Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import telebot
- import config
- import db
- import bot_code
- # Инициализация API и СУБД
- bot = telebot.TeleBot(config.TOKEN, skip_pending=True)
- bot_code.bot = bot
- db.init_db(config.FORCE_DB)
- # Обработка Inline клавиш
- @bot.callback_query_handler(func=lambda call: True)
- def callback_inline(call):
- bot_code.callback_inline(call)
- # TODO: изменить текст
- @bot.message_handler(commands=['start'])
- def command_start(message):
- bot_code.start_command_handler(message)
- # TODO: изменить текст
- @bot.shipping_query_handler(func=lambda query: True)
- def payment_error_server(shipping_query):
- bot_code.payment_error_server(shipping_query)
- # TODO: изменить текст
- @bot.pre_checkout_query_handler(func=lambda query: True)
- def payment_error_bot(pre_checkout_query):
- bot_code.payment_error_bot(pre_checkout_query)
- @bot.message_handler(content_types=['successful_payment'])
- def payment_success(message):
- print(message.successful_payment)
- print()
- print(message)
- bot_code.payment_success(message)
- """
- @bot.channel_post_handler(content_types=['text'])
- def channel_post_handler(message):
- bot_code.channel_post_handler(bot, message)
- """
- # TODO: доработать
- @bot.message_handler(content_types=['text'])
- def text_handler(message):
- if message.text.lower() in config.WORDS['account_text']:
- bot_code.subscribe_handler(message, account=True)
- elif message.text.lower() in config.WORDS['subscribe_text']:
- bot_code.subscribe_handler(message, account=False)
- elif message.text.lower() in config.WORDS['add_channel']:
- bot_code.add_channel_handler(message)
- elif message.text.lower() in config.WORDS['create_post_riddle']:
- bot_code.create_post_handler(message)
- elif message.text.lower() in config.WORDS['create_post_surwey']:
- bot_code.create_post_handler(message, surwey=True, buttons=False)
- elif message.text.lower() == 'пересоздать бд' and message.from_user.id in config.OWNER:
- db.init_db(force=True)
- bot.send_message(message.chat.id,
- 'База данных очищена! 🎉',
- reply_markup=config.standart_markup(),
- parse_mode='HTML'
- )
- elif message.text.lower().startswith(config.WORDS['gift']) and message.from_user.id in config.OWNER:
- bot_code.send_gift(message)
- elif message.text.lower().startswith(config.WORDS['mailing']) and message.from_user.id in config.OWNER:
- if message.photo:
- bot_code.mailing(message.chat.id,
- message.text,
- message.photo[-1].file_id
- )
- elif message.video:
- bot_code.mailing(message.chat.id,
- message.text,
- message.video[-1].file_id
- )
- elif message.document:
- bot_code.mailing(message.chat.id,
- message.text,
- message.document[-1].file_id
- )
- else:
- bot.send_message(message.chat.id,
- config.WORDS['sorry'], reply_markup=config.standart_markup(), parse_mode='HTML'
- )
- if __name__ == '__main__':
- #bot_code.channel_timer()
- bot.polling()
- #bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment