1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00

Aggiunto /pug, un comando per @Mallllco!

This commit is contained in:
Steffo 2019-02-22 01:53:25 +01:00
parent 66e5ed6dd4
commit 5174655f6b
2 changed files with 17 additions and 4 deletions

View file

@ -183,6 +183,11 @@ class MATCHMAKING:
MATCH_CLOSED = "⚠ Il matchmaking per questa partita è terminato." MATCH_CLOSED = "⚠ Il matchmaking per questa partita è terminato."
# Pug sender
class PUG:
HERE_HAVE_A_PUG = '🐶 Ecco, tieni un <a href="{image_url}">carlino</a>.'
# Dice roller # Dice roller
class ROLL: class ROLL:
SUCCESS = "🎲 {result}" SUCCESS = "🎲 {result}"

View file

@ -21,6 +21,7 @@ import raven
import coloredlogs import coloredlogs
import strings import strings
import time import time
import requests
IKMarkup = telegram.InlineKeyboardMarkup IKMarkup = telegram.InlineKeyboardMarkup
IKButton = telegram.InlineKeyboardButton IKButton = telegram.InlineKeyboardButton
@ -55,17 +56,17 @@ sentry = raven.Client(config["Sentry"]["token"],
hook_libraries=[]) hook_libraries=[])
def reply_msg(bot: telegram.Bot, chat_id: int, string: str, ignore_escaping=False, **kwargs) -> telegram.Message: def reply_msg(bot: telegram.Bot, chat_id: int, string: str, ignore_escaping=False, disable_web_page_preview=True, **kwargs) -> telegram.Message:
string = strings.safely_format_string(string, ignore_escaping=ignore_escaping, words=kwargs) string = strings.safely_format_string(string, ignore_escaping=ignore_escaping, words=kwargs)
return bot.send_message(chat_id, string, return bot.send_message(chat_id, string,
parse_mode="HTML", parse_mode="HTML",
disable_web_page_preview=True) disable_web_page_preview=disable_web_page_preview)
def reply(bot: telegram.Bot, update: telegram.Update, string: str, ignore_escaping=False, **kwargs) -> telegram.Message: def reply(bot: telegram.Bot, update: telegram.Update, string: str, ignore_escaping=False, disable_web_page_preview=True, **kwargs) -> telegram.Message:
while True: while True:
try: try:
return reply_msg(bot, update.message.chat.id, string, ignore_escaping=ignore_escaping, **kwargs) return reply_msg(bot, update.message.chat.id, string, ignore_escaping=ignore_escaping, disable_web_page_preview=disable_web_page_preview, **kwargs)
except Unauthorized: except Unauthorized:
if update.message.chat.type == telegram.Chat.PRIVATE: if update.message.chat.type == telegram.Chat.PRIVATE:
return reply_msg(bot, main_group_id, strings.TELEGRAM.ERRORS.UNAUTHORIZED_USER, return reply_msg(bot, main_group_id, strings.TELEGRAM.ERRORS.UNAUTHORIZED_USER,
@ -816,6 +817,12 @@ def cmd_emojify(bot: telegram.Bot, update: telegram.Update):
reply(bot, update, strings.EMOJIFY.RESPONSE, emojified=msg) reply(bot, update, strings.EMOJIFY.RESPONSE, emojified=msg)
@command
def cmd_pug(bot: telegram.Bot, update: telegram.Update):
j = requests.get("https://dog.ceo/api/breed/pug/images/random").json()
reply(bot, update, strings.PUG.HERE_HAVE_A_PUG, disable_web_page_preview=False, image_url=j["message"])
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
@ -852,6 +859,7 @@ def process(arg_discord_connection):
u.dispatcher.add_handler(CommandHandler("start", cmd_start)) u.dispatcher.add_handler(CommandHandler("start", cmd_start))
u.dispatcher.add_handler(CommandHandler("spell", cmd_spell)) u.dispatcher.add_handler(CommandHandler("spell", cmd_spell))
u.dispatcher.add_handler(CommandHandler("emojify", cmd_emojify)) u.dispatcher.add_handler(CommandHandler("emojify", cmd_emojify))
u.dispatcher.add_handler(CommandHandler("pug", cmd_pug))
u.dispatcher.add_handler(CallbackQueryHandler(on_callback_query)) u.dispatcher.add_handler(CallbackQueryHandler(on_callback_query))
logger.info("Handlers registered.") logger.info("Handlers registered.")
u.start_polling() u.start_polling()