Implement support for modes and get WHO data on a loop
This commit is contained in:
parent
bc87ffddf7
commit
edea19222d
|
@ -1 +0,0 @@
|
||||||
{}
|
|
18
core/bot.py
18
core/bot.py
|
@ -1,6 +1,7 @@
|
||||||
from twisted.internet.protocol import ReconnectingClientFactory
|
from twisted.internet.protocol import ReconnectingClientFactory
|
||||||
from twisted.words.protocols.irc import IRCClient
|
from twisted.words.protocols.irc import IRCClient
|
||||||
from twisted.internet.defer import Deferred
|
from twisted.internet.defer import Deferred
|
||||||
|
from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
import modules.keyword as keyword
|
import modules.keyword as keyword
|
||||||
import modules.userinfo as userinfo
|
import modules.userinfo as userinfo
|
||||||
|
@ -139,6 +140,7 @@ class IRCBot(IRCClient):
|
||||||
n = self._who[channel][1]
|
n = self._who[channel][1]
|
||||||
n[nick] = [nick, user, host, server, status, realname]
|
n[nick] = [nick, user, host, server, status, realname]
|
||||||
count.event(self.name, "whoreply")
|
count.event(self.name, "whoreply")
|
||||||
|
monitor.event(self.name, channel, {"type": "who", "exact": nick+"!"+user+"@"+host, "nick": nick, "ident": user, "host": host, "realname": realname, "server": server, "status": status})
|
||||||
|
|
||||||
def irc_RPL_ENDOFWHO(self, prefix, params):
|
def irc_RPL_ENDOFWHO(self, prefix, params):
|
||||||
channel = params[1]
|
channel = params[1]
|
||||||
|
@ -152,7 +154,6 @@ class IRCBot(IRCClient):
|
||||||
def got_who(self, whoinfo):
|
def got_who(self, whoinfo):
|
||||||
userinfo.setWho(self.name, whoinfo[1])
|
userinfo.setWho(self.name, whoinfo[1])
|
||||||
|
|
||||||
|
|
||||||
#twisted sucks so i have to do this to actually get the user info
|
#twisted sucks so i have to do this to actually get the user info
|
||||||
def irc_JOIN(self, prefix, params):
|
def irc_JOIN(self, prefix, params):
|
||||||
"""
|
"""
|
||||||
|
@ -232,6 +233,9 @@ class IRCBot(IRCClient):
|
||||||
self.join(i)
|
self.join(i)
|
||||||
count.event(self.name, "signedon")
|
count.event(self.name, "signedon")
|
||||||
|
|
||||||
|
def getWho(self, channel):
|
||||||
|
self.who(channel).addCallback(self.got_who)
|
||||||
|
|
||||||
def joined(self, channel):
|
def joined(self, channel):
|
||||||
if not channel in self.channels:
|
if not channel in self.channels:
|
||||||
self.channels.append(channel)
|
self.channels.append(channel)
|
||||||
|
@ -241,6 +245,9 @@ class IRCBot(IRCClient):
|
||||||
for i in range(len(main.masterbuf)):
|
for i in range(len(main.masterbuf)):
|
||||||
self.msg(channel, main.masterbuf.pop(0))
|
self.msg(channel, main.masterbuf.pop(0))
|
||||||
main.saveConf("masterbuf")
|
main.saveConf("masterbuf")
|
||||||
|
lc = LoopingCall(self.getWho, channel)
|
||||||
|
self._getWho[channel] = lc
|
||||||
|
lc.start(60)
|
||||||
|
|
||||||
def left(self, channel, message):
|
def left(self, channel, message):
|
||||||
if channel in self.channels:
|
if channel in self.channels:
|
||||||
|
@ -248,10 +255,11 @@ class IRCBot(IRCClient):
|
||||||
keyword.actKeyword(self.nickname, channel, message, self.nickname, "SELFPART", self.name)
|
keyword.actKeyword(self.nickname, channel, message, self.nickname, "SELFPART", self.name)
|
||||||
count.event(self.name, "selfpart")
|
count.event(self.name, "selfpart")
|
||||||
monitor.event(self.name, channel, {"type": "part", "message": message})
|
monitor.event(self.name, channel, {"type": "part", "message": message})
|
||||||
|
lc = self._getWho[channel]
|
||||||
|
lc.stop()
|
||||||
|
|
||||||
def kickedFrom(self, channel, kicker, message):
|
def kickedFrom(self, channel, kicker, message):
|
||||||
nick, ident, host = self.parsen(kicker)
|
nick, ident, host = self.parsen(kicker)
|
||||||
print(kicker)
|
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
if channel in self.channels:
|
if channel in self.channels:
|
||||||
self.channels.remove(channel)
|
self.channels.remove(channel)
|
||||||
|
@ -307,8 +315,10 @@ class IRCBot(IRCClient):
|
||||||
nick, ident, host = self.parsen(user)
|
nick, ident, host = self.parsen(user)
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.name, nick, ident, host)
|
||||||
count.event(self.name, "mode")
|
count.event(self.name, "mode")
|
||||||
print("%s // %s // %s" % (toset, modes, args))
|
argList = list(args)
|
||||||
#monitor.event(self.name, channel, {"type": "topic", "exact": user, "nick": nick, "ident": ident, "host": host, "message": newTopic})
|
modeList = [i for i in modes]
|
||||||
|
for a, m in zip(argList, modeList):
|
||||||
|
monitor.event(self.name, channel, {"type": "mode", "exact": user, "nick": nick, "ident": ident, "host": host, "modes": m, "modeargs": a})
|
||||||
|
|
||||||
class IRCBotFactory(ReconnectingClientFactory):
|
class IRCBotFactory(ReconnectingClientFactory):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
|
|
Loading…
Reference in New Issue