Created
March 15, 2017 02:22
-
-
Save sldenazis/eba38f4777e57a80f4aea55e791cca89 to your computer and use it in GitHub Desktop.
it requires https://github.com/nickoala/telepot
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
import time | |
import telepot | |
import re | |
def handle(msg): | |
content_type, chat_type, chat_id = telepot.glance(msg) | |
print(content_type, chat_type, chat_id) | |
re_cu = re.compile('cii', re.IGNORECASE) | |
re_qu = re.compile('qii', re.IGNORECASE) | |
re_vowel = re.compile('(a|á|ä|å|ë|é|ö|ó|e|o|u|ú|à|è|ò|ù)', re.IGNORECASE) | |
if content_type == 'text': | |
missigi = re_vowel.sub('i', msg['text']) | |
missigi = re_qu.sub('qui', missigi) | |
missigi = re_cu.sub('qui', missigi) | |
bot.sendMessage(chat_id, missigi) | |
TOKEN = sys.argv[1] | |
bot = telepot.Bot(TOKEN) | |
bot.message_loop(handle) | |
print ('Listening ...') | |
# Keep the program running. | |
while 1: | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment