Add more detail in IRC docstrings
This commit is contained in:
parent
661582a97d
commit
7c8f77df40
|
@ -12,6 +12,11 @@ from settings import settings
|
|||
|
||||
class IRCBot(irc.IRCClient):
|
||||
def __init__(self, log):
|
||||
"""
|
||||
Initialise IRC bot.
|
||||
:param log: logger instance
|
||||
:type log: Logger
|
||||
"""
|
||||
self.log = log
|
||||
self.nickname = settings.IRC.Nick
|
||||
self.password = settings.IRC.Pass
|
||||
|
@ -41,6 +46,10 @@ class IRCBot(irc.IRCClient):
|
|||
:param host: user's hostname
|
||||
:param channel: channel the message was received on
|
||||
:param msg: the message
|
||||
:type user: string
|
||||
:type host: string
|
||||
:type channel: string
|
||||
:type msg: string
|
||||
"""
|
||||
spl = msg.split()
|
||||
# nick = user.split("!")[0]
|
||||
|
@ -106,6 +115,7 @@ class IRCBot(irc.IRCClient):
|
|||
Setup the Agora LoopingCall to get trades.
|
||||
This is here to ensure the IRC client is initialised enough to send the trades.
|
||||
:param channel: channel we joined
|
||||
:type channel: string
|
||||
"""
|
||||
self.agora.setup_loop()
|
||||
self.log.info("Joined channel %s" % (channel))
|
||||
|
@ -117,6 +127,9 @@ class IRCBot(irc.IRCClient):
|
|||
:param user: full user string with host
|
||||
:param channel: channel the message was received on
|
||||
:param msg: the message
|
||||
:type user: string
|
||||
:type channel: string
|
||||
:type msg: string
|
||||
"""
|
||||
nick = user.split("!")[0]
|
||||
|
||||
|
@ -140,6 +153,9 @@ class IRCBot(irc.IRCClient):
|
|||
:param user: full user string with host
|
||||
:param channel: channel the notice was received on
|
||||
:param msg: the message
|
||||
:type user: string
|
||||
:type channel: string
|
||||
:type msg: string
|
||||
"""
|
||||
nick = user.split("!")[0]
|
||||
if channel == self.nickname:
|
||||
|
@ -170,8 +186,10 @@ class IRCBotFactory(protocol.ClientFactory):
|
|||
Called when connection to IRC server lost. Reconnect.
|
||||
:param connector: connector object
|
||||
:param reason: reason connection lost
|
||||
:type connector: object
|
||||
:type reason: string
|
||||
"""
|
||||
self.log.error("Lost connection (%s), reconnecting" % (reason))
|
||||
self.log.error("Lost connection: {reason}, reconnecting", reason=reason)
|
||||
connector.connect()
|
||||
|
||||
def clientConnectionFailed(self, connector, reason):
|
||||
|
@ -179,12 +197,19 @@ class IRCBotFactory(protocol.ClientFactory):
|
|||
Called when connection to IRC server failed. Reconnect.
|
||||
:param connector: connector object
|
||||
:param reason: reason connection failed
|
||||
:type connector: object
|
||||
:type reason: string
|
||||
"""
|
||||
self.log.error("Could not connect: %s" % (reason))
|
||||
self.log.error("Could not connect: {reason}", reason=reason)
|
||||
connector.connect()
|
||||
|
||||
|
||||
def bot():
|
||||
"""
|
||||
Load the certificates, start the Bot Factory and connect it to the IRC server.
|
||||
:return: Factory instance
|
||||
:rtype: Factory
|
||||
"""
|
||||
# Load the certificates
|
||||
context = ssl.DefaultOpenSSLContextFactory(settings.IRC.Cert, settings.IRC.Cert)
|
||||
# Define the factory instance
|
||||
|
|
Loading…
Reference in New Issue