]>
Commit | Line | Data |
---|---|---|
685e346e A |
1 | import pseudoclient.sys_base |
2 | ||
3 | from datetime import datetime | |
4 | from utils import * | |
5 | ||
6 | #---------------------------------------------------------------------# | |
7 | # import admin cmds and re-export commands we don't need to override | |
8 | ||
9 | from pseudoclient import cmd_admin | |
10 | from pseudoclient.cmd_admin import \ | |
11 | admin_unregistered, \ | |
12 | admin_chan, \ | |
13 | admin_log, \ | |
14 | admin_msg, \ | |
15 | admin_opt, \ | |
16 | admin_db | |
17 | ||
18 | #---------------------------------------------------------------------# | |
19 | ||
20 | def admin_sys(self, source, target, pieces): | |
21 | if len(pieces) < 2: | |
22 | return False | |
23 | ||
24 | starget = pieces[0] | |
25 | operation = pieces[1] | |
26 | names = [] | |
27 | subsystems = [] | |
28 | ||
29 | if 'o' in starget: | |
30 | names.append('options') | |
31 | subsystems.append(self.options) | |
32 | ||
33 | if 'c' in starget: | |
34 | names.append('channels') | |
35 | subsystems.append(self.channels) | |
36 | ||
37 | if 'a' in starget: | |
38 | names.append('auth') | |
39 | subsystems.append(self.auth) | |
40 | ||
41 | if len(names) == 0: | |
42 | return False | |
43 | ||
44 | if operation in ['u', 'update']: | |
45 | for subsystem in subsystems: | |
46 | subsystem.force() | |
47 | ||
48 | self.msg(target, 'Forced update for @b%s@b.' % '@b, @b'.join(names)) | |
49 | elif operation in ['r', 'reload']: | |
50 | for subsystem in subsystems: | |
51 | subsystem.reload() | |
52 | ||
53 | self.msg(target, 'Forced reload for @b%s@b.' % '@b, @b'.join(names)) | |
54 | else: | |
55 | return False | |
56 | ||
57 | return True | |
58 | ||
59 | def admin_stats(self, source, target, pieces): | |
60 | self.msg(target, 'Registered channels: @b%d@b.' % len(self.channels.list_all())) | |
61 | return True | |
62 | ||
63 | def admin_qsize(self, source, target, pieces): | |
64 | self.msg(target, 'Queue size: %d' % len(self.limit_monitor)) | |
65 | return True | |
66 | ||
67 | def get_commands(): | |
68 | return { | |
69 | 'chan' : (admin_chan, '<ban|unban|info|add|remove|list|blist> <channel> [reason]'), | |
70 | 'unreg' : (admin_unregistered, '<check|list|part> - remove unregistered channels'), | |
71 | 'stats' : (admin_stats, 'counts registered channels'), | |
72 | 'db' : (admin_db, '[on|off] - enables/disables auto commits to db'), | |
73 | 'opt' : (admin_opt, '[get|set|clear] [option] [value] - manipulates options (list all if no arguments)'), | |
74 | 'sys' : (admin_sys, '<subsystem> <operation> [value] - (subsystems: options (o), channels (c), auth (a)) (operations: update (u), reload (r))'), | |
75 | 'log' : (admin_log, '[level] - gets or sets the log level (0-7).'), | |
76 | 'msg' : (admin_msg, '<message> - sends a message to all channels'), | |
77 | 'qsize' : (admin_qsize, '[debug command] shows channel update queue size'), | |
78 | } |