Refer to client nick as "nick", not "name"
This commit is contained in:
parent
ef2d9eba50
commit
a4b9e016b0
1 changed files with 9 additions and 9 deletions
|
|
@ -31,9 +31,9 @@ class BotManager:
|
||||||
self.bot_id_counter = 0 # no two bots can have the same id
|
self.bot_id_counter = 0 # no two bots can have the same id
|
||||||
self.bots = {} # each bot has an unique id
|
self.bots = {} # each bot has an unique id
|
||||||
|
|
||||||
def create(self, name, roomname, pw=None, creator=None, create_room=None, create_time=None):
|
def create(self, nick, roomname, pw=None, creator=None, create_room=None, create_time=None):
|
||||||
"""
|
"""
|
||||||
create(name, roomname, pw, creator, create_room, create_time) -> bot
|
create(nick, roomname, pw, creator, create_room, create_time) -> bot
|
||||||
|
|
||||||
Create a bot of type self.bot_class.
|
Create a bot of type self.bot_class.
|
||||||
Starts the bot and returns it.
|
Starts the bot and returns it.
|
||||||
|
|
@ -48,13 +48,13 @@ class BotManager:
|
||||||
if create_time is None:
|
if create_time is None:
|
||||||
create_time = time.time()
|
create_time = time.time()
|
||||||
|
|
||||||
bot = self.bot_class(name, roomname, pw=pw, creator=creator, create_room=create_room,
|
bot = self.bot_class(nick, roomname, pw=pw, creator=creator, create_room=create_room,
|
||||||
create_time=create_time, manager=self)
|
create_time=create_time, manager=self)
|
||||||
|
|
||||||
self.bots[bot_id] = bot
|
self.bots[bot_id] = bot
|
||||||
bot.launch()
|
bot.launch()
|
||||||
|
|
||||||
logger.info("Created {} - {} in room {}".format(bot_id, name, roomname))
|
logger.info("Created {} - {} in room {}".format(bot_id, nick, roomname))
|
||||||
return bot
|
return bot
|
||||||
|
|
||||||
def remove(self, bot_id):
|
def remove(self, bot_id):
|
||||||
|
|
@ -68,13 +68,13 @@ class BotManager:
|
||||||
if not bot: return
|
if not bot: return
|
||||||
|
|
||||||
# for logging purposes
|
# for logging purposes
|
||||||
name = bot.get_name()
|
nick = bot.get_nick()
|
||||||
roomname = bot.get_roomname()
|
roomname = bot.get_roomname()
|
||||||
|
|
||||||
bot.stop()
|
bot.stop()
|
||||||
del self.bots[bot_id]
|
del self.bots[bot_id]
|
||||||
|
|
||||||
logger.info("Removed {} - {} in room {}".format(bot_id, name, roomname))
|
logger.info("Removed {} - {} in room {}".format(bot_id, nick, roomname))
|
||||||
|
|
||||||
def get(self, bot_id):
|
def get(self, bot_id):
|
||||||
"""
|
"""
|
||||||
|
|
@ -109,7 +109,7 @@ class BotManager:
|
||||||
l = []
|
l = []
|
||||||
|
|
||||||
for bot_id, bot in sorted(self.bots.items()):
|
for bot_id, bot in sorted(self.bots.items()):
|
||||||
if bot.get_roomname() == roomname and mention == Mention(bot.get_name()):
|
if bot.get_roomname() == roomname and mention == Mention(bot.get_nick()):
|
||||||
l.append(bot_id)
|
l.append(bot_id)
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
@ -126,7 +126,7 @@ class BotManager:
|
||||||
bots = []
|
bots = []
|
||||||
for bot in self.bots.values():
|
for bot in self.bots.values():
|
||||||
bots.append({
|
bots.append({
|
||||||
"name": bot.get_name(),
|
"nick": bot.get_nick(),
|
||||||
"room": bot.get_roomname(),
|
"room": bot.get_roomname(),
|
||||||
"pw": bot.get_roompw(),
|
"pw": bot.get_roompw(),
|
||||||
"creator": bot.get_creator(),
|
"creator": bot.get_creator(),
|
||||||
|
|
@ -164,7 +164,7 @@ class BotManager:
|
||||||
logger.debug("Bot info: {}".format(bots))
|
logger.debug("Bot info: {}".format(bots))
|
||||||
for bot_info in bots:
|
for bot_info in bots:
|
||||||
try:
|
try:
|
||||||
self.create(bot_info["name"], bot_info["room"], bot_info["pw"],
|
self.create(bot_info["nick"], bot_info["room"], bot_info["pw"],
|
||||||
bot_info["creator"], bot_info["create_room"],
|
bot_info["creator"], bot_info["create_room"],
|
||||||
bot_info["create_time"]).load(bot_info["data"])
|
bot_info["create_time"]).load(bot_info["data"])
|
||||||
except CreateBotException as err:
|
except CreateBotException as err:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue