def start_bot_weebook_ngrok():
    bot.remove_webhook()
    ngrok_conn = ngrok.connect(port)
    http_url = ngrok_conn.public_url
    https_url = http_url.replace('http://', 'https://')
    bot.set_webhook(url=https_url + '/' + secret)
    print(
        f'------------- ONLY FOR TESTS (USING Webhook and pyngrok) -------------\n'
        f'http_url = {http_url}\nhttps_url={https_url}\n')
    app.run(debug=True)
Пример #2
0
def start_bot():
    if global_settings.DEBUG == True:
        bot.polling()
    else:
        import time
        print('STARTED')
        bot.remove_webhook()
        time.sleep(1)
        bot.set_webhook(
            url=WEBHOOK_URL,
            certificate=open('nginx-selfsigned.crt', 'r')
            )
        app.run(host='127.0.0.1', port=5000, debug=True)
Пример #3
0
def start():
    logging.basicConfig(filename="log.log", level=logging.INFO)
    try:
        now_date = datetime.datetime.today()
        now_date = now_date.strftime("%d/%m/%y %H:%M")
        logging.info('[' + now_date + '] Bot started')
        bot.remove_webhook()
        bot.set_webhook(url=WEBHOOK_URL_BASE + WEBHOOK_URL_PATH,
                        certificate=open(WEBHOOK_SSL_CERT, 'r'))
        cherrypy.config.update({
            'server.socket_host': WEBHOOK_LISTEN,
            'server.socket_port': WEBHOOK_PORT,
            'server.ssl_module': 'builtin',
            'server.ssl_certificate': WEBHOOK_SSL_CERT,
            'server.ssl_private_key': WEBHOOK_SSL_PRIV
        })
        cherrypy.quickstart(WebhookServer(), WEBHOOK_URL_PATH, {'/': {}})
    except:
        now_date = datetime.datetime.today()
        now_date = now_date.strftime("%d/%m/%y %H:%M")
        logging.debug('[' + now_date + '] Bot dropped')
    now_date = datetime.datetime.today()
    now_date = now_date.strftime("%d/%m/%y %H:%M")
    logging.info('[' + now_date + '] Bot finished')
Пример #4
0
 def webhook():
     bot.remove_webhook()
     bot.set_webhook(url='https://test-school4-bot.herokuapp.com/' +
                     TOKEN)
     return "!", 200
Пример #5
0
def webhook():
    jurl = heroku_url
    bot.remove_webhook()
    bot.set_webhook(jurl + token)
    return f"Webhook set to {heroku_url}"
Пример #6
0
@bot.callback_query_handler(func=lambda call: call.data == START_KB['story'])
def story_order(call):

    bot.story_order(str(call.from_user.id))


@bot.callback_query_handler(
    func=lambda call: call.data.split('_')[0] == 'story')
def show_archive_order(call):
    id_cart = call.data.split('_')[1]

    bot.show_archive_cart(str(call.from_user.id), id_cart)


"""
WEBHOOK_HOST = https://33.46.22.19:8443

PKEM = '/home/sertificates/webhok_pkem.pem'
PKEY = '/home/sertificates/webhok_pkey.pem'

bot.set_webhook(WEBHOOK_HOST, open('r', PKEM))

TimeLoop - cron

sendChatAction - ... 'typing'

нджинкс - всджиай - питон

VPS - mesto na polwoi mawine
VDS - Fiz machin
Пример #7
0
                                                   name=name,
                                                   action=action,
                                                   year=year,
                                                   month=month,
                                                   day=day)
    if action == "DAY":
        if date < datetime.datetime.now():
            bot.send_message(
                call.message.chat.id,
                "You can choose date older than today, try one more time")
            return schedule_lesson(call.message)
        SAVED_DATA['schedule']['users'].append(SAVED_DATA['user_id'])
        return clock(call.message, date)
    elif action == "CANCEL":
        bot.send_message(
            chat_id=call.from_user.id,
            text="Cancellation \ngo too main: \start",
            reply_markup=types.ReplyKeyboardRemove(),
        )
        return start(call.message)


if __name__ == '__main__':
    while True:
        try:
            bot.set_webhook()
            bot.polling(none_stop=True)
        except Exception as e:
            telebot.logger.error(e)
            time.sleep(15)