Revert the non-PRIVMSG changes until after the release

This commit is contained in:
James Vega 2004-12-30 05:38:34 +00:00
parent 8d4244f04e
commit 7a176eead3

View File

@ -65,8 +65,6 @@ class IrcStringAndIntDict(utils.InsensitivePreservingDict):
else:
return ircutils.toLower(x)
ANY = '<any>'
class SeenDB(plugins.ChannelUserDB):
IdDict = IrcStringAndIntDict
def serialize(self, v):
@ -129,68 +127,25 @@ class Seen(callbacks.Privmsg):
said = ircmsgs.prettyPrint(msg)
channel = plugins.getChannel(msg.args[0])
self.db.update(channel, msg.nick, said)
self.db.update(ANY + channel, msg.nick, said)
try:
id = ircdb.users.getUserId(msg.prefix)
self.db.update(channel, id, said)
self.db.update(ANY + channel, id, said)
except KeyError:
pass # Not in the database.
# non-PRIVMSG which have a channel association
def doNonPrivmsgWithChannel(self, irc, msg):
if irc.isChannel(msg.args[0]):
said = ircmsgs.prettyPrint(msg)
channel = ANY + plugins.getChannel(msg.args[0])
self.db.update(channel, msg.nick, said)
try:
id = ircdb.users.getUserId(msg.prefix)
self.db.update(channel, id, said)
except KeyError:
pass # Not in the database.
doJoin = doNonPrivmsgWithChannel
doKick = doNonPrivmsgWithChannel
doMode = doNonPrivmsgWithChannel
doPart = doNonPrivmsgWithChannel
doTopic = doNonPrivmsgWithChannel
doNotice = doNonPrivmsgWithChannel
# non-PRIVMSG which don't have a channel association
def doNonPrivmsg(self, irc, msg):
said = ircmsgs.prettyPrint(msg)
self.db.update(ANY, msg.nick, said)
try:
id = ircdb.users.getUserId(msg.prefix)
self.db.update(ANY, id, said)
except KeyError:
pass # Not in the database.
doNick = doNonPrivmsg
doQuit = doNonPrivmsg
def seen(self, irc, msg, args, channel, optlist, name):
"""[<channel>] [--any] <nick>
def seen(self, irc, msg, args, channel, name):
"""[<channel>] <nick>
Returns the last time <nick> was seen and what <nick> was last seen
saying. * can be used as a wildcard in the nick. If --any is
specified, also search for non-PRIVMSG activity. <channel> is only
necessary if the message isn't sent on the channel itself.
saying. <channel> is only necessary if the message isn't sent on the
channel itself.
"""
any = False
for (opt, _) in optlist:
if opt == 'any':
any = True
try:
results = []
if '*' in name:
if not any:
results = self.db.seenWildcard(channel, name)
else:
results = self.db.seenWildcard(ANY + channel, name)
results = self.db.seenWildcard(channel, name)
else:
if not any:
results = [[name, self.db.seen(channel, name)]]
else:
results = [[name, self.db.seen(ANY + channel, name)]]
results = [[name, self.db.seen(channel, name)]]
if len(results) == 1:
(nick, info) = results[0]
(when, said) = info
@ -209,9 +164,7 @@ class Seen(callbacks.Privmsg):
irc.reply('I haven\'t seen anyone matching %s.' % name)
except KeyError:
irc.reply('I have not seen %s.' % name)
# Have to use 'something' instead of 'nick' because * isn't necessarily a
# valid character in a nick
seen = wrap(seen, ['channeldb', getopts({'any': ''}), 'something'])
seen = wrap(seen, ['channeldb', 'nick'])
def last(self, irc, msg, args, channel):
"""[<channel>]
@ -227,31 +180,24 @@ class Seen(callbacks.Privmsg):
irc.reply('I have never seen anyone.')
last = wrap(last, ['channeldb'])
def user(self, irc, msg, args, channel, optlist, user):
"""[<channel>] [--any] <name>
def user(self, irc, msg, args, channel, user):
"""[<channel>] <name>
Returns the last time <name> was seen and what <name> was last seen
saying. This looks up <name> in the user seen database, which means
that it could be any nick recognized as user <name> that was seen. If
--any is specified, also search for non-PRIVMSG activity by <name>.
that it could be any nick recognized as user <name> that was seen.
<channel> is only necessary if the message isn't sent in the channel
itself.
"""
any = False
for (opt, arg) in optlist:
if opt == 'any':
any = True
try:
if not any:
(when, said) = self.db.seen(channel, user.id)
else:
(when, said) = self.db.seen(ANY + channel, user.id)
(when, said) = self.db.seen(channel, user.id)
irc.reply('%s was last seen in %s %s ago saying: %s' %
(user.name, channel, utils.timeElapsed(time.time()-when),
said))
except KeyError:
irc.reply('I have not seen %s.' % user.name)
user = wrap(user, ['channeldb', getopts({'any': ''}), 'otherUser'])
user = wrap(user, ['channeldb', 'otherUser'])
Class = Seen