]>
jfr.im git - z_archive/pyp10.git/blob - modules/do.py
4 def __init__(self
, uplink
):
7 self
.num
= self
.uplink
.makenick(self
, self
.nick
, 'TheDoBot','PyP10 Do')
8 self
.uplink
.join("#p10", self
.num
, op
=True)
9 self
.uplink
.endburst(self
)
10 def _send(self
, line
, **kwargs
):
11 self
.uplink
.send(line
, self
.num
, **kwargs
)
12 def gotmsg(self
, msg
, source
, target
):
13 msgpieces
= msg
.split(None, 1)
14 if len(msgpieces
) >= 1:
15 command
= msgpieces
[0]
16 if len(msgpieces
) >= 2:
19 user
= self
.uplink
.getuser(source
)
21 self
._send
("O %(fromnum)s :You aren't authorized to use this service.")
26 exec(args
, globals(), locals())
28 self
._send
("P #p10 :!%(fromnum)s! exec - Exception: %(exc)r", fromnum
=source
, exc
=sys
.exc_info()[1])
30 self
._send
("P #p10 :!%(fromnum)s! exec - Done.", fromnum
=source
)
31 elif command
== 'eval':
34 retval
= eval(args
, globals(), locals())
36 self
._send
("P #p10 :!%(fromnum)s! eval - Exception: %(exc)r", fromnum
=source
, exc
=sys
.exc_info()[1])
38 self
._send
("P #p10 :!%(fromnum)s! eval - Return: %(retval)r", fromnum
=source
, retval
=retval
)
39 elif command
== 'whoami':
40 user
= self
.uplink
.getuser(source
)
42 self
._send
("O %(fromnum)s :You're %(nick)s, oper", fromnum
=source
, nick
=user
.nick
)
44 self
._send
("O %(fromnum)s :You're %(nick)s.", fromnum
=source
, nick
=user
.nick
)