poezio/plugins/pacokick.py
mathieui e1956533a6 Fix #2231 (update the plugins to use the new help system)
And fix some imprecisions/mistakes in the help.
2013-03-01 19:25:31 +01:00

23 lines
781 B
Python

from random import choice
from tabs import MucTab
from plugin import BasePlugin
class Plugin(BasePlugin):
def init(self):
self.add_command('pacokick', self.command_kick,
usage='',
help='Kick a random user.',
short='Kick a random user')
def command_kick(self, arg):
tab = self.core.current_tab()
if isinstance(tab, MucTab):
kickable = list(filter(lambda x: x.affiliation in ('none', 'member'), tab.users))
if kickable:
to_kick = choice(kickable)
if to_kick:
to_kick = to_kick.nick
tab.command_kick(to_kick + ' ' +arg)
else:
self.core.information('No one to kick :(', 'Info')