From f18850e5f8210ebec6e33db1faf1a4162b875120 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 11 Feb 2012 15:17:12 +0100 Subject: [PATCH] Misc: Add @completenick. Closes GH-154. --- plugins/Misc/plugin.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/Misc/plugin.py b/plugins/Misc/plugin.py index 66e072c24..f42fc1a5d 100644 --- a/plugins/Misc/plugin.py +++ b/plugins/Misc/plugin.py @@ -504,6 +504,28 @@ class Misc(callbacks.Plugin): """ irc.reply(_('pong'), prefixNick=False) + @internationalizeDocstring + def completenick(self, irc, msg, args, channel, beginning, optlist): + """[] [--match-case] + + Returns the nick of someone on the channel whose nick begins with the + given . + defaults to the current channel.""" + if ('match-case', True) in optlist: + def match(nick): + return nick.startswith(beginning) + else: + beginning = beginning.lower() + def match(nick): + return nick.lower().startswith(beginning) + for nick in irc.state.channels[channel].users: + if match(nick): + irc.reply(nick) + return + irc.error(_('No such nick.')) + completenick = wrap(completenick, ['channel', 'something', + getopts({'match-case':''})]) + Class = Misc # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: