2011-11-09 02:07:51 +00:00
|
|
|
from random import choice
|
|
|
|
from tabs import MucTab
|
|
|
|
|
|
|
|
from plugin import BasePlugin
|
|
|
|
|
|
|
|
class Plugin(BasePlugin):
|
|
|
|
def init(self):
|
2013-03-08 21:53:35 +00:00
|
|
|
self.api.add_command('pacokick', self.command_kick,
|
2013-03-01 18:25:31 +00:00
|
|
|
usage='',
|
|
|
|
help='Kick a random user.',
|
|
|
|
short='Kick a random user')
|
2011-11-09 02:07:51 +00:00
|
|
|
|
|
|
|
def command_kick(self, arg):
|
2013-03-08 21:53:35 +00:00
|
|
|
tab = self.api.current_tab()
|
2011-11-09 02:07:51 +00:00
|
|
|
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:
|
2013-03-08 21:53:35 +00:00
|
|
|
self.api.information('No one to kick :(', 'Info')
|