mirror of https://gitlab.com/ceda_ei/Nukist-Bot
Add nuke code with relevant checks.
This commit is contained in:
parent
e11a0e17aa
commit
16e6f0f720
22
bot.py
22
bot.py
|
@ -8,7 +8,27 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - \
|
|||
|
||||
|
||||
def nuke(bot, update):
|
||||
pass
|
||||
if not update.message:
|
||||
return
|
||||
m = update.message
|
||||
if m.chat.type == "private":
|
||||
text = "This bot does not work in PM."
|
||||
bot.send_message(chat_id=m.chat_id, text=text)
|
||||
return
|
||||
if not m.reply_to_message:
|
||||
text = "You need to reply to a message."
|
||||
bot.send_message(chat_id=m.chat_id, text=text)
|
||||
user = bot.get_chat_member(m.chat.id, m.from_user.id)
|
||||
if not user.can_delete_messages and user.status != "creator":
|
||||
text = ('Only admins with "Delete Messages Permission" are allowed '
|
||||
'to /nuke')
|
||||
bot.send_message(chat_id=m.chat_id, text=text)
|
||||
return
|
||||
for i in range(m.reply_to_message.message_id, m.message_id + 1):
|
||||
try:
|
||||
bot.delete_message(m.chat_id, i)
|
||||
except:
|
||||
continue
|
||||
|
||||
|
||||
updater = Updater(token=config.api_key)
|
||||
|
|
Loading…
Reference in New Issue