Skip to content

Commit 6bbc17e

Browse files
committed
Document feature and fix code style
1 parent b01a0e7 commit 6bbc17e

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

botogram/frozenbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __reduce__(self):
8383
self.validate_callback_signatures, self.process_backlog, self.lang,
8484
self.itself, self._commands_re, self._commands, self._chains,
8585
self._scheduler, self._main_component_id, self._bot_id,
86-
self._shared_memory, self._update_processors, self.override_i18n
86+
self._shared_memory, self._update_processors, self.override_i18n,
8787
)
8888
return restore, args
8989

docs/api/bot.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ components.
8383
The :py:class:`botogram.User` representation of the bot's user account.
8484
From this you can access its id, username and more.
8585

86+
.. py:attribute:: override_i18n
87+
88+
A dictionary that allows to override default i18n messages by associating
89+
the default ``msgid`` string of a message with its alternative.
90+
91+
.. versionadded:: 0.4.1
92+
8693
.. py:decoratormethod:: before_processing
8794
8895
Functions decorated with this decorator will be called before an update

docs/changelog/0.4.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ botogram 0.4.1
1616

1717
Release description not yet written.
1818

19+
New features
20+
------------
21+
22+
* Added ability to override default i18n messages
23+
24+
* New attribute :py:attr:`botogram.Bot.override_i18n`
25+
1926
Bug fixes
2027
---------
2128

tests/test_bot.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_bot_creation(api, mock_req):
3131
# Mock the getMe request
3232
mock_req({
3333
"getMe": {"ok": True, "result": {"id": 1, "first_name": "test",
34-
"username": "test_bot"}},
34+
"username": "test_bot"}},
3535
})
3636

3737
bot1 = botogram.bot.create(conftest.API_KEY)
@@ -78,16 +78,20 @@ def test_bot_freeze(bot):
7878

7979
assert bot == frozen
8080

81+
8182
def test_i18n_override(bot):
82-
default_message = botogram.utils.get_language("en").gettext("Use /help to get a list of all the commands.")
83+
default_message = botogram.utils.get_language("en") \
84+
.gettext("Use /help to get a list of all the commands.")
8385
override_message = "git gud"
8486

8587
bot.override_i18n = {
8688
default_message: override_message
8789
}
8890

89-
assert bot._("Use /help to get a list of all the commands.") == "git gud"
91+
assert bot._("Use /help to get a list of all the commands.") \
92+
== override_message
9093

9194
bot.override_i18n = {}
9295

93-
assert bot._("Use /help to get a list of all the commands.") == default_message
96+
assert bot._("Use /help to get a list of all the commands.") \
97+
== default_message

0 commit comments

Comments
 (0)