add dump command

This commit is contained in:
bakatrouble 2025-03-15 22:21:42 +03:00
parent eaeb631be3
commit 6520e9ef50

View File

@ -223,7 +223,7 @@ class ChannelHelperBotModuleConfig(TelegramBotModuleConfig):
update.effective_message.reply_text('GTFO') update.effective_message.reply_text('GTFO')
return return
update.effective_message.reply_document( update.effective_message.reply_document(
BytesIO(json.dumps(list(QueuedItem.objects.filter(config=self).values()), indent=2).encode()), BytesIO(json.dumps(list(qi.__json__() for qi in QueuedItem.objects.filter(config=self)), indent=2).encode()),
filename='dump.json', filename='dump.json',
) )
@ -251,6 +251,17 @@ class QueuedItem(models.Model):
processed = models.BooleanField(default=False) processed = models.BooleanField(default=False)
datetime = models.DateTimeField(auto_now_add=True) datetime = models.DateTimeField(auto_now_add=True)
def __json__(self):
return {
'type': self.type,
'args': self.args,
'message_id': self.message_id,
'message_ids_extra': self.message_ids_extra,
'image_hash': self.image_hash,
'processed': self.processed,
'datetime': self.datetime.isoformat(),
}
def send(self, bot: Bot): def send(self, bot: Bot):
if self.type == 'photo' and self.config.should_send_photo_group(): if self.type == 'photo' and self.config.should_send_photo_group():
items = [self] + list(self.config.get_additional_images(self.pk)) items = [self] + list(self.config.get_additional_images(self.pk))