Skip to content

Commit

Permalink
Fixed gettext
Browse files Browse the repository at this point in the history
  • Loading branch information
djamg committed Dec 26, 2023
1 parent cdc5939 commit ccbe034
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
13 changes: 9 additions & 4 deletions boxoffice/messageclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
from . import app, rq
from baseframe import _


@rq.job('boxoffice')
def send_telegram_message(buyer_fullname, line_item_title):
with app.test_request_context():
message_text = _(f'{buyer_fullname} purchased {line_item_title}')
send_text = f'https://api.telegram.org/bot{app.config["TELEGRAM_BOT_TOKEN"]}/sendMessage'
message_text = _("{user} purchased {title}").format(
user=buyer_fullname, title=line_item_title
)
send_text = (
f'https://api.telegram.org/bot{app.config["TELEGRAM_APIKEY"]}/sendMessage'
)
params = {
'chat_id': app.config['TELEGRAM_CHAT_ID'],
'message_thread_id': app.config['TELEGRAM_MESSAGE_THREAD_ID'],
'chat_id': app.config['TELEGRAM_CHATID'],
'message_thread_id': app.config.get['TELEGRAM_THREADID'],
'text': message_text,
}
requests.post(send_text, data=params, timeout=30)
2 changes: 1 addition & 1 deletion boxoffice/views/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def payment(order):
invoice_no=order.invoice_no,
),
)
if app.config['TELEGRAM_BOT_TOKEN']:
if app.config['TELEGRAM_APIKEY'] and app.config['TELEGRAM_CHATID']:
send_telegram_message.queue(
buyer_fullname=order.buyer_fullname,
line_item_title=order.line_item.item.title,
Expand Down
7 changes: 4 additions & 3 deletions instance/settings-sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#: RQ settings
RQ_REDIS_URL = 'redis://localhost:6379/0'
RQ_SCHEDULER_INTERVAL = 1
TELEGRAM_BOT_TOKEN = ''
TELEGRAM_CHAT_ID = ''
TELEGRAM_MESSAGE_THREAD_ID = ''
#: Telegram settings
TELEGRAM_APIKEY = '' # nosec
TELEGRAM_CHATID = '' # nosec
TELEGRAM_THREADID = ''

0 comments on commit ccbe034

Please sign in to comment.