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)
Example #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)
Example #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')
def start_bot_getupdates():
    bot.remove_webhook()
    bot.infinity_polling(timeout=60, long_polling_timeout=100)
Example #5
0
 def webhook():
     bot.remove_webhook()
     bot.set_webhook(url='https://test-school4-bot.herokuapp.com/' +
                     TOKEN)
     return "!", 200
Example #6
0
from flask import Flask, request
import handlers.start_handler
import handlers.text_handler

if __name__ == '__main__':
    if "HEROKU" in list(os.environ.keys()):
        logger = telebot.logger
        telebot.logger.setLevel(logging.INFO)

        server = Flask(__name__)

        @server.route('/' + TOKEN, methods=['POST'])
        def getMessage():
            bot.process_new_updates([
                telebot.types.Update.de_json(
                    request.stream.read().decode("utf-8"))
            ])
            return "!", 200

        @server.route("/")
        def webhook():
            bot.remove_webhook()
            bot.set_webhook(url='https://test-school4-bot.herokuapp.com/' +
                            TOKEN)
            return "!", 200

        server.run(host="0.0.0.0", port=os.environ.get('PORT', 5000))
    else:
        bot.remove_webhook()
        bot.infinity_polling()
Example #7
0
from plugins.wiki import wikipedia
from plugins.screenshot import screen
from plugins.cats import cats
from plugins.github import github
from plugins.command_id import command_id
from plugins.translation import en, ru
from plugins.game import game
from plugins.search import search, search_youtube
from plugins.proxy import proxy
from plugins.top import top, deletedb, createdb, writes, write
from plugins.news import news
from telebot import types
from plugins.error import Error
from telebot.apihelper import ApiTelegramException

bot.remove_webhook()  # отключает вебхук

banner()  #выводим баннер

try:

    @bot.message_handler(commands=['news'])
    def new(m):
        news(m)

    #________________________________________________________________________________________________________________
    #Команда Удаления таблицы
    #________________________________________________________________________________________________________________
    @bot.message_handler(commands=['deletedb'])
    def delete_database(m):
        deletedb(m)
Example #8
0
def webhook():
    jurl = heroku_url
    bot.remove_webhook()
    bot.set_webhook(jurl + token)
    return f"Webhook set to {heroku_url}"