limit users for channel helper

This commit is contained in:
2020-05-05 11:47:40 +03:00
parent 89e839d36f
commit 203efae85d
2 changed files with 39 additions and 0 deletions

View File

@@ -16,9 +16,18 @@ from djconfig import config
from bots.models import TelegramBotModuleConfig
class ChannelHelperUser(models.Model):
name = models.CharField(max_length=32)
user_id = models.BigIntegerField(db_index=True)
def __str__(self):
return self.name
class ChannelHelperBotModuleConfig(TelegramBotModuleConfig):
chat_id = models.CharField(max_length=32)
queued = models.BooleanField(default=False)
users = models.ManyToManyField(ChannelHelperUser)
MODULE_NAME = 'Channel helper'
@@ -64,6 +73,10 @@ class ChannelHelperBotModuleConfig(TelegramBotModuleConfig):
i.delete()
def handle_message(self, update: Update, ctx: CallbackContext):
if self.users.count() and not self.users.filter(user_id=update.effective_user.id).count():
update.effective_message.reply_text('GTFO')
return
m = update.effective_message
bot = ctx.bot
i = QueuedItem(config=self)