Indent fixes to address #1258
PEP 8 whitespace and docstring edits, also
This commit is contained in:
parent
62bd9fb4ab
commit
63c7ea3ab7
1 changed files with 17 additions and 14 deletions
|
|
@ -81,8 +81,10 @@ class BotStarter(DefaultScript):
|
||||||
"""
|
"""
|
||||||
self.db.started = False
|
self.db.started = False
|
||||||
|
|
||||||
|
#
|
||||||
# Bot base class
|
# Bot base class
|
||||||
|
|
||||||
|
|
||||||
class Bot(DefaultPlayer):
|
class Bot(DefaultPlayer):
|
||||||
"""
|
"""
|
||||||
A Bot will start itself when the server starts (it will generally
|
A Bot will start itself when the server starts (it will generally
|
||||||
|
|
@ -196,9 +198,9 @@ class IRCBot(Bot):
|
||||||
|
|
||||||
# instruct the server and portal to create a new session with
|
# instruct the server and portal to create a new session with
|
||||||
# the stored configuration
|
# the stored configuration
|
||||||
configdict = {"uid":self.dbid,
|
configdict = {"uid": self.dbid,
|
||||||
"botname": self.db.irc_botname,
|
"botname": self.db.irc_botname,
|
||||||
"channel": self.db.irc_channel ,
|
"channel": self.db.irc_channel,
|
||||||
"network": self.db.irc_network,
|
"network": self.db.irc_network,
|
||||||
"port": self.db.irc_port,
|
"port": self.db.irc_port,
|
||||||
"ssl": self.db.irc_ssl}
|
"ssl": self.db.irc_ssl}
|
||||||
|
|
@ -325,31 +327,32 @@ class IRCBot(Bot):
|
||||||
whos.append("%s (%s/%s)" % (utils.crop("|w%s|n" % player.name, width=25),
|
whos.append("%s (%s/%s)" % (utils.crop("|w%s|n" % player.name, width=25),
|
||||||
utils.time_format(delta_conn, 0),
|
utils.time_format(delta_conn, 0),
|
||||||
utils.time_format(delta_cmd, 1)))
|
utils.time_format(delta_cmd, 1)))
|
||||||
text = "Who list (online/idle): %s" % ", ".join(sorted(whos, key=lambda w:w.lower()))
|
text = "Who list (online/idle): %s" % ", ".join(sorted(whos, key=lambda w: w.lower()))
|
||||||
elif txt.lower().startswith("about"):
|
elif txt.lower().startswith("about"):
|
||||||
# some bot info
|
# some bot info
|
||||||
text = "This is an Evennia IRC bot connecting from '%s'." % settings.SERVERNAME
|
text = "This is an Evennia IRC bot connecting from '%s'." % settings.SERVERNAME
|
||||||
else:
|
else:
|
||||||
text = "I understand 'who' and 'about'."
|
text = "I understand 'who' and 'about'."
|
||||||
super(IRCBot, self).msg(privmsg=((text,), {"user":user}))
|
super(IRCBot, self).msg(privmsg=((text,), {"user": user}))
|
||||||
else:
|
else:
|
||||||
# something to send to the main channel
|
# something to send to the main channel
|
||||||
if kwargs["type"] == "action":
|
if kwargs["type"] == "action":
|
||||||
# An action (irc pose)
|
# An action (irc pose)
|
||||||
text = "%s@%s %s" % (kwargs["user"], kwargs["channel"], txt)
|
text = "%s@%s %s" % (kwargs["user"], kwargs["channel"], txt)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# msg - A normal channel message
|
# msg - A normal channel message
|
||||||
text = "%s@%s: %s" % (kwargs["user"], kwargs["channel"], txt)
|
text = "%s@%s: %s" % (kwargs["user"], kwargs["channel"], txt)
|
||||||
|
|
||||||
if not self.ndb.ev_channel and self.db.ev_channel:
|
if not self.ndb.ev_channel and self.db.ev_channel:
|
||||||
# cache channel lookup
|
# cache channel lookup
|
||||||
self.ndb.ev_channel = self.db.ev_channel
|
self.ndb.ev_channel = self.db.ev_channel
|
||||||
if self.ndb.ev_channel:
|
if self.ndb.ev_channel:
|
||||||
self.ndb.ev_channel.msg(text, senders=self.id)
|
self.ndb.ev_channel.msg(text, senders=self.id)
|
||||||
|
|
||||||
|
#
|
||||||
# RSS
|
# RSS
|
||||||
|
|
||||||
|
|
||||||
class RSSBot(Bot):
|
class RSSBot(Bot):
|
||||||
"""
|
"""
|
||||||
An RSS relayer. The RSS protocol itself runs a ticker to update
|
An RSS relayer. The RSS protocol itself runs a ticker to update
|
||||||
|
|
@ -363,7 +366,7 @@ class RSSBot(Bot):
|
||||||
Args:
|
Args:
|
||||||
ev_channel (str): Key of the Evennia channel to connect to.
|
ev_channel (str): Key of the Evennia channel to connect to.
|
||||||
rss_url (str): Full URL to the RSS feed to subscribe to.
|
rss_url (str): Full URL to the RSS feed to subscribe to.
|
||||||
rss_update_rate (int): How often for the feedreader to update.
|
rss_rate (int): How often for the feedreader to update.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
RuntimeError: If `ev_channel` does not exist.
|
RuntimeError: If `ev_channel` does not exist.
|
||||||
|
|
@ -371,8 +374,8 @@ class RSSBot(Bot):
|
||||||
"""
|
"""
|
||||||
if not _RSS_EMABLED:
|
if not _RSS_EMABLED:
|
||||||
# The bot was created, then RSS was turned off. Delete ourselves.
|
# The bot was created, then RSS was turned off. Delete ourselves.
|
||||||
self.delete()
|
self.delete()
|
||||||
return
|
return
|
||||||
|
|
||||||
global _SESSIONS
|
global _SESSIONS
|
||||||
if not _SESSIONS:
|
if not _SESSIONS:
|
||||||
|
|
@ -404,7 +407,7 @@ class RSSBot(Bot):
|
||||||
Args:
|
Args:
|
||||||
session (Session, optional): Session responsible for this
|
session (Session, optional): Session responsible for this
|
||||||
command.
|
command.
|
||||||
text (str, optional): Command string.
|
txt (str, optional): Command string.
|
||||||
kwargs (dict, optional): Additional Information passed from bot.
|
kwargs (dict, optional): Additional Information passed from bot.
|
||||||
Not used by the RSSbot by default.
|
Not used by the RSSbot by default.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue