mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 15:26:37 +00:00
pngbot.py:IrcMiRCARTBot.clientChannelOps: added to track nicks authorised to use `!pngbot'.
pngbot.py:IrcMiRCARTBot.dispatch(): sync clientChannelOps w/ 353 (RPL_NAMREPLY) and (channel) MODE messages.
This commit is contained in:
parent
75e8e5fdf0
commit
993e986ec0
35
pngbot.py
35
pngbot.py
@ -86,7 +86,7 @@ class IrcBot:
|
|||||||
|
|
||||||
class IrcMiRCARTBot(IrcBot):
|
class IrcMiRCARTBot(IrcBot):
|
||||||
"""IRC<->MiRCART bot"""
|
"""IRC<->MiRCART bot"""
|
||||||
clientLastMessage = clientChannel = None
|
clientChannelLastMessage = clientChannelOps = clientChannel = None
|
||||||
|
|
||||||
# {{{ connect(): Connect to server and (re)initialise
|
# {{{ connect(): Connect to server and (re)initialise
|
||||||
def connect(self):
|
def connect(self):
|
||||||
@ -94,7 +94,7 @@ class IrcMiRCARTBot(IrcBot):
|
|||||||
super().connect()
|
super().connect()
|
||||||
print("Connected to {}:{}.".format(self.serverHname, self.serverPort))
|
print("Connected to {}:{}.".format(self.serverHname, self.serverPort))
|
||||||
print("Registering on {}:{} as {}, {}, {}...".format(self.serverHname, self.serverPort, self.clientNick, self.clientIdent, self.clientGecos))
|
print("Registering on {}:{} as {}, {}, {}...".format(self.serverHname, self.serverPort, self.clientNick, self.clientIdent, self.clientGecos))
|
||||||
self.clientLastMessage = 0
|
self.clientLastMessage = 0; self.clientChannelOps = [];
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ dispatch(): Read, parse, and dispatch single line from server
|
# {{{ dispatch(): Read, parse, and dispatch single line from server
|
||||||
def dispatch(self):
|
def dispatch(self):
|
||||||
@ -107,6 +107,37 @@ class IrcMiRCARTBot(IrcBot):
|
|||||||
print("Registered on {}:{} as {}, {}, {}.".format(self.serverHname, self.serverPort, self.clientNick, self.clientIdent, self.clientGecos))
|
print("Registered on {}:{} as {}, {}, {}.".format(self.serverHname, self.serverPort, self.clientNick, self.clientIdent, self.clientGecos))
|
||||||
print("Joining {} on {}:{}...".format(self.clientChannel, self.serverHname, self.serverPort))
|
print("Joining {} on {}:{}...".format(self.clientChannel, self.serverHname, self.serverPort))
|
||||||
self.sendline("JOIN", self.clientChannel)
|
self.sendline("JOIN", self.clientChannel)
|
||||||
|
elif serverMessage[1] == "353" \
|
||||||
|
and serverMessage[4].lower() == self.clientChannel.lower():
|
||||||
|
for channelNickSpec in serverMessage[5].split(" "):
|
||||||
|
if channelNickSpec[0] == "@" \
|
||||||
|
and len(channelNickSpec[1:]):
|
||||||
|
self.clientChannelOps.append(channelNickSpec[1:])
|
||||||
|
print("Authorising {} on {}".format(channelNickSpec[1:], serverMessage[2]))
|
||||||
|
elif serverMessage[1] == "MODE" \
|
||||||
|
and serverMessage[2].lower() == self.clientChannel.lower():
|
||||||
|
channelModeType = "+"; channelModeArg = 4;
|
||||||
|
channelAuthAdd = ""; channelAuthDel = "";
|
||||||
|
for channelModeChar in serverMessage[3]:
|
||||||
|
if channelModeChar[0] == "-":
|
||||||
|
channelModeType = "-"
|
||||||
|
elif channelModeChar[0] == "+":
|
||||||
|
channelModeType = "+"
|
||||||
|
elif channelModeChar[0].isalpha():
|
||||||
|
if channelModeChar[0] == "o":
|
||||||
|
if channelModeType == "+":
|
||||||
|
channelAuthAdd = serverMessage[channelModeArg]; channelAuthDel = "";
|
||||||
|
elif channelModeType == "-":
|
||||||
|
channelAuthAdd = ""; channelAuthDel = serverMessage[channelModeArg];
|
||||||
|
channelModeArg += 1
|
||||||
|
if len(channelAuthAdd) \
|
||||||
|
and channelAuthAdd not in self.clientChannelOps:
|
||||||
|
print("Authorising {} on {}".format(channelAuthAdd, serverMessage[2]))
|
||||||
|
self.clientChannelOps.append(channelAuthAdd)
|
||||||
|
elif len(channelAuthDel) \
|
||||||
|
and channelAuthDel in self.clientChannelOps:
|
||||||
|
print("Deauthorising {} on {}".format(channelAuthDel, serverMessage[2]))
|
||||||
|
self.clientChannelOps.remove(channelAuthDel)
|
||||||
elif serverMessage[1] == "PING":
|
elif serverMessage[1] == "PING":
|
||||||
self.sendline("PONG", serverMessage[2])
|
self.sendline("PONG", serverMessage[2])
|
||||||
elif serverMessage[1] == "PRIVMSG" \
|
elif serverMessage[1] == "PRIVMSG" \
|
||||||
|
Loading…
Reference in New Issue
Block a user