|
|
|
@ -6,21 +6,21 @@ from telegram.error import Unauthorized, TelegramError
|
|
|
|
|
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
|
|
|
|
|
from telegram import Message, Update
|
|
|
|
|
|
|
|
|
|
import config
|
|
|
|
|
from models import Subscriber
|
|
|
|
|
|
|
|
|
|
queue = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def go_away(bot, update: Update):
|
|
|
|
|
Subscriber(user_id=str(update.message.chat_id))
|
|
|
|
|
update.message.reply_text('Вы были добавлены')
|
|
|
|
|
# update.message.reply_text('Пожалуйста, обратитесь к @lono_contactbot')
|
|
|
|
|
# Subscriber(user_id=str(update.message.chat_id))
|
|
|
|
|
# update.message.reply_text('Вы были добавлены')
|
|
|
|
|
update.message.reply_text('Пожалуйста, обратитесь к @lono_contactbot')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def unsubscribe(bot, update: Update):
|
|
|
|
|
Subscriber.deleteBy(user_id=str(update.message.chat_id))
|
|
|
|
|
update.message.reply_text('Вы были отписаны от бота. Обратитесь к @lono_contactbot за добавлением обратно.')
|
|
|
|
|
# update.message.reply_text('Пожалуйста, обратитесь к @lono_contactbot')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def msg(bot, update: Update):
|
|
|
|
@ -34,9 +34,9 @@ def task_queue(bot, job):
|
|
|
|
|
current_chat = str(m.chat_id)
|
|
|
|
|
uids = set(s.user_id for s in Subscriber.select())
|
|
|
|
|
if current_chat not in uids:
|
|
|
|
|
# return m.reply_text('Пожалуйста, обратитесь к @lono_contactbot')
|
|
|
|
|
Subscriber(user_id=current_chat)
|
|
|
|
|
m.reply_text('Вы были добавлены')
|
|
|
|
|
return m.reply_text('Пожалуйста, обратитесь к @lono_contactbot')
|
|
|
|
|
# Subscriber(user_id=current_chat)
|
|
|
|
|
# m.reply_text('Вы были добавлены')
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
uids.remove(current_chat)
|
|
|
|
@ -90,7 +90,7 @@ def task_queue(bot, job):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updater = Updater('450146961:AAGt5QRp3jS5wcHVIZOLxmqyO55iOVf6gpY', workers=4)
|
|
|
|
|
updater = Updater(config.BOT_TOKEN, workers=4)
|
|
|
|
|
updater.job_queue.run_repeating(task_queue, .04)
|
|
|
|
|
|
|
|
|
|
updater.dispatcher.add_handler(CommandHandler('start', go_away))
|
|
|
|
|