From 6330be8758418042ab9accb10ebd1b4eda8049dd Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 18 Dec 2015 22:04:42 -0800 Subject: [PATCH] chancmds: add TOPIC command, fix help text of KICK (it is admin-only, not oper-only) For #90. --- plugins/chancmds.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/chancmds.py b/plugins/chancmds.py index 3821106..d2f657a 100644 --- a/plugins/chancmds.py +++ b/plugins/chancmds.py @@ -14,7 +14,7 @@ from log import log def kick(irc, source, args): """ [] - Oper only. Kicks from via , where is either the nick of a PyLink client or the SID of a PyLink server.""" + Admin only. Kicks from via , where is either the nick of a PyLink client or the SID of a PyLink server.""" utils.checkAuthenticated(irc, source, allowOper=False) try: sourcenick = args[0] @@ -53,3 +53,26 @@ def kick(irc, source, args): irc.callHooks([u, 'CHANCMDS_KICK', {'channel': channel, 'target': targetu, 'text': reason, 'parse_as': 'KICK'}]) + +@utils.add_cmd +def topic(irc, source, args): + """ + + Admin only. Updates the topic in a channel.""" + utils.checkAuthenticated(irc, source, allowOper=False) + try: + channel = args[0] + topic = ' '.join(args[1:]) + except IndexError: + irc.reply("Error: Not enough arguments. Needs 2: channel, topic.") + return + + if channel not in irc.channels: + irc.reply("Error: Unknown channel %r." % channel) + return + + irc.proto.topicClient(irc.pseudoclient.uid, channel, topic) + + irc.callHooks([irc.pseudoclient.uid, 'CHANCMDS_TOPIC', + {'channel': channel, 'text': topic, 'setter': source, + 'parse_as': 'TOPIC'}])