result
unknown
python
a year ago
4.4 kB
5
Indexable
"""IT WAS""" import telebot from telebot import types import re bot = telebot.TeleBot("") @bot.message_handler(commands=["start"]) def start(message): bot.send_message(message.from_user.id, text="Вот возможности нашего бота:", reply_markup=types.InlineKeyboardMarkup().add(types.InlineKeyboardButton(text="Шифровать", callback_data="encode"), types.InlineKeyboardButton(text="Дешифровать", callback_data="decode"))) @bot.callback_query_handler(func=lambda call: True) def answer(call): global CALL CALL = call if call.data: bot.register_next_step_handler(bot.send_message(call.from_user.id, text="Введите выражение:"), func_encode) def func_encode(message): message_out = re.findall(r"\d+|[+/*-=]|[a-zA-Z]+", message.text) mass = { "x": "-", "y": "|", "z": "n", "n": "z", "i": "l", "m": "w", "-": "_", "+": "t", "*": ".", "/": "^", "(": "{", ")": "}", "=": "~"} if CALL.data == "encode" else {v: k for k, v in { "x": "-", "y": "|", "z": "n", "n": "z", "i": "l", "m": "w", "-": "_", "+": "t", "*": ".", "/": "^", "(": "{", ")": "}", "=": "~"}.items()} for i in range(len(message_out)): message_out[i] = mass[message_out[i]] if message_out[i] in mass else str((int(message_out[i]) + 28) * 121) if message_out[i].isdigit() == True and CALL.data == "encode" else str(int(int(message_out[i]) / 121 - 28)) if message_out[i].isdigit() == True and CALL.data == "decode" else "." bot.send_message(message.from_user.id, text="".join(message_out), reply_markup=types.InlineKeyboardMarkup().add(types.InlineKeyboardButton(text="Шифровать", callback_data="encode"), types.InlineKeyboardButton(text="Дешифровать", callback_data="decode"))) bot.polling(non_stop=True) """IT HAS BECOME""" import telebot from telebot import types import re bot = telebot.TeleBot("") @bot.message_handler(commands=["start"]) def start(message): bot.send_message( message.from_user.id, text="Вот возможности нашего бота:", reply_markup=types.InlineKeyboardMarkup().add( types.InlineKeyboardButton(text="Шифровать", callback_data="encode"), types.InlineKeyboardButton(text="Дешифровать", callback_data="decode"), ), ) @bot.callback_query_handler(func=lambda call: True) def answer(call): global CALL CALL = call if call.data: bot.register_next_step_handler( bot.send_message(call.from_user.id, text="Введите выражение:"), func_encode ) def func_encode(message): message_out = re.findall(r"\d+|[+/*-=]|[a-zA-Z]+", message.text) mass = ( { "x": "-", "y": "|", "z": "n", "n": "z", "i": "l", "m": "w", "-": "_", "+": "t", "*": ".", "/": "^", "(": "{", ")": "}", "=": "~", } if CALL.data == "encode" else { v: k for k, v in { "x": "-", "y": "|", "z": "n", "n": "z", "i": "l", "m": "w", "-": "_", "+": "t", "*": ".", "/": "^", "(": "{", ")": "}", "=": "~", }.items() } ) for i in range(len(message_out)): message_out[i] = ( mass[message_out[i]] if message_out[i] in mass else str((int(message_out[i]) + 28) * 121) if message_out[i].isdigit() == True and CALL.data == "encode" else str(int(int(message_out[i]) / 121 - 28)) if message_out[i].isdigit() == True and CALL.data == "decode" else "." ) bot.send_message( message.from_user.id, text="".join(message_out), reply_markup=types.InlineKeyboardMarkup().add( types.InlineKeyboardButton(text="Шифровать", callback_data="encode"), types.InlineKeyboardButton(text="Дешифровать", callback_data="decode"), ), ) bot.polling(non_stop=True)
Editor is loading...
Leave a Comment