summaryrefslogtreecommitdiff
path: root/plugins/admin.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-05-05 02:08:35 +0200
committermathieui <mathieui@mathieui.net>2012-05-05 02:08:35 +0200
commit6ff2f2acc6e995440f6be414680e426031d71a79 (patch)
treecdc723d2c24c040f954b6665765b46c0c082aee0 /plugins/admin.py
parentfcdf98eda203c7cea76de8d49a4b65bcf75412dc (diff)
downloadpoezio-6ff2f2acc6e995440f6be414680e426031d71a79.tar.gz
poezio-6ff2f2acc6e995440f6be414680e426031d71a79.tar.bz2
poezio-6ff2f2acc6e995440f6be414680e426031d71a79.tar.xz
poezio-6ff2f2acc6e995440f6be414680e426031d71a79.zip
Add an "Admin" plug-in that add several shortcuts for room administration
Diffstat (limited to 'plugins/admin.py')
-rw-r--r--plugins/admin.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/plugins/admin.py b/plugins/admin.py
new file mode 100644
index 00000000..8f4e67a7
--- /dev/null
+++ b/plugins/admin.py
@@ -0,0 +1,51 @@
+from plugin import BasePlugin
+from tabs import MucTab
+
+class Plugin(BasePlugin):
+ """
+ Adds several convenient aliases to /affiliation and /role:
+ /visitor
+ /participant
+ /moderator == /op
+ /member == /voice
+ /owner
+ /admin
+ /noaffiliation
+ """
+ def init(self):
+ for role in ['visitor', 'participant' , 'moderator']:
+ self.add_tab_command(MucTab, role, self.role(role),
+ '/%s <nick>\n%s: Set the role of a nick to %s.' %
+ (role, role.capitalize(), role), self.complete_nick)
+
+ for aff in ['member', 'owner', 'admin']:
+ self.add_tab_command(MucTab, aff, self.affiliation(aff),
+ '/%s <nick>\n%s: set the affiliation of a nick to %s' %
+ (aff, aff.capitalize(), aff), self.complete_nick)
+
+ self.add_tab_command(MucTab, 'noaffiliation', self.affiliation('none'),
+ '/noaffiliation <nick>\nNoAffiliation: set the affiliation of a nick to none.',
+ self.complete_nick)
+ self.add_tab_command(MucTab, 'voice', self.affiliation('member'),
+ '/voice <nick>\nVoice: set the affiliation of a nick to member.',
+ self.complete_nick)
+ self.add_tab_command(MucTab, 'op', self.role('moderator'),
+ '/op <nick>\nOp: set the role of a nick to moderator.',
+ self.complete_nick)
+
+ def role(self, role):
+ return lambda args: self.core.current_tab().command_role(args+' '+role)
+
+ def affiliation(self, affiliation):
+ return lambda args: self.core.current_tab().command_affiliation(
+ args+' '+affiliation)
+
+ def complete_nick(self, the_input):
+ tab = self.core.current_tab()
+ compare_users = lambda x: x.last_talked
+ word_list = [user.nick for user in sorted(tab.users, key=compare_users, reverse=True)\
+ if user.nick != tab.own_nick]
+ return the_input.auto_completion(word_list, '')
+
+
+