mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Speriamo che vada.
This commit is contained in:
parent
fba5673a9a
commit
6bb940bab0
3 changed files with 18 additions and 3 deletions
1
cast.py
1
cast.py
|
@ -1,5 +1,6 @@
|
|||
import random
|
||||
import math
|
||||
import dice
|
||||
|
||||
|
||||
def cast(spell_name: str, target_name: str, platform: str) -> str:
|
||||
|
|
4
db.py
4
db.py
|
@ -805,7 +805,7 @@ class Reddit(Base):
|
|||
royal_id = Column(Integer, ForeignKey("royals.id"))
|
||||
royal = relationship("Royal", backref="reddit", lazy="joined")
|
||||
|
||||
username = Column(String)
|
||||
username = Column(String, primary_key=True)
|
||||
karma = Column(BigInteger)
|
||||
|
||||
|
||||
|
@ -815,7 +815,7 @@ class GameLog(Base):
|
|||
royal_id = Column(Integer, ForeignKey("royals.id"))
|
||||
royal = relationship("Royal", backref="gamelog", lazy="joined")
|
||||
|
||||
username = Column(String)
|
||||
username = Column(String, primary_key=True)
|
||||
owned_games = Column(Integer)
|
||||
unfinished_games = Column(Integer)
|
||||
beaten_games = Column(Integer)
|
||||
|
|
|
@ -7,7 +7,7 @@ import stagismo
|
|||
from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
|
||||
import telegram.error
|
||||
from discord import Status as DiscordStatus
|
||||
import dice
|
||||
import subprocess
|
||||
import os
|
||||
import time
|
||||
|
@ -503,11 +503,23 @@ def cmd_markov(bot: Bot, update: Update):
|
|||
bot.send_message(update.message.chat.id, sentence)
|
||||
|
||||
|
||||
def cmd_roll(bot: Bot, update: Update):
|
||||
dice_string = update.message.text.split(" ", 1)[1]
|
||||
try:
|
||||
result = dice.utilities.verbose_print(dice_string)
|
||||
except dice.DiceBaseException:
|
||||
bot.send_message(update.message.chat.id, "⚠ Il tiro dei dadi è fallito. Controlla la sintassi!")
|
||||
return
|
||||
bot.send_message(update.message.chat.id, f"🎲 Tiro {int(dice_string)}: **{result}**", parse_mode="Markdown")
|
||||
|
||||
|
||||
def process(arg_discord_connection):
|
||||
if arg_discord_connection is not None:
|
||||
global discord_connection
|
||||
discord_connection = arg_discord_connection
|
||||
logger.info("Creating updater...")
|
||||
u = Updater(config["Telegram"]["bot_token"])
|
||||
logger.info("Registering handlers...")
|
||||
u.dispatcher.add_handler(CommandHandler("register", cmd_register))
|
||||
u.dispatcher.add_handler(CommandHandler("discord", cmd_discord))
|
||||
u.dispatcher.add_handler(CommandHandler("cv", cmd_discord))
|
||||
|
@ -527,6 +539,8 @@ def process(arg_discord_connection):
|
|||
u.dispatcher.add_handler(CommandHandler("newevent", cmd_newevent))
|
||||
u.dispatcher.add_handler(CommandHandler("calendar", cmd_calendar))
|
||||
u.dispatcher.add_handler(CommandHandler("markov", cmd_markov))
|
||||
u.dispatcher.add_handler(CommandHandler("roll", cmd_roll))
|
||||
u.dispatcher.add_handler(CommandHandler("r", cmd_roll))
|
||||
u.dispatcher.add_handler(CallbackQueryHandler(on_callback_query))
|
||||
logger.info("Handlers registered.")
|
||||
u.bot.send_message(config["Telegram"]["main_group"],
|
||||
|
|
Loading…
Reference in a new issue