Skip to content

Instantly share code, notes, and snippets.

@donRumata03
Created January 16, 2021 17:46
Show Gist options
  • Select an option

  • Save donRumata03/bcc83c87604b86f4869bea758abdf0d5 to your computer and use it in GitHub Desktop.

Select an option

Save donRumata03/bcc83c87604b86f4869bea758abdf0d5 to your computer and use it in GitHub Desktop.
The Mark Ipatov Bot
import telebot
def clean_word(word: str):
return "".join(filter(lambda x: str.isalnum(x), word.lower()))
def IpatovMarkize(string: str):
words = string.split()
has_mipatov = False
ptr = 0
while ptr < len(words):
has_mipatov_this = False
if ptr != len(words) - 1:
viewing_words = { clean_word(words[ptr]), clean_word(words[ptr + 1]) }
if ("марк" in viewing_words or "mark" in viewing_words) and ("ipatov" in viewing_words or "ипатов" in viewing_words):
has_mipatov_this = True
has_mipatov = True
words[ptr], words[ptr + 1] = words[ptr + 1], words[ptr]
if has_mipatov_this:
ptr += 2
else:
ptr += 1
if not has_mipatov:
return None
return " ".join(words)
# print(clean_word("dkfjgh*?(*?(*:!!"))
bot = telebot.TeleBot('1481980528:AAEOauqfL8lT1sN4n1fhHc38J4my5o0m5RE')
@bot.message_handler(content_types=['text'])
def get_text_messages(message):
# print(message.from_user.id, message.chat.id)
response = IpatovMarkize(message.text)
if response is not None:
bot.send_message(message.chat.id, response)
bot.polling(none_stop=True, interval=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment