mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Revert the non-PRIVMSG changes until after the release
This commit is contained in:
parent
8d4244f04e
commit
7a176eead3
@ -65,8 +65,6 @@ class IrcStringAndIntDict(utils.InsensitivePreservingDict):
|
|||||||
else:
|
else:
|
||||||
return ircutils.toLower(x)
|
return ircutils.toLower(x)
|
||||||
|
|
||||||
ANY = '<any>'
|
|
||||||
|
|
||||||
class SeenDB(plugins.ChannelUserDB):
|
class SeenDB(plugins.ChannelUserDB):
|
||||||
IdDict = IrcStringAndIntDict
|
IdDict = IrcStringAndIntDict
|
||||||
def serialize(self, v):
|
def serialize(self, v):
|
||||||
@ -129,68 +127,25 @@ class Seen(callbacks.Privmsg):
|
|||||||
said = ircmsgs.prettyPrint(msg)
|
said = ircmsgs.prettyPrint(msg)
|
||||||
channel = plugins.getChannel(msg.args[0])
|
channel = plugins.getChannel(msg.args[0])
|
||||||
self.db.update(channel, msg.nick, said)
|
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:
|
try:
|
||||||
id = ircdb.users.getUserId(msg.prefix)
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
self.db.update(channel, id, said)
|
self.db.update(channel, id, said)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass # Not in the database.
|
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 seen(self, irc, msg, args, channel, name):
|
||||||
def doNonPrivmsg(self, irc, msg):
|
"""[<channel>] <nick>
|
||||||
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>
|
|
||||||
|
|
||||||
Returns the last time <nick> was seen and what <nick> was last seen
|
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
|
saying. <channel> is only necessary if the message isn't sent on the
|
||||||
specified, also search for non-PRIVMSG activity. <channel> is only
|
channel itself.
|
||||||
necessary if the message isn't sent on the channel itself.
|
|
||||||
"""
|
"""
|
||||||
any = False
|
|
||||||
for (opt, _) in optlist:
|
|
||||||
if opt == 'any':
|
|
||||||
any = True
|
|
||||||
try:
|
try:
|
||||||
results = []
|
results = []
|
||||||
if '*' in name:
|
if '*' in name:
|
||||||
if not any:
|
results = self.db.seenWildcard(channel, name)
|
||||||
results = self.db.seenWildcard(channel, name)
|
|
||||||
else:
|
|
||||||
results = self.db.seenWildcard(ANY + channel, name)
|
|
||||||
else:
|
else:
|
||||||
if not any:
|
results = [[name, self.db.seen(channel, name)]]
|
||||||
results = [[name, self.db.seen(channel, name)]]
|
|
||||||
else:
|
|
||||||
results = [[name, self.db.seen(ANY + channel, name)]]
|
|
||||||
if len(results) == 1:
|
if len(results) == 1:
|
||||||
(nick, info) = results[0]
|
(nick, info) = results[0]
|
||||||
(when, said) = info
|
(when, said) = info
|
||||||
@ -209,9 +164,7 @@ class Seen(callbacks.Privmsg):
|
|||||||
irc.reply('I haven\'t seen anyone matching %s.' % name)
|
irc.reply('I haven\'t seen anyone matching %s.' % name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply('I have not seen %s.' % name)
|
irc.reply('I have not seen %s.' % name)
|
||||||
# Have to use 'something' instead of 'nick' because * isn't necessarily a
|
seen = wrap(seen, ['channeldb', 'nick'])
|
||||||
# valid character in a nick
|
|
||||||
seen = wrap(seen, ['channeldb', getopts({'any': ''}), 'something'])
|
|
||||||
|
|
||||||
def last(self, irc, msg, args, channel):
|
def last(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
@ -227,31 +180,24 @@ class Seen(callbacks.Privmsg):
|
|||||||
irc.reply('I have never seen anyone.')
|
irc.reply('I have never seen anyone.')
|
||||||
last = wrap(last, ['channeldb'])
|
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
|
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
|
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
|
that it could be any nick recognized as user <name> that was seen.
|
||||||
--any is specified, also search for non-PRIVMSG activity by <name>.
|
|
||||||
<channel> is only necessary if the message isn't sent in the channel
|
<channel> is only necessary if the message isn't sent in the channel
|
||||||
itself.
|
itself.
|
||||||
"""
|
"""
|
||||||
any = False
|
|
||||||
for (opt, arg) in optlist:
|
|
||||||
if opt == 'any':
|
|
||||||
any = True
|
|
||||||
try:
|
try:
|
||||||
if not any:
|
(when, said) = self.db.seen(channel, user.id)
|
||||||
(when, said) = self.db.seen(channel, user.id)
|
|
||||||
else:
|
|
||||||
(when, said) = self.db.seen(ANY + channel, user.id)
|
|
||||||
irc.reply('%s was last seen in %s %s ago saying: %s' %
|
irc.reply('%s was last seen in %s %s ago saying: %s' %
|
||||||
(user.name, channel, utils.timeElapsed(time.time()-when),
|
(user.name, channel, utils.timeElapsed(time.time()-when),
|
||||||
said))
|
said))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply('I have not seen %s.' % user.name)
|
irc.reply('I have not seen %s.' % user.name)
|
||||||
user = wrap(user, ['channeldb', getopts({'any': ''}), 'otherUser'])
|
user = wrap(user, ['channeldb', 'otherUser'])
|
||||||
|
|
||||||
|
|
||||||
Class = Seen
|
Class = Seen
|
||||||
|
Loading…
Reference in New Issue
Block a user