coronabot/bot.py

40 lines
1018 B
Python
Executable File

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import config
TOKEN = config.apiToken
from telegram.ext import Updater
from telegram.ext import CommandHandler
updater = Updater(token=TOKEN, use_context=True)
dispatcher = updater.dispatcher
def start(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text="Sóc un bot, prova a dir-me /andorra o /world")
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
def andorra(update, context):
os.system("./and.py")
text=open("and.txt", "r")
context.bot.send_message(chat_id=update.effective_chat.id, text=text.read())
and_handler = CommandHandler('andorra', andorra)
dispatcher.add_handler(and_handler)
def world(update, context):
os.system("./world.py")
text=open("world.txt", "r")
context.bot.send_message(chat_id=update.effective_chat.id, text=text.read())
world_handler = CommandHandler('world', world)
dispatcher.add_handler(world_handler)
updater.start_polling()