Skip to content

Commit

Permalink
Merge pull request #5 from rexdivakar/feature-addfile
Browse files Browse the repository at this point in the history
added send_image
  • Loading branch information
rexdivakar authored Oct 17, 2020
2 parents f5a9510 + c4c64fe commit d441ea8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name='notifly',
version='1.1',
version='1.1.1',
description='Telegram Bot Notifier',
long_description=long_description,
long_description_content_type='text/x-rst',
Expand Down
14 changes: 13 additions & 1 deletion telegram/notifly.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

token = '' # Token of your bot


class BotHandler:
def __init__(self, token):
self.token = token
Expand All @@ -25,8 +26,19 @@ def push_notification_msg(self, chat_id, text):
resp = requests.post(self.api_url + method, params)
return resp

def send_message(self,msg):
def send_message(self, msg):
fetch_updates = self.get_updates()
chat_id = fetch_updates[0]['message']['chat']['id']
print(chat_id)
update_id = fetch_updates[0]['update_id']
return self.push_notification_msg(chat_id=chat_id, text=msg)

def send_file(self,img_path):
fetch_updates = self.get_updates()
chat_id = fetch_updates[0]['message']['chat']['id']
method = 'sendPhoto?'+'chat_id='+str(chat_id)

files ={'photo':open(img_path, 'rb')}

resp = requests.post(self.api_url+method,files=files)

0 comments on commit d441ea8

Please sign in to comment.