]>
Commit | Line | Data |
---|---|---|
f30d341c JR |
1 | import sys |
2 | ||
3 | class Pseudo(object): | |
4 | def __init__(self, uplink): | |
5 | self.uplink = uplink | |
6 | self.nick = 'Do' | |
7 | self.num = self.uplink.makenick(self, self.nick, 'TheDoBot','PyP10 Do') | |
1a1d9e61 JR |
8 | self.uplink.join("#p10", self.num, op=True) |
9 | self.uplink.endburst(self) | |
f30d341c JR |
10 | def _send(self, line, **kwargs): |
11 | self.uplink.send(line, self.num, **kwargs) | |
12 | def gotmsg(self, msg, source, target): | |
13 | command, args = msg.split(None, 1) | |
14 | if command == 'exec': | |
15 | try: | |
16 | exec(args, globals(), locals()) | |
17 | except: | |
18 | self._send("P #p10 :!%(fromnum)s! exec - Exception: %(exc)r", fromnum=source, exc=sys.exc_info()[1]) | |
19 | else: | |
20 | self._send("P #p10 :!%(fromnum)s! exec - Done.", fromnum=source) | |
21 | elif command == 'eval': | |
22 | retval = None | |
23 | try: | |
24 | retval = eval(args, globals(), locals()) | |
25 | except: | |
26 | self._send("P #p10 :!%(fromnum)s! eval - Exception: %(exc)r", fromnum=source, exc=sys.exc_info()[1]) | |
27 | else: | |
28 | self._send("P #p10 :!%(fromnum)s! eval - Return: %(retval)r", fromnum=source, retval=retval) |