Skip to content

Commit

Permalink
Update telegram.py to add a delete method
Browse files Browse the repository at this point in the history
Add an option for delete bar message with the deleteMessage method in Bot API.
  • Loading branch information
raulsaavedr committed Jun 19, 2021
1 parent c1ec3b1 commit f1071d7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tqdm/contrib/telegram.py
Expand Up @@ -62,6 +62,19 @@ def write(self, s):
else:
return future

def delete(self):
try:
res = self.submit(
self.session.post,
self.API + '%s/deleteMessage' % self.token,
data=dict(
chat_id=self.chat_id,
message_id=self.message_id))
except Exception as e:
tqdm_auto.write(str(e))
else:
return res


class tqdm_telegram(tqdm_auto):
"""
Expand Down Expand Up @@ -112,6 +125,9 @@ def clear(self, *args, **kwargs):
if not self.disable:
self.tgio.write("")

def delete(self):
self.tgio.delete()


def ttgrange(*args, **kwargs):
"""
Expand Down

0 comments on commit f1071d7

Please sign in to comment.