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