From 07575ac98459ba12823845b8054e7fd2e8648c50 Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Mon, 11 May 2009 17:54:36 +0000 Subject: add pingall command. Pings all nicks on the channel. - currently can be used by anyone. This can be changed if it is abused. darcs-hash:20090511175436-82ea9-ef91d5b2b83fcaac11878d456824300a665c7720.gz --- (limited to 'plugin.py') diff --git a/plugin.py b/plugin.py index b67a5ab..f85368f 100644 --- a/plugin.py +++ b/plugin.py @@ -116,6 +116,42 @@ class MeetBot(callbacks.Plugin): irc.reply("Saved %d meetings."%numSaved) savemeetings = wrap(savemeetings, ['owner']) + def pingall(self, irc, msg, args, message): + """Send a broadcast ping to all users on the channel. + + An message to be sent along with this ping must also be + supplied for this command to work. + """ + nick = msg.nick + channel = msg.args[0] + payload = msg.args[1] + + # We require a message to go out with the ping, we don't want + # to waste people's time: + if channel[0] != '#': + irc.reply("Not joined to any channel.") + return + if message is None: + irc.reply("You must supply a description with the `pingall` command. We don't want to go wasting people's times looking for why they are pinged.") + return + + # Send announcement message + irc.sendMsg(ircmsgs.privmsg(channel, message)) + # ping all nicks in lines of about 256 + nickline = '' + nicks = sorted(irc.state.channels[channel].users, + key=lambda x: x.lower()) + for nick in nicks: + nickline = nickline + nick + ' ' + if len(nickline) > 256: + irc.sendMsg(ircmsgs.privmsg(channel, nickline)) + nickline = '' + irc.sendMsg(ircmsgs.privmsg(channel, nickline)) + # Send announcement message + irc.sendMsg(ircmsgs.privmsg(channel, message)) + + pingall = wrap(pingall, [optional('text', None)]) + Class = MeetBot -- cgit v0.9.1