def shvs(m): if m.text == gettr(m.chat.id, 'back'): send_text(m) return try: c = format(int(m.text, 16), "0o") except: c = gettr(m.chat.id, 'error') msg = bot.send_message(m.chat.id, c) bot.register_next_step_handler(msg, shvs)
def cosFoo(m): if m.text == gettr(m.chat.id, 'back'): send_text(m) return try: d = math.cos(float(m.text)) except: d = gettr(m.chat.id, 'error_cos') msg = bot.send_message(m.chat.id, d) bot.register_next_step_handler(msg, cosFoo)
def vsds(m): if m.text == gettr(m.chat.id, 'back'): send_text(m) return try: c = str(int(m.text, 8)) except: c = gettr(m.chat.id, 'error') msg = bot.send_message(m.chat.id, c) bot.register_next_step_handler(msg, vsds)
def trig(m): markup = types.ReplyKeyboardRemove(selective=True) if m.text == gettr(m.chat.id, 'cos'): keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_cos'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, cosFoo)
def calculator(m): if m.text == gettr(m.chat.id, 'back'): send_text(m) return s = "" try: pattern = re.compile("^([-+]*[0-9]*\.?[0-9]+[\/\+\-\*\(\)\^\%]*)*$") if pattern.match(m.text): s = eval(m.text) else: s = gettr(m.chat.id, 'taboo_char') except: s = gettr(m.chat.id, 'error_exp') msg = bot.send_message(m.chat.id, s) bot.register_next_step_handler(msg, calculator)
def send_text(m): if m.text == 'Uzbek' '\U0001F1FA\U0001F1FF': chooselang(m.chat.id, "uz") elif m.text == 'Rus' '\U0001f1f7\U0001f1fa': chooselang(m.chat.id, "ru") keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [ gettr(m.chat.id, 'calc'), gettr(m.chat.id, 'converter'), gettr(m.chat.id, 'trigonometry') ] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'langselect'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, name)
def name(m): markup = types.ReplyKeyboardRemove(selective=False) if m.text == gettr(m.chat.id, 'calc'): bot.send_message(m.chat.id, gettr(m.chat.id, 'calc_mod'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'calc_ae'), reply_markup=keyboard) bot.register_next_step_handler(msg, calculator) elif m.text == gettr(m.chat.id, 'converter'): bot.send_message(m.chat.id, gettr(m.chat.id, 'converter_mod'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [ '2 ➝ 10', '10 ➝ 2', '2 ➝ 16', '16 ➝ 2', '10 ➝ 16', '16 ➝ 10', '2 ➝ 8', '8 ➝ 2', '10 ➝ 8', '8 ➝ 10', '8 ➝ 16', '16 ➝ 8', gettr(m.chat.id, 'back') ] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'converter_type'), reply_markup=keyboard) bot.register_next_step_handler(msg, convert) elif m.text == gettr(m.chat.id, 'trigonometry'): bot.send_message(m.chat.id, gettr(m.chat.id, 'trig_mod'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add( * [types.KeyboardButton(name) for name in [gettr(m.chat.id, 'cos')]]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'trig_ae'), reply_markup=keyboard) bot.register_next_step_handler(msg, trig)
def convert(m): markup = types.ReplyKeyboardRemove(selective=False) if m.text == '2 ➝ 10': bot.send_message(m.chat.id, gettr(m.chat.id, 'bin'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_bin'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, dvds) elif m.text == '10 ➝ 2': bot.send_message(m.chat.id, gettr(m.chat.id, 'dec'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_dec'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, dsdv) elif m.text == '2 ➝ 16': bot.send_message(m.chat.id, gettr(m.chat.id, 'bin'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_bin'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, dvsh) elif m.text == '16 ➝ 2': bot.send_message(m.chat.id, gettr(m.chat.id, 'hex'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_hex'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, shdv) elif m.text == '10 ➝ 16': bot.send_message(m.chat.id, gettr(m.chat.id, 'dec'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_dec'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, dssh) elif m.text == '16 ➝ 10': bot.send_message(m.chat.id, gettr(m.chat.id, 'hex'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_hex'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, shds) elif m.text == '2 ➝ 8': bot.send_message(m.chat.id, gettr(m.chat.id, 'bin'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_bin'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, dvvs) elif m.text == '8 ➝ 2': bot.send_message(m.chat.id, gettr(m.chat.id, 'oct'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_oct'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, vsdv) elif m.text == '8 ➝ 10': bot.send_message(m.chat.id, gettr(m.chat.id, 'oct'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_oct'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, vsds) elif m.text == '10 ➝ 8': bot.send_message(m.chat.id, gettr(m.chat.id, 'dec'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_dec'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, dsvs) elif m.text == '8 ➝ 16': bot.send_message(m.chat.id, gettr(m.chat.id, 'oct'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_oct'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, vssh) elif m.text == '16 ➝ 8': bot.send_message(m.chat.id, gettr(m.chat.id, 'hex'), parse_mode='Markdown', reply_markup=markup) keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) keyboard.add(*[ types.KeyboardButton(name) for name in [gettr(m.chat.id, 'back')] ]) msg = bot.send_message(m.chat.id, gettr(m.chat.id, 'example_hex'), parse_mode='Markdown', reply_markup=keyboard) bot.register_next_step_handler(msg, shvs) elif m.text == gettr(m.chat.id, 'back'): send_text(m) return
def back(m): if m.text == gettr(m.chat.id, 'back'): bot.send_message(m.chat.id, gettr(m.chat.id, '')) send_text(m) return