e1956533a6
And fix some imprecisions/mistakes in the help.
66 lines
2.7 KiB
Python
66 lines
2.7 KiB
Python
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),
|
|
help='Set the role of a nick to %s' % role,
|
|
usage= '<nick>',
|
|
short='Set the role to %s' % role,
|
|
completion=self.complete_nick)
|
|
|
|
for aff in ('member', 'owner', 'admin'):
|
|
self.add_tab_command(MucTab, aff, self.affiliation(aff),
|
|
usage='<nick>',
|
|
help='Set the affiliation of a nick to %s' % aff,
|
|
short='Set the affiliation to %s' % aff,
|
|
completion=self.complete_nick)
|
|
|
|
self.add_tab_command(MucTab, 'noaffiliation', self.affiliation('none'),
|
|
usage='<nick>',
|
|
help='Set the affiliation of a nick to none.',
|
|
short='Set the affiliation to none.',
|
|
completion=self.complete_nick)
|
|
self.add_tab_command(MucTab, 'voice', self.affiliation('member'),
|
|
usage='<nick>',
|
|
help='Set the affiliation of a nick to member.',
|
|
short='Set the affiliation to member.',
|
|
completion=self.complete_nick)
|
|
self.add_tab_command(MucTab, 'op', self.role('moderator'),
|
|
usage='<nick>',
|
|
help='Set the role of a nick to moderator.',
|
|
short='Set the role to moderator.',
|
|
completion=self.complete_nick)
|
|
self.add_tab_command(MucTab, 'mute', self.role('visitor'),
|
|
usage='<nick>',
|
|
help='Set the role of a nick to visitor.',
|
|
short='Set the role to visitor.',
|
|
completion=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, '')
|
|
|
|
|
|
|