mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-08 00:24:00 +02:00
Update docstrings
This commit is contained in:
parent
48ec923d17
commit
1394679dce
1 changed files with 14 additions and 0 deletions
|
@ -213,10 +213,12 @@ class IrcThread(threading.Thread):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def setConnected(self, connected):
|
def setConnected(self, connected):
|
||||||
|
""" Set the connection status (result) of last connection attempt"""
|
||||||
with self.threadLock:
|
with self.threadLock:
|
||||||
self.connected = connected
|
self.connected = connected
|
||||||
|
|
||||||
def getConnected(self):
|
def getConnected(self):
|
||||||
|
""" Return whether we are connected to IRC"""
|
||||||
with self.threadLock:
|
with self.threadLock:
|
||||||
return self.connected
|
return self.connected
|
||||||
|
|
||||||
|
@ -250,15 +252,21 @@ class IrcThread(threading.Thread):
|
||||||
self.connection.topic(channel)
|
self.connection.topic(channel)
|
||||||
|
|
||||||
def setTopic(self, channel, newTopic):
|
def setTopic(self, channel, newTopic):
|
||||||
|
""" Change topic for a channel. If not connected yet, won't queue the topic change request. """
|
||||||
with self.threadLock:
|
with self.threadLock:
|
||||||
return self.connection.topic(channel, newTopic)
|
return self.connection.topic(channel, newTopic)
|
||||||
|
|
||||||
def onConnect(self, connection, event):
|
def onConnect(self, connection, event):
|
||||||
|
""" Callback when IRC server is connected. Joins channels specified in config. """
|
||||||
logging.info("Joining channels: %s", self.channels)
|
logging.info("Joining channels: %s", self.channels)
|
||||||
for channel in self.channels:
|
for channel in self.channels:
|
||||||
connection.join(channel)
|
connection.join(channel)
|
||||||
|
|
||||||
def onDisconnect(self, connection, event):
|
def onDisconnect(self, connection, event):
|
||||||
|
"""
|
||||||
|
Disconnect handler that attempts reconnect.
|
||||||
|
TODO: investigate reconnect and channel re-join behavior upon netsplits.
|
||||||
|
"""
|
||||||
logging.info("Disconnected, waiting for %s seconds before reconnect", self.reconnectDelay)
|
logging.info("Disconnected, waiting for %s seconds before reconnect", self.reconnectDelay)
|
||||||
self.setConnected(False)
|
self.setConnected(False)
|
||||||
time.sleep(self.reconnectDelay)
|
time.sleep(self.reconnectDelay)
|
||||||
|
@ -267,6 +275,7 @@ class IrcThread(threading.Thread):
|
||||||
self.setConnected(reconnected)
|
self.setConnected(reconnected)
|
||||||
|
|
||||||
def onJoin(self, connection, event):
|
def onJoin(self, connection, event):
|
||||||
|
""" Callback when channel is joined """
|
||||||
nick, _ = event.source.split("!", 2)
|
nick, _ = event.source.split("!", 2)
|
||||||
if (nick == config.ircNick):
|
if (nick == config.ircNick):
|
||||||
logging.info("Joined channel, event: %s", event)
|
logging.info("Joined channel, event: %s", event)
|
||||||
|
@ -274,6 +283,10 @@ class IrcThread(threading.Thread):
|
||||||
#connection.privmsg(self.channels[0], "brmbot-libfc starting")
|
#connection.privmsg(self.channels[0], "brmbot-libfc starting")
|
||||||
|
|
||||||
def onTopic(self, connection, event):
|
def onTopic(self, connection, event):
|
||||||
|
"""
|
||||||
|
Callback when we see IRC topic message. It can be caused by us or other users in channel.
|
||||||
|
Check if there was request to change topic and update it.
|
||||||
|
"""
|
||||||
global channelPrefixMap
|
global channelPrefixMap
|
||||||
channel = event.arguments[0]
|
channel = event.arguments[0]
|
||||||
topic = event.arguments[1]
|
topic = event.arguments[1]
|
||||||
|
@ -293,6 +306,7 @@ class IrcThread(threading.Thread):
|
||||||
del channelPrefixMap[channel] # remove request
|
del channelPrefixMap[channel] # remove request
|
||||||
|
|
||||||
def onNoTopic(self, connection, event):
|
def onNoTopic(self, connection, event):
|
||||||
|
""" Callback on empty topic. I couldn't trigger this, so it's untested. """
|
||||||
channel = event.arguments[0]
|
channel = event.arguments[0]
|
||||||
topic = event.arguments[1]
|
topic = event.arguments[1]
|
||||||
logging.info("No topic: channel %s, topic %s", channel, topic)
|
logging.info("No topic: channel %s, topic %s", channel, topic)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue