mod_admin.py

Mon, 03 Aug 2015 19:45:57 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 03 Aug 2015 19:45:57 +0300
changeset 145
588aff83bb87
parent 121
ac07779f788d
child 146
c17b82b1f573
permissions
-rw-r--r--

- Encode messages in the hgpoll module so that joining them won't result in an error if they cannot be coded to ascii
- Support for Doomseeker's VERSION_STRING in version string parsing

65
20bd76353eb5 - modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents: 64
diff changeset
1 from modulecore import command_error
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
2 import sys
62
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 ModuleData = {
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 'commands':
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 [
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 {
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 'name': 'raw',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 'description': 'Sends a raw message to the server',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 'args': '<message...>',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 'level': 'admin',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 },
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 {
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 'name': 'msg',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 'description': 'Sends a message to someone',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 'args': '<recipient> <message...>',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 'level': 'admin',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 },
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 {
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 'name': 'restart',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 'description': 'Restarts the bot',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 'args': None,
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 'level': 'admin',
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 },
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 {
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
29 'name': 'die',
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
30 'description': 'Shuts the bot down',
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
31 'args': None,
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
32 'level': 'admin',
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
33 },
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
34
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
35 {
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
36 'name': 'modreload',
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
37 'description': 'Reloads a module',
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
38 'args': '<module>',
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
39 'level': 'admin',
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
40 },
62
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 ]
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 }
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 def cmd_raw (bot, args, **rest):
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 bot.write (args['message'])
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 def cmd_msg (bot, args, **rest):
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 bot.privmsg (args['recipient'], args['message'])
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 def cmd_restart (bot, **rest):
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 bot.restart()
052a8a1e3d7d - revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
53 def cmd_die (bot, **rest):
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
54 quit()
121
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
55
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
56 def cmd_modreload (bot, args, **rest):
ac07779f788d - reworked mercurial repository handling, removed hardcoded values
Teemu Piippo <crimsondusk64@gmail.com>
parents: 103
diff changeset
57 reload (sys.modules[args['module']])

mercurial