def gen_markup_starter(): markup = ReplyKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Заработать"), InlineKeyboardButton("Баланс"), InlineKeyboardButton("Правила"), InlineKeyboardButton("Пригласить друзей"), InlineKeyboardButton("Вывод")) return markup
def start_markup(): markup = ReplyKeyboardMarkup(resize_keyboard=True) markup.row_width = 2 a=KeyboardButton('🔎 IP Lookup') b=KeyboardButton('🔎 Search Subdomains') markup.row(a) markup.row(b) return markup
def bottom_markup(): markup = ReplyKeyboardMarkup() markup.row_width = 2 markup.one_time_keyboard = 2 markup.add(InlineKeyboardButton("💿热搜榜推荐", callback_data='recommend'), InlineKeyboardButton("🈲写代码专用", callback_data='very_hot'), InlineKeyboardButton("🎻小品相声", callback_data='classic_music'), InlineKeyboardButton("📗我要上传", callback_data='upload')) return markup
def reply_markup2(): markupl = ReplyKeyboardMarkup() markupl.row_width = 1 item_bt1 = types.KeyboardButton('Data Science (DSt)') item_bt2 = types.KeyboardButton('Machine Learning (MLt)') item_bt3 = types.KeyboardButton('Data Vizualization (DVt)') item_bt4 = types.KeyboardButton('Artificial Intelligence (AIt)') markupl.add(item_bt1,item_bt2,item_bt3,item_bt4) return markupl
def repl_markup(arr, rw=5, rh=20): markup = ReplyKeyboardMarkup() markup.row_width = rw markup.resize_keyboard = 20 for i, buttons in enumerate(arr.copy()): arr[i] = KeyboardButton(buttons) markup.add(*arr) return markup
def index(): if request.method == "POST": passcodenew = request.form['passcode'] logging.info("given pin from web is: " + str(passcodenew)) with open(datafolder + "db/box.json", 'r') as ff: datastore = json.load(ff) pincode = datastore["pin"][0] logging.info("real pin is: " + str(pincode)) if str(pincode) == str(passcodenew): alert = "Не забудьте закрыть крышку, пожалуйста." markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('GOD: Домой')) bot.send_message(godID, "Открой крышку. Потом езжай домой.", reply_markup=markup) return render_template( "index.html", **locals()) else: alert = "Вы ввели неправильный пароль" return render_template( "index.html", **locals()) alert = "Введите пароль из смс, пожалуйста" return render_template('index.html', **locals())
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, KeyboardButton mark1 = InlineKeyboardMarkup() mark1.row_width = 2 mark1.add(InlineKeyboardButton("Да", callback_data="y0"), InlineKeyboardButton("Нет", callback_data="n0")) m1 = ReplyKeyboardMarkup(resize_keyboard=True) m1.add(KeyboardButton("📲 Доступные для загрузки приложения")) m1.add(KeyboardButton("✉ Пригласить друга"), KeyboardButton('📃 Информация')) m2 = ReplyKeyboardMarkup(resize_keyboard=True) m2.add(KeyboardButton("⬅ Главное меню")) m4 = ReplyKeyboardMarkup() m4.row_width = 1 m4.add(KeyboardButton('Joom – товары из Китая [Android 5.0+]')) m4.add(KeyboardButton('Joom – покупай и экономь! [IOS]')) m4.add(KeyboardButton('Auto.ru [Android 5.0+]')) m4.add(KeyboardButton('Auto.ru [IOS]')) m4.add(KeyboardButton('Winline [IOS]')) m4.add(KeyboardButton('Париматч: ставки на спорт [IOS]')) m4.add(KeyboardButton('Book of Slots [IOS]')) md1 = ReplyKeyboardMarkup(resize_keyboard=True) md1.add(KeyboardButton("📲 Доступные приложения для загрузки")) md1.add(KeyboardButton("⬇ Скачать Joom[Android]")) md1.add(KeyboardButton("⬅ Главное меню")) md2 = ReplyKeyboardMarkup(resize_keyboard=True) md2.add(KeyboardButton("📲 Доступные приложения для загрузки"))
def gen_markup(): markup = ReplyKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Yes", callback_data=f"cb_yes"), InlineKeyboardButton("No", callback_data=f"cb_no")) return markup
def main_messages(message): logging.info("New message: " + str(message.text) + " from: " + str(message.chat.id)) if message.text == "Нет": bot.reply_to(message, "Хорошо, если вдруг передумаете, нажмите на кнопку 'Да'", reply_markup=gen_markup()) elif message.text == "Я не приду": markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('GOD: Домой')) bot.send_message(godID, "Не придут, отмена, домой.", reply_markup=markup) bot.send_message(adminID, "Клиент отменил поездку. Выезжаю обратно в офис.") bot.reply_to(message, "Хорошо, тогда я поехала обратно в офис АО 'Казпочта'") elif message.text == "Проверить посылку" and str( message.chat.id) == str(adminID): bot.send_message(adminID, "Введите ШПИ в формате 'KZ112345678KZ', пожалуйста.") elif message.text == "Отмена" and str(message.chat.id) == str(adminID): send_main_menu() elif message.text[:2] == "KZ" and str(message.chat.id) == str(adminID): bot.send_message(godID, "Начал проверку ШПИ: " + message.text) pus_data(message.text) elif message.text == "Посылка в роботе" and str( message.chat.id) == str(adminID): bot.send_message(adminID, "Провожу процесс загрузки посылки.") with open(datafolder + "db/box.json", 'r') as ff: datastore = json.load(ff) status, info = income(datastore["spi"]) if status[0] == "E": bot.send_message(adminID, "ПУС отправил следующую ошибку: " + info) send_main_menu() else: bot.send_message(godID, "Положила в робота посылку.") responce = "Выберите направление." markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('Направление: Astana Hub'), \ KeyboardButton("Направление: Mega Silkway"), \ KeyboardButton("Направление: AIFC")) bot.send_message(adminID, responce, reply_markup=markup) elif message.text == "Спать" and str(message.chat.id) == str(adminID): bot.send_message(godID, "Отправлен спать") send_main_menu() elif message.text[:13] == "Направление: " and str( message.chat.id) == str(adminID): address = message.text[13:] with open(datafolder + "db/box.json", 'r') as ff: datastore = json.load(ff) datastore["address"] = address logging.info("Datastore is: " + str(datastore)) with open(datafolder + "db/box.json", 'w') as ff2: json.dump(datastore, ff2) markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('GOD: Доехал'), KeyboardButton("GOD: Трабл на дороге")) bot.send_message(godID, "Выезжай на точку: " + address, reply_markup=markup) bot.send_message(adminID, "Я направляюсь на точку: " + address) if datastore["id"]: bot.send_sticker(datastore["id"], "CAADAgADEwEAAtrHBgABeuVsifwYcG4WBA") bot.send_message(datastore["id"], "Я выехала доставить Вам посылку [ШПИ №" + \ datastore["spi"] + "]. Через 15 минут ожидайте меня по адресу: " + \ datastore["address"] + ".") bot.send_location(datastore["id"], points[address][0], points[address][1]) else: send_sms(datastore) elif message.text == "Получить посылку": with open(datafolder + "db/box.json", 'r') as ff: datastore = json.load(ff) if str(datastore["id"]) == str(message.chat.id): status, info = given(datastore["spi"]) bot.send_message(adminID, info) bot.send_sticker(message.chat.id, "CAADAgADKgEAAtrHBgABFMqO3SCCTN4WBA") bot.send_message( message.chat.id, """\ Отлично! Спасибо, что воспользовались нашей доставкой! Пожалуйста, не забудьте закрыть крышку за собой.\ """) markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('GOD: Домой')) bot.send_message(godID, "Открой крышку. Потом езжай домой.", reply_markup=markup) elif message.text == "GOD: Домой" and str(message.chat.id) == str(godID): markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('GOD: Пустой'), KeyboardButton('GOD: Не пустой')) bot.send_message(godID, "Приехал, нажми.", reply_markup=markup) elif message.text == "GOD: Пустой" and str(message.chat.id) == str(godID): with open(datafolder + "db/box.json", 'r') as ff: datastore = json.load(ff) status, info = given(datastore["spi"]) markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('Спать')) bot.send_message(adminID, "Вернулась домой, отдала посылку. Хочу спать.", reply_markup=markup) bot.send_message(godID, "Ок, иди отдыхать.") elif message.text == "GOD: Не пустой" and str( message.chat.id) == str(godID): markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('Вернуть посылку')) bot.send_message(adminID, "Вернулась домой, не отдала посылку.", reply_markup=markup) bot.send_message(godID, "Жди команды открыть дверь.") elif message.text == "Вернуть посылку" and str( message.chat.id) == str(adminID): with open(datafolder + "db/box.json", 'r') as ff: datastore = json.load(ff) status, info = back(datastore["spi"]) bot.send_message(adminID, info) bot.send_message(godID, "Открывай") bot.send_message(adminID, "Открыла дверь, до свидания!") elif message.text[:5] == "GOD: " and str(message.chat.id) == str(godID): if message.text[-6:] == "Доехал": with open(datafolder + "db/box.json", 'r') as ff: datastore = json.load(ff) markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('GOD: Домой')) bot.send_message(godID, "Ок, жди 30 минут. \ Если никто не придет, запускай дорогу домой", reply_markup=markup) bot.send_message(adminID, "Доехала. Жду 30 минут клиента.") if datastore["id"]: bot.send_sticker(datastore["id"], "CAADAgADDwEAAtrHBgABtT_ofg7UMK4WBA") markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('Получить посылку'), KeyboardButton("Я не приду")) waiting = datetime.datetime.now() + datetime.timedelta( minutes=30) bot.send_message(datastore["id"], "Я приехала. \ Буду ожидать Вас до " + waiting.strftime("%H:%M:%S") +\ """\ . Когда будете готовы, нажмите 'Получить посылку'. Если у Вас не получается забрать ее, нажмите 'Я не приду'.\ """ , reply_markup=markup) else: logging.error("Old type")
def pus_data(barcode): barcode = barcode.replace("\n", "") url = "http://pls-test.post.kz/api/service/postamatHierarchy?wsdl" url2 = "http://pls-test.post.kz/api/service/postamat?wsdl" headers = {'content-type': 'text/xml'} file_name = datafolder + "/templates/GETDATA.xml" file_name2 = datafolder + "/templates/chech_money.xml" with open(file_name, "r") as file: req = file.read() req = req.replace("BARCODE", barcode) response = send_post(url, data=req.replace("\n", "").encode('utf-8'), headers=headers) status = re.findall("<ResponseText>(.*?)</ResponseText>", str(response.content.decode("utf-8")))[0] if status != "Success": logging.warning("There is no such payload: " + barcode) responce = "Проверил по ШПИ №" + barcode + \ ". Вышла ошибка: " + status + "." bot.send_message(adminID, responce) send_main_menu() return False log = { 'barcode': barcode, "client": re.findall("<Rcpn>(.*?)</Rcpn>", str(response.content.decode("utf-8")))[0], "time": datetime.datetime.now(), "phone": re.findall("<RcpnPhone>(.*?)</RcpnPhone>", str(response.content.decode("utf-8")))[0] } responce = "Проверил адресата " + log["client"] + " по ШПИ №" + log["barcode"] + \ " с номером " + log["phone"] + ". Проверяю наложный платеж, пожалуйста, подождите." bot.send_message(adminID, responce) with open(file_name2, "r") as file: req = file.read() req = req.replace("BARCODE", barcode) response2 = send_post(url2, data=req.replace("\n", "").encode('utf-8'), headers=headers) cash_check = re.findall("<ns2:amount>(.*?)</ns2:amount>", str(response2.content)) if cash_check: if cash_check[0] != "0": cash_check = False else: cash_check = True else: cash_check = True if cash_check: responce = "Наложный платеж отсуствует. Проверяю пользователя в базе данных. Пожалуйста, ждите." bot.send_message(adminID, responce) else: responce = "Наложный платеж присуствует. Не могу доставлять посылки с платежом." bot.send_message(adminID, responce) send_main_menu() return False ids = find_user(log["phone"]) data = { 'id': ids, 'name': log["client"], 'spi': barcode, 'address': None, 'start': None, 'phone': log["phone"], 'pin': pass_create() } bot.send_message(godID, "PIN: " + str(data["pin"][0])) if ids: responce = "Этот пользователь зарегистрирован в нашей системе. Использую телеграмм интерфейс." markup = ReplyKeyboardMarkup() markup.row_width = 1 with open(datafolder + "db/box.json", 'w') as database: json.dump(data, database) markup.add(KeyboardButton('Посылка в роботе'), KeyboardButton("Отмена")) bot.send_message(adminID, responce, reply_markup=markup) else: responce = "Этот пользователь не пользуется нашим ботов в телеграм. Использую классический интерфейс." bot.send_message(adminID, responce) with open(datafolder + "db/box.json", 'w') as database: json.dump(data, database) # send_sms(data) markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('Посылка в роботе'), KeyboardButton("Отмена")) bot.send_message(adminID, responce, reply_markup=markup)
def gen_markup(): markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('Да (Отправить мой номер)', True), KeyboardButton("Нет")) return markup
def send_main_menu(): markup = ReplyKeyboardMarkup() markup.row_width = 1 markup.add(KeyboardButton('Проверить посылку')) bot.send_message(adminID, "Главное меню", reply_markup=markup)