Beispiel #1
0
def auto_save(bot: Bot = None, job: Job = None):
    core.save_all()
Beispiel #2
0
core.init(bot=updater.bot, job_queue=updater.job_queue, callback=auto_spin)

if config.TELESOCKET_TOKEN:
    from TeleSocketClient import TeleSocket
    updater.bot.set_webhook()
    sock = TeleSocket()
    sock.login(config.TELESOCKET_TOKEN)
    sock.add_telegram_handler(lambda update: core.read_update(updater, update))
    webhook = sock.set_webhook(updater.bot.username)
    updater._clean_updates()
    updater.bot.set_webhook(url=webhook.url, allowed_updates=ALLOWED_UPDATES)
    updater.job_queue.start()
    updater._init_thread(updater.dispatcher.start, "dispatcher")
    updater.running = True
elif config.USE_WEBHOOKS:
    updater.start_webhook(listen='0.0.0.0',
                          port=8443,
                          cert=config.WEBHOOK_CERT,
                          key=config.WEBHOOK_KEY,
                          clean=True,
                          allowed_updates=ALLOWED_UPDATES,
                          webhook_url=f'https://{config.WEBHOOK_URL}:8443')
else:
    updater.start_polling(clean=True, allowed_updates=ALLOWED_UPDATES)

log.info("Bot started")
updater.idle()

core.save_all()
log.info("Bot stopped")
Beispiel #3
0
def auto_save(bot: Bot, job: Job):
    core.save_all(chat_users, spin_name, can_change_name, results)
Beispiel #4
0
def auto_save(bot: Bot, job: Job):
    core.save_all()
Beispiel #5
0
@core.check_destination
def spin_count(bot: Bot, update: Update):
    update.message.reply_text(text="Кол-во людей, участвующих в розыгрыше: _{}_".format(len(chat_users[update.message.chat_id])),
                              parse_mode=ParseMode.MARKDOWN)


jobs.put(Job(auto_save, 60.0))
jobs.put(Job(reset, 86400.0), next_t=core.time_diff())

#handler hell
dp.add_handler(CommandHandler('start', helper))
dp.add_handler(CommandHandler('help', helper))
dp.add_handler(CommandHandler('adminF5sn', admin_refresh))
dp.add_handler(CommandHandler('sudo', admin_shell, pass_args=True, allow_edited=True))
dp.add_handler(CommandHandler('pingsn', ping))
dp.add_handler(CommandHandler('setsn', change_spin_name, pass_args=True, allow_edited=True))
dp.add_handler(CommandHandler('countsn', spin_count))
dp.add_handler(CommandHandler('spinsn', do_the_spin))
dp.add_handler(MessageHandler(Filters.status_update, svc_handler))
dp.add_handler(MessageHandler(Filters.all, update_cache, allow_edited=True), group=-1)

dp.add_error_handler(handle_error)

core.log_to_channel(updater.bot, "INFO", "Bot started")

updater.start_polling(clean=True)
updater.idle()

core.save_all(chat_users, spin_name, can_change_name, results)
core.log_to_channel(updater.bot, "INFO", "Bot stopped")