Delete message with /epiphony command

This commit is contained in:
bursa-pastoris 2023-05-30 04:12:24 +02:00
parent bbc7c08ac0
commit 85577dd8b9
1 changed files with 10 additions and 1 deletions

View File

@ -32,7 +32,7 @@ import Levenshtein
import psutil
from rolldice import roll_dice, rolldice
from telegram import BotCommand
from telegram.constants import ChatAction, ChatType, ParseMode
from telegram.constants import ChatAction, ChatMemberStatus, ChatType, ParseMode
from constants import *
@ -391,6 +391,15 @@ async def epiphony(update, context):
voice=open(voice_file,'rb'),
reply_to_message_id=update.effective_message.reply_to_message.message_id
if update.effective_message.reply_to_message else None)
bot_data = await context.bot.get_me()
bot_chatmember = await context.bot.get_chat_member(
chat_id=update.effective_chat.id,
user_id=bot_data.id)
if (bot_chatmember.status == ChatMemberStatus.ADMINISTRATOR
and bot_chatmember.can_delete_messages):
await context.bot.delete_message(
chat_id=update.effective_chat.id,
message_id=update.effective_message.message_id)
async def roll(update, context):