mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Small fixes
This commit is contained in:
parent
cac86d1c5f
commit
1aea02822e
2 changed files with 18 additions and 8 deletions
|
@ -12,6 +12,8 @@ def safely_format_string(string, **kwargs):
|
|||
|
||||
# Generic telegram errors
|
||||
class TELEGRAM:
|
||||
BOT_STARTED = "✅ Hai autorizzato il bot ad inviarti messaggi privati."
|
||||
|
||||
class ERRORS:
|
||||
CRITICAL_ERROR = "☢ <b>ERRORE CRITICO!</b>\nIl bot ha ignorato il comando.\nUna segnalazione di errore è stata automaticamente mandata a @Steffo.\n\nDettagli dell'errore:\n<pre>{exc_info}</pre>"
|
||||
TELEGRAM_NOT_LINKED = "⚠ Il tuo account Telegram non è registrato a Royalnet! Registrati con `/register@royalgamesbot <nomeutenteryg>`."
|
||||
|
@ -76,6 +78,6 @@ class MATCHMAKING:
|
|||
|
||||
|
||||
# Diario search
|
||||
class DIARIO_SEARCH:
|
||||
class DIARIOSEARCH:
|
||||
class ERRORS:
|
||||
INVALID_SYNTAX = "⚠ Non hai specificato un termine da cercare!\nSintassi: <pre>/search {termine}</pre>"
|
|
@ -10,7 +10,7 @@ from sqlalchemy.sql import text
|
|||
from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
# noinspection PyPackageRequirements
|
||||
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
|
||||
from telegram.error import TimedOut, Unauthorized
|
||||
from telegram.error import TimedOut, Unauthorized, BadRequest
|
||||
import dice
|
||||
import sys
|
||||
import os
|
||||
|
@ -303,7 +303,7 @@ def cmd_cerca(bot: Bot, update: Update):
|
|||
try:
|
||||
queryText = update.message.text.split(" ", 1)[1]
|
||||
except IndexError:
|
||||
bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX))
|
||||
bot.send_message(update.message.chat.id, s(strings.DIARIOSEARCH.ERRORS.INVALID_SYNTAX))
|
||||
return
|
||||
queryText = queryText.replace('%', '\\%').replace('_', '\\_')
|
||||
entries = session.query(db.Diario).filter(text(f"text ~* '(?:[^\w\d]+{queryText}[^\w\d]+|^{queryText}[^\w\d]+|^{queryText}$|[^\w\d]+{queryText}$)'")).order_by(db.Diario.id.desc()).all()
|
||||
|
@ -492,11 +492,14 @@ def on_callback_query(bot: Bot, update: Update):
|
|||
for key in strings.MATCHMAKING.BUTTONS])
|
||||
else:
|
||||
inline_keyboard = None
|
||||
bot.edit_message_text(message_id=update.callback_query.message.message_id,
|
||||
chat_id=config["Telegram"]["announcement_group"],
|
||||
text=match.generate_text(session),
|
||||
reply_markup=inline_keyboard,
|
||||
parse_mode="HTML")
|
||||
try:
|
||||
bot.edit_message_text(message_id=update.callback_query.message.message_id,
|
||||
chat_id=config["Telegram"]["announcement_group"],
|
||||
text=match.generate_text(session),
|
||||
reply_markup=inline_keyboard,
|
||||
parse_mode="HTML")
|
||||
except BadRequest:
|
||||
pass
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
|
@ -732,6 +735,11 @@ def cmd_roll(bot: Bot, update: Update):
|
|||
bot.send_message(update.message.chat.id, f"🎲 {result}")
|
||||
|
||||
|
||||
@catch_and_report
|
||||
def cmd_start(bot: Bot, update: Update):
|
||||
bot.send_message(update.message.chat.id, s(strings.TELEGRAM.BOT_STARTED))
|
||||
|
||||
|
||||
def process(arg_discord_connection):
|
||||
if arg_discord_connection is not None:
|
||||
global discord_connection
|
||||
|
|
Loading…
Reference in a new issue