mirror of
https://github.com/RYGhub/royal-mifia.git
synced 2025-02-16 13:24:06 +00:00
Aggiunto newgam
This commit is contained in:
parent
76c42beb93
commit
7dc6482a39
1 changed files with 18 additions and 1 deletions
19
main.py
19
main.py
|
@ -1,6 +1,10 @@
|
|||
from telegram.ext import Updater
|
||||
import filemanager
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
token = filemanager.readfile('telegramapi.txt')
|
||||
updater = Updater(token)
|
||||
|
||||
|
@ -99,10 +103,23 @@ class Game:
|
|||
# Inoltra il messaggio all'admin
|
||||
self.adminmessage(bot, text)
|
||||
|
||||
# Partite in corso
|
||||
inprogress = list()
|
||||
|
||||
|
||||
# Comandi a cui risponde il bot
|
||||
def ping(bot, update):
|
||||
bot.sendMessage(update.message.chat.id, "Pong!")
|
||||
|
||||
|
||||
def newgame(bot, update):
|
||||
if update.message.chat['type'] != 'private':
|
||||
g = Game(update.message.chat['id'], update.message.from_user['id'])
|
||||
inprogress.append(g)
|
||||
bot.sendMessage(update.message.chat.id, repr(inprogress))
|
||||
else:
|
||||
bot.sendMessage(update.message.chat.id, "Non puoi creare una partita in questo tipo di chat!")
|
||||
|
||||
updater.dispatcher.addTelegramCommandHandler('ping', ping)
|
||||
updater.start_polling()
|
||||
updater.dispatcher.addTelegramCommandHandler('newgame', newgame)
|
||||
updater.start_polling()
|
||||
|
|
Loading…
Add table
Reference in a new issue