1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-30 15:04:18 +00:00

Speriamo che vada.

This commit is contained in:
Steffo 2018-09-11 02:02:09 +02:00
parent fba5673a9a
commit 6bb940bab0
3 changed files with 18 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import random import random
import math import math
import dice
def cast(spell_name: str, target_name: str, platform: str) -> str: def cast(spell_name: str, target_name: str, platform: str) -> str:

4
db.py
View file

@ -805,7 +805,7 @@ class Reddit(Base):
royal_id = Column(Integer, ForeignKey("royals.id")) royal_id = Column(Integer, ForeignKey("royals.id"))
royal = relationship("Royal", backref="reddit", lazy="joined") royal = relationship("Royal", backref="reddit", lazy="joined")
username = Column(String) username = Column(String, primary_key=True)
karma = Column(BigInteger) karma = Column(BigInteger)
@ -815,7 +815,7 @@ class GameLog(Base):
royal_id = Column(Integer, ForeignKey("royals.id")) royal_id = Column(Integer, ForeignKey("royals.id"))
royal = relationship("Royal", backref="gamelog", lazy="joined") royal = relationship("Royal", backref="gamelog", lazy="joined")
username = Column(String) username = Column(String, primary_key=True)
owned_games = Column(Integer) owned_games = Column(Integer)
unfinished_games = Column(Integer) unfinished_games = Column(Integer)
beaten_games = Column(Integer) beaten_games = Column(Integer)

View file

@ -7,7 +7,7 @@ import stagismo
from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
import telegram.error import telegram.error
from discord import Status as DiscordStatus import dice
import subprocess import subprocess
import os import os
import time import time
@ -503,11 +503,23 @@ def cmd_markov(bot: Bot, update: Update):
bot.send_message(update.message.chat.id, sentence) 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): 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
discord_connection = arg_discord_connection discord_connection = arg_discord_connection
logger.info("Creating updater...")
u = Updater(config["Telegram"]["bot_token"]) u = Updater(config["Telegram"]["bot_token"])
logger.info("Registering handlers...")
u.dispatcher.add_handler(CommandHandler("register", cmd_register)) u.dispatcher.add_handler(CommandHandler("register", cmd_register))
u.dispatcher.add_handler(CommandHandler("discord", cmd_discord)) u.dispatcher.add_handler(CommandHandler("discord", cmd_discord))
u.dispatcher.add_handler(CommandHandler("cv", 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("newevent", cmd_newevent))
u.dispatcher.add_handler(CommandHandler("calendar", cmd_calendar)) u.dispatcher.add_handler(CommandHandler("calendar", cmd_calendar))
u.dispatcher.add_handler(CommandHandler("markov", cmd_markov)) 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)) u.dispatcher.add_handler(CallbackQueryHandler(on_callback_query))
logger.info("Handlers registered.") logger.info("Handlers registered.")
u.bot.send_message(config["Telegram"]["main_group"], u.bot.send_message(config["Telegram"]["main_group"],