Created
January 31, 2017 18:00
-
-
Save andreuinyu/761ecf393ebf1c876a67844778042c4e to your computer and use it in GitHub Desktop.
t.me/reverser_bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters | |
def start(bot, update): | |
update.message.reply_text('This bot reverses every message you send') | |
def help(bot, update): | |
update.message.reply_text('Need help? Fuck yourself') | |
def answerer(bot, update): | |
text = update.message.text | |
update.message.reply_text(reverse(text)) | |
def reverse(s): | |
#Tonterida de funció | |
ans = '' | |
for c in s: | |
ans = c + ans | |
return ans | |
def main(): | |
with open('token.txt', 'r') as tokentxt: | |
#Obtenir d'un arxiu txt el token únic del bot en qüestió | |
token = tokentxt.readline().strip() | |
botUpdater = Updater(token) | |
bot = botUpdater.dispatcher | |
# Events | |
# Commandos: comencen amb / | |
bot.add_handler(CommandHandler("start", start)) | |
bot.add_handler(CommandHandler("help", help)) | |
# Missatges: Filtrar els de text | |
bot.add_handler(MessageHandler(Filters.text, answerer)) | |
botUpdater.start_polling() | |
botUpdater.idle() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment