]>
jfr.im git - erebus.git/blob - modules/control.py
1 # Erebus IRC bot - Author: Erebus Team
2 # Various highly recommended "control" commands.
3 # This file is released into the public domain; see http://unlicense.org/
7 'author': 'Erebus Team',
8 'license': 'public domain',
15 lib
= modlib
.modlib(__name__
)
16 modstart
= lib
.modstart
24 @lib.hook(needchan
=False, glevel
=lib
.MANAGER
)
25 def die(bot
, user
, chan
, realtarget
, *args
):
26 for botitem
in bot
.parent
.bots
.itervalues():
27 for chan
in botitem
.chans
:
28 chan
.fastmsg("Bot is restarting! %s" % ' '.join(args
))
29 bot
.conn
.send("QUIT :Restarting.")
33 @lib.hook(needchan
=False, glevel
=lib
.MANAGER
)
35 def modload(bot
, user
, chan
, realtarget
, *args
):
36 okay
= ctlmod
.load(bot
.parent
, args
[0])
38 bot
.msg(user
, "Loaded %s" % (args
[0]))
40 bot
.msg(user
, "Error loading %s: %r" % (args
[0], okay
))
42 @lib.hook(needchan
=False, glevel
=lib
.MANAGER
)
44 def modunload(bot
, user
, chan
, realtarget
, *args
):
45 okay
= ctlmod
.unload(bot
.parent
, args
[0])
47 bot
.msg(user
, "Unloaded %s" % (args
[0]))
49 bot
.msg(user
, "Error unloading %s: %r" % (args
[0], okay
))
51 @lib.hook(needchan
=False, glevel
=lib
.MANAGER
)
53 def modreload(bot
, user
, chan
, realtarget
, *args
):
54 okay
= ctlmod
.reloadmod(bot
.parent
, args
[0])
56 bot
.msg(user
, "Reloaded %s" % (args
[0]))
58 bot
.msg(user
, "Error occurred: %r" % (okay
))
60 @lib.hook(needchan
=False, glevel
=lib
.STAFF
)
62 def modlist(bot
, user
, chan
, realtarget
, *args
):
64 for mod
in mods
.itervalues():
65 bot
.msg(user
, "- %s %r" % (mod
.__name
__, mod
))
66 bot
.msg(user
, "Done.")
68 @lib.hook(cmd
='whoami', needchan
=False)
69 def whoami(bot
, user
, chan
, realtarget
, *args
):
70 if not user
.isauthed():
71 bot
.msg(user
, "You are not authed.")
74 fillers
= {'auth': user.auth}
75 fmt
= "You are %(auth)s"
78 fillers
['glevel'] = user
.glevel
79 fmt
+= " (global access: %(glevel)s)"
83 if chan
is not None and chan
.levelof(user
.auth
) >= 1:
84 fillers
['clevel'] = chan
.levelof(user
.auth
)
85 fmt
+= " (channel access: %(clevel)s)"
87 fmt
+= " (not a channel user)"
88 bot
.msg(user
, fmt
% fillers
)