mirror of https://github.com/str4d/RelayBot.git
Add topic sync.
This commit is contained in:
parent
d72f0b542d
commit
9f8a6254f9
|
@ -11,6 +11,7 @@ username=unit22
|
||||||
realname=Bender Bending Rodríguez
|
realname=Bender Bending Rodríguez
|
||||||
heartbeat=90
|
heartbeat=90
|
||||||
nickcolor=True
|
nickcolor=True
|
||||||
|
synctopic=True
|
||||||
|
|
||||||
[Freenode]
|
[Freenode]
|
||||||
host=irc.freenode.net
|
host=irc.freenode.net
|
||||||
|
|
14
relaybot.py
14
relaybot.py
|
@ -38,7 +38,7 @@ def main():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
for option in [ "timeout", "host", "port", "nick", "channel", "heartbeat", "password", "username", "realname", "mode", "ssl", "fingerprint", "nickcolor" ]:
|
for option in [ "timeout", "host", "port", "nick", "channel", "heartbeat", "password", "username", "realname", "mode", "ssl", "fingerprint", "nickcolor", "synctopic" ]:
|
||||||
options[option] = get(option)
|
options[option] = get(option)
|
||||||
|
|
||||||
mode = get("mode")
|
mode = get("mode")
|
||||||
|
@ -208,6 +208,7 @@ class IRCRelayer(irc.IRCClient):
|
||||||
self.realname = config['realname']
|
self.realname = config['realname']
|
||||||
self.mode = config['mode']
|
self.mode = config['mode']
|
||||||
self.nickcolor = config['nickcolor']
|
self.nickcolor = config['nickcolor']
|
||||||
|
self.synctopic = config['synctopic']
|
||||||
log.msg("IRC Relay created. Name: %s | Host: %s | Channel: %s"%(self.nickname, self.network, self.channel))
|
log.msg("IRC Relay created. Name: %s | Host: %s | Channel: %s"%(self.nickname, self.network, self.channel))
|
||||||
# IRC RFC: https://tools.ietf.org/html/rfc2812#page-4
|
# IRC RFC: https://tools.ietf.org/html/rfc2812#page-4
|
||||||
if len(self.nickname) > 9:
|
if len(self.nickname) > 9:
|
||||||
|
@ -251,10 +252,19 @@ class IRCRelayer(irc.IRCClient):
|
||||||
log.msg("Kicked by %s. Message \"%s\""%(kicker, message))
|
log.msg("Kicked by %s. Message \"%s\""%(kicker, message))
|
||||||
communicator.unregister(self)
|
communicator.unregister(self)
|
||||||
|
|
||||||
def action(self, user, channel, data):
|
def action(self, user, channel, message):
|
||||||
if self.mode != "RelayByCommand":
|
if self.mode != "RelayByCommand":
|
||||||
self.relay(":%s PRIVMSG %s :%s %s"%(user, channel, self.formatNick(user), message))
|
self.relay(":%s PRIVMSG %s :%s %s"%(user, channel, self.formatNick(user), message))
|
||||||
|
|
||||||
|
def topicUpdated(self, user, channel, newTopic):
|
||||||
|
if self.mode != "RelayByCommand":
|
||||||
|
self.topic(user, channel, newTopic)
|
||||||
|
|
||||||
|
def topic(self, user, channel, newTopic):
|
||||||
|
if self.synctopic != "True":
|
||||||
|
if self.mode != "RelayByCommand":
|
||||||
|
self.relay(":%s TOPIC %s :%s" %(user, channel, newTopic))
|
||||||
|
|
||||||
class RelayFactory(ReconnectingClientFactory):
|
class RelayFactory(ReconnectingClientFactory):
|
||||||
protocol = IRCRelayer
|
protocol = IRCRelayer
|
||||||
#Log information which includes reconnection status.
|
#Log information which includes reconnection status.
|
||||||
|
|
Loading…
Reference in New Issue