Add topic sync.

This commit is contained in:
Merdal Kaymaz 2015-02-04 21:11:04 +01:00
parent d72f0b542d
commit 9f8a6254f9
2 changed files with 13 additions and 2 deletions

View File

@ -11,6 +11,7 @@ username=unit22
realname=Bender Bending Rodríguez
heartbeat=90
nickcolor=True
synctopic=True
[Freenode]
host=irc.freenode.net

View File

@ -38,7 +38,7 @@ def main():
return None
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)
mode = get("mode")
@ -208,6 +208,7 @@ class IRCRelayer(irc.IRCClient):
self.realname = config['realname']
self.mode = config['mode']
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))
# IRC RFC: https://tools.ietf.org/html/rfc2812#page-4
if len(self.nickname) > 9:
@ -251,10 +252,19 @@ class IRCRelayer(irc.IRCClient):
log.msg("Kicked by %s. Message \"%s\""%(kicker, message))
communicator.unregister(self)
def action(self, user, channel, data):
def action(self, user, channel, message):
if self.mode != "RelayByCommand":
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):
protocol = IRCRelayer
#Log information which includes reconnection status.