limit users for channel helper
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user