forked from Micha854/TeamRocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear.py
34 lines (32 loc) · 1 KB
/
clear.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import telebot
class Clear():
def clear(self,token,chatID,filename):
bot = telebot.TeleBot(token)
oldMessages =""
try:
f = open(filename+"output.txt", "r")
oldMessages = f.read()
f.close()
oldMessages = oldMessages[1:len(oldMessages)-1]
oldMessages = oldMessages.split(', ')
for messageID in oldMessages:
print("Nachrichten ID: "+messageID)
try:
bot.delete_message(chatID,message_id=messageID)
except:
print("Nachricht konnte nicht entfernt werden")
except:
print("File nicht gefunden")
try:
f = open(filename+"boss-output.txt", "r")
oldMessages = f.read()
f.close()
oldMessages = oldMessages[1:len(oldMessages)-1]
oldMessages = oldMessages.split(', ')
for messageID in oldMessages:
try:
bot.delete_message(chatID,message_id=messageID)
except:
print("Nachricht konnte nicht entfernt werden")
except:
print("File nicht gefunden")