From ea90ba36dbc117684702587926dc013ec01b7396 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 30 Apr 2004 19:19:59 +0000 Subject: [PATCH] Added ignores. --- plugins/Note.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/plugins/Note.py b/plugins/Note.py index f9b3c4144..570e53ad7 100644 --- a/plugins/Note.py +++ b/plugins/Note.py @@ -38,6 +38,7 @@ __revision__ = "$Id$" import plugins +import sets import time import getopt import os.path @@ -72,6 +73,11 @@ conf.registerGlobalValue(conf.supybot.plugins.Note, 'notifyOnJoinRepeatedly', when they join the channel, the bot will tell them they have unread messages, even if it's told them before.""")) +class Ignores(registry.SpaceSeparatedListOfStrings): + List = ircutils.IrcSet + +conf.registerUserValue(conf.users.plugins.Note, 'ignores', Ignores([], '')) + class NoteDb(plugins.DBHandler): def makeDb(self, filename): "create Notes database and tables" @@ -158,9 +164,13 @@ class Note(callbacks.Privmsg): return try: fromId = ircdb.users.getUserId(msg.prefix) + senderName = ircdb.users.getUser(fromId).name except KeyError: irc.errorNotRegistered() return + if senderName in self.userValue('ignores', name): + irc.error('That user has ignored messages from you.') + return if ircutils.isChannel(msg.args[0]): public = 1 else: @@ -260,6 +270,32 @@ class Note(callbacks.Privmsg): else: return '#%s (private)' % id + def ignore(self, irc, msg, args): + """[--remove] + + Ignores all messages from . If --remove is listed, remove + from the list of users being ignored. + """ + remove = False + while '--remove' in args: + remove = True + args.remove('--remove') + user = privmsgs.getArgs(args) + try: + L = self.userValue('ignores', msg.prefix) + if remove: + try: + L.remove(user) + except (KeyError, ValueError): + irc.error('%r was not in your list of ignores.' % user) + return + else: + L.add(user) + self.setUserValue(msg.prefix, 'ignores', L, setValue=True) + irc.replySuccess() + except KeyError: + irc.errorNoUser() + def list(self, irc, msg, args): """[--{old,sent}] [--{from,to} ]