poezio/plugins/pacokick.py
mathieui 9885203c67 Update the plugins to use the PluginAPI
Also:
- Add get_conversation_messages() to PluginAPI
- Make plugins_autoload colon-separated instead of space-separated
    (for consistency)
- Replace a JID() with a safeJID() in the uptime plugin
2013-03-08 22:53:35 +01:00

23 lines
783 B
Python

from random import choice
from tabs import MucTab
from plugin import BasePlugin
class Plugin(BasePlugin):
def init(self):
self.api.add_command('pacokick', self.command_kick,
usage='',
help='Kick a random user.',
short='Kick a random user')
def command_kick(self, arg):
tab = self.api.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.api.information('No one to kick :(', 'Info')