mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-10-18 09:57:26 +02:00
Add Seen trackers for PART, JOIN, QUIT (and fix ircmsgs.prettyPrint for QUIT)
This commit is contained in:
parent
4db8096757
commit
4b32a206c4
@ -82,6 +82,16 @@ class SeenDB(plugins.ChannelUserDB):
|
|||||||
def seen(self, channel, nickOrId):
|
def seen(self, channel, nickOrId):
|
||||||
return self[channel, nickOrId]
|
return self[channel, nickOrId]
|
||||||
|
|
||||||
|
conf.registerPlugin('Seen')
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.Seen, 'trackJoins',
|
||||||
|
registry.Boolean(False, """Determines whether the bot will track JOINs for
|
||||||
|
the Seen database."""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.Seen, 'trackParts',
|
||||||
|
registry.Boolean(False, """Determines whether the bot will track PARTs for
|
||||||
|
the Seen database."""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.Seen, 'trackQuits',
|
||||||
|
registry.Boolean(False, """Determines whether the bot will track QUITs for
|
||||||
|
the Seen database."""))
|
||||||
filename = os.path.join(conf.supybot.directories.data(), 'Seen.db')
|
filename = os.path.join(conf.supybot.directories.data(), 'Seen.db')
|
||||||
|
|
||||||
class Seen(callbacks.Privmsg):
|
class Seen(callbacks.Privmsg):
|
||||||
@ -99,6 +109,39 @@ class Seen(callbacks.Privmsg):
|
|||||||
self.db.close()
|
self.db.close()
|
||||||
callbacks.Privmsg.die(self)
|
callbacks.Privmsg.die(self)
|
||||||
|
|
||||||
|
def doJoin(self, irc, msg):
|
||||||
|
if self.registryValue('trackJoins'):
|
||||||
|
joinMsg = ircmsgs.prettyPrint(msg)
|
||||||
|
channel = msg.args[0]
|
||||||
|
self.db.update(channel, msg.nick, joinMsg)
|
||||||
|
try:
|
||||||
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
|
self.db.update(channel, id, joinMsg)
|
||||||
|
except KeyError:
|
||||||
|
pass # Not in the database.
|
||||||
|
|
||||||
|
def doPart(self, irc, msg):
|
||||||
|
if self.registryValue('trackParts'):
|
||||||
|
partMsg = ircmsgs.prettyPrint(msg)
|
||||||
|
channel = msg.args[0]
|
||||||
|
self.db.update(channel, msg.nick, partMsg)
|
||||||
|
try:
|
||||||
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
|
self.db.update(channel, id, partMsg)
|
||||||
|
except KeyError:
|
||||||
|
pass # Not in the database
|
||||||
|
|
||||||
|
def doQuit(self, irc, msg):
|
||||||
|
if self.registryValue('trackQuits'):
|
||||||
|
quitMsg = ircmsgs.prettyPrint(msg)
|
||||||
|
channel = msg.args[0]
|
||||||
|
self.db.update(channel, msg.nick, quitMsg)
|
||||||
|
try:
|
||||||
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
|
self.db.update(channel, id, quitMsg)
|
||||||
|
except KeyError:
|
||||||
|
pass # Not in the database
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
said = ircmsgs.prettyPrint(msg)
|
said = ircmsgs.prettyPrint(msg)
|
||||||
|
@ -266,7 +266,7 @@ def prettyPrint(msg, addRecipients=False):
|
|||||||
quitmsg = ' (%s)' % msg.args[0]
|
quitmsg = ' (%s)' % msg.args[0]
|
||||||
else:
|
else:
|
||||||
quitmsg = ''
|
quitmsg = ''
|
||||||
s = '*** %s has quit IRC%s' % quitmsg
|
s = '*** %s has quit IRC%s' % (msg.nick, quitmsg)
|
||||||
elif msg.command == 'TOPIC':
|
elif msg.command == 'TOPIC':
|
||||||
s = '*** %s changes topic to %s' % (nickorprefix(), msg.args[1])
|
s = '*** %s changes topic to %s' % (nickorprefix(), msg.args[1])
|
||||||
return s
|
return s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user