Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: DRY version #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from tululbot.commands import leli, quote, who, slang, hotline, hbd, kbbi, eid, xmas, kawin

from tululbot import VERSION


class TestLeliCommand:

Expand Down Expand Up @@ -110,11 +112,12 @@ def test_who(fake_message, mocker):
who(fake_message)

expected_text = (
'TululBot v1.11.2\n\n'
'TululBot v{}\n\n'
'Enhancing your tulul experience since 2015\n\n'
'Contribute on https://github.com/tulul/tululbot\n\n'
"We're hiring! Contact @iqbalmineraltown for details"
)
expected_text = expected_text.format(VERSION)
mock_reply_to.assert_called_once_with(fake_message, expected_text,
disable_web_page_preview=True)

Expand Down
3 changes: 3 additions & 0 deletions tululbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from tululbot import commands # noqa


VERSION = '1.11.2'


# Why do this? See https://core.telegram.org/bots/api#setwebhook
webhook_url_path = '/{}'.format(app.config['TELEGRAM_BOT_TOKEN'])
webhook_url_base = app.config['WEBHOOK_HOST']
Expand Down
5 changes: 3 additions & 2 deletions tululbot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tululbot.utils.quote import QuoteEngine
from tululbot.utils.slang import lookup_slang
from tululbot.utils.leli import search_on_google, search_on_wikipedia

from tululbot import VERSION

quote_engine = QuoteEngine()
HOTLINE_MESSAGE_ID = app.config['HOTLINE_MESSAGE_ID']
Expand Down Expand Up @@ -55,11 +55,12 @@ def quote(message):
def who(message):
app.logger.debug('Detected who command {!r}'.format(message.text))
about_text = (
'TululBot v1.11.2\n\n'
'TululBot v{}\n\n'
'Enhancing your tulul experience since 2015\n\n'
'Contribute on https://github.com/tulul/tululbot\n\n'
"We're hiring! Contact @iqbalmineraltown for details"
)
about_text = about_text.format(VERSION)
return bot.reply_to(message, about_text, disable_web_page_preview=True)


Expand Down