Skip to content

Commit f18850e

Browse files
committed
Misc: Add @completenick. Closes GH-154.
1 parent d8ecc7d commit f18850e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

plugins/Misc/plugin.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,28 @@ def ping(self, irc, msg, args):
504504
"""
505505
irc.reply(_('pong'), prefixNick=False)
506506

507+
@internationalizeDocstring
508+
def completenick(self, irc, msg, args, channel, beginning, optlist):
509+
"""[<channel>] <beginning> [--match-case]
510+
511+
Returns the nick of someone on the channel whose nick begins with the
512+
given <beginning>.
513+
<channel> defaults to the current channel."""
514+
if ('match-case', True) in optlist:
515+
def match(nick):
516+
return nick.startswith(beginning)
517+
else:
518+
beginning = beginning.lower()
519+
def match(nick):
520+
return nick.lower().startswith(beginning)
521+
for nick in irc.state.channels[channel].users:
522+
if match(nick):
523+
irc.reply(nick)
524+
return
525+
irc.error(_('No such nick.'))
526+
completenick = wrap(completenick, ['channel', 'something',
527+
getopts({'match-case':''})])
528+
507529
Class = Misc
508530

509531
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

0 commit comments

Comments
 (0)