mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +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
|
# Generic telegram errors
|
||||||
class TELEGRAM:
|
class TELEGRAM:
|
||||||
|
BOT_STARTED = "✅ Hai autorizzato il bot ad inviarti messaggi privati."
|
||||||
|
|
||||||
class ERRORS:
|
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>"
|
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>`."
|
TELEGRAM_NOT_LINKED = "⚠ Il tuo account Telegram non è registrato a Royalnet! Registrati con `/register@royalgamesbot <nomeutenteryg>`."
|
||||||
|
@ -76,6 +78,6 @@ class MATCHMAKING:
|
||||||
|
|
||||||
|
|
||||||
# Diario search
|
# Diario search
|
||||||
class DIARIO_SEARCH:
|
class DIARIOSEARCH:
|
||||||
class ERRORS:
|
class ERRORS:
|
||||||
INVALID_SYNTAX = "⚠ Non hai specificato un termine da cercare!\nSintassi: <pre>/search {termine}</pre>"
|
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
|
from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton
|
||||||
# noinspection PyPackageRequirements
|
# noinspection PyPackageRequirements
|
||||||
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
|
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
|
||||||
from telegram.error import TimedOut, Unauthorized
|
from telegram.error import TimedOut, Unauthorized, BadRequest
|
||||||
import dice
|
import dice
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -303,7 +303,7 @@ def cmd_cerca(bot: Bot, update: Update):
|
||||||
try:
|
try:
|
||||||
queryText = update.message.text.split(" ", 1)[1]
|
queryText = update.message.text.split(" ", 1)[1]
|
||||||
except IndexError:
|
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
|
return
|
||||||
queryText = queryText.replace('%', '\\%').replace('_', '\\_')
|
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()
|
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])
|
for key in strings.MATCHMAKING.BUTTONS])
|
||||||
else:
|
else:
|
||||||
inline_keyboard = None
|
inline_keyboard = None
|
||||||
bot.edit_message_text(message_id=update.callback_query.message.message_id,
|
try:
|
||||||
chat_id=config["Telegram"]["announcement_group"],
|
bot.edit_message_text(message_id=update.callback_query.message.message_id,
|
||||||
text=match.generate_text(session),
|
chat_id=config["Telegram"]["announcement_group"],
|
||||||
reply_markup=inline_keyboard,
|
text=match.generate_text(session),
|
||||||
parse_mode="HTML")
|
reply_markup=inline_keyboard,
|
||||||
|
parse_mode="HTML")
|
||||||
|
except BadRequest:
|
||||||
|
pass
|
||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
|
@ -732,6 +735,11 @@ def cmd_roll(bot: Bot, update: Update):
|
||||||
bot.send_message(update.message.chat.id, f"🎲 {result}")
|
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):
|
def process(arg_discord_connection):
|
||||||
if arg_discord_connection is not None:
|
if arg_discord_connection is not None:
|
||||||
global discord_connection
|
global discord_connection
|
||||||
|
|
Loading…
Reference in a new issue