]> jfr.im git - irc/rizon/acid.git/blob - pyva/src/main/python/trivia/sys_auth.py
.gitignore: Ignore all pyva logs
[irc/rizon/acid.git] / pyva / src / main / python / trivia / sys_auth.py
1 from pseudoclient.sys_auth import AuthManager
2
3 class TriviaAuthManager(AuthManager):
4 def __init__(self, module):
5 AuthManager.__init__(self, module)
6
7 def onAccept(self, user, request, action, channel):
8 if action == 'news':
9 if self.module.channels.is_valid(channel):
10 self.module.channels.set(channel, 'news', True)
11 self.module.msg(user, 'Enabled news in @b%s@b.' % channel)
12 elif action == 'nonews':
13 if self.module.channels.is_valid(channel):
14 self.module.channels.set(channel, 'news', False)
15 self.module.msg(user, 'Disabled news in @b%s@b.' % channel)
16 elif action.startswith('set_theme_'):
17 reqtheme = action[10:].lower()
18 settheme = ""
19 for theme in self.module.themes:
20 if reqtheme == theme[0].lower() or reqtheme == theme[1].lower():
21 settheme = theme[0] # we only care for the table name
22 break
23 else:
24 # XXX: Breaking compatibility; original trivia first checks
25 # if the calling user is founder; we save the effort.
26 self.module.notice(user, 'Theme %s not found.' % reqtheme)
27 del self.requests[user]
28 return True
29
30 # XXX: Breaking compatibility; orig trivia uses malformed msg
31 self.module.dbp.execute("UPDATE trivia_chans SET theme = %s WHERE id = %s",
32 (settheme, self.module.get_cid(channel)))
33 self.module.notice(user,
34 "Updated the trivia theme of %s to %s." % (channel, reqtheme))
35 else:
36 return False
37
38 return True