Skip to content

Instantly share code, notes, and snippets.

@andreuinyu
Created January 31, 2017 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreuinyu/761ecf393ebf1c876a67844778042c4e to your computer and use it in GitHub Desktop.
Save andreuinyu/761ecf393ebf1c876a67844778042c4e to your computer and use it in GitHub Desktop.
t.me/reverser_bot
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