Skip to content

Commit 60d7493

Browse files
author
Pietro Albini
committed
Fix GH-37 -- Broken /help command
This commit fixes a regression introduced in commit 99f24a0, which removed a private attribute of FrozenBot used by the default /help command. This commit reimplements that in order to restore the command.
1 parent 4b298d2 commit 60d7493

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

botogram/bot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,17 @@ def freeze(self):
188188
chains = components.merge_chains(self._main_component,
189189
*self._components)
190190

191+
# Get the list of commands for the bot
192+
commands = self._components[-1]._get_commands()
193+
for component in reversed(self._components[:-1]):
194+
commands.update(component._get_commands())
195+
commands.update(self._main_component._get_commands())
196+
191197
return frozenbot.FrozenBot(self.api, self.about, self.owner,
192198
self.hide_commands, self.before_help,
193199
self.after_help, self.process_backlog,
194200
self.lang, self.itself, self._commands_re,
195-
chains, self._scheduler,
201+
commands, chains, self._scheduler,
196202
self._main_component._component_id,
197203
self._bot_id, self._shared_memory)
198204

botogram/frozenbot.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class FrozenBot:
2222

2323
def __init__(self, api, about, owner, hide_commands, before_help,
2424
after_help, process_backlog, lang, itself, commands_re,
25-
chains, scheduler, main_component_id, bot_id,
25+
commands, chains, scheduler, main_component_id, bot_id,
2626
shared_memory):
2727
# This attribute should be added with the default setattr, because is
2828
# needed by the custom setattr
@@ -43,6 +43,7 @@ def __init__(self, api, about, owner, hide_commands, before_help,
4343
self._shared_memory = shared_memory
4444
self._scheduler = scheduler
4545
self._chains = chains
46+
self._commands = commands
4647

4748
# Setup the logger
4849
self.logger = logbook.Logger('botogram bot')
@@ -61,9 +62,9 @@ def __reduce__(self):
6162
args = (
6263
self.api, self.about, self.owner, self.hide_commands,
6364
self.before_help, self.after_help, self.process_backlog,
64-
self.lang, self.itself, self._commands_re, self._chains,
65-
self._scheduler, self._main_component_id, self._bot_id,
66-
self._shared_memory,
65+
self.lang, self.itself, self._commands_re, self._commands,
66+
self._chains, self._scheduler, self._main_component_id,
67+
self._bot_id, self._shared_memory,
6768
)
6869
return restore, args
6970

0 commit comments

Comments
 (0)