Skip to content

Commit

Permalink
#281 - add telegram() to send notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
kensoh committed Jul 18, 2021
1 parent 8d67f07 commit 1dcbb98
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rpa_package/rpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Apache License 2.0, Copyright 2019 Tebel.Automation Private Limited
# https://github.com/tebelorg/RPA-Python/blob/master/LICENSE.txt
__author__ = 'Ken Soh <opensource@tebel.org>'
__version__ = '1.41.0'
__version__ = '1.42.0'

# for backward compatibility, invoke tagui.py functions to use in rpa.py
from tagui import *
4 changes: 2 additions & 2 deletions rpa_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

setup(
name='rpa',
version='1.41.0',
py_modules=['rpa'], install_requires=['tagui>=1.41.0'],
version='1.42.0',
py_modules=['rpa'], install_requires=['tagui>=1.42.0'],
author='Ken Soh',
author_email='opensource@tebel.org',
license='Apache License 2.0',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='tagui',
version='1.41.0',
version='1.42.0',
py_modules=['tagui'],
author='Ken Soh',
author_email='opensource@tebel.org',
Expand Down
29 changes: 28 additions & 1 deletion tagui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Apache License 2.0, Copyright 2019 Tebel.Automation Private Limited
# https://github.com/tebelorg/RPA-Python/blob/master/LICENSE.txt
__author__ = 'Ken Soh <opensource@tebel.org>'
__version__ = '1.41.0'
__version__ = '1.42.0'

import subprocess
import os
Expand Down Expand Up @@ -1230,6 +1230,33 @@ def ask(text_to_prompt = ''):
else:
return input(text_to_prompt + space_padding)

def telegram(telegram_id = None, text_to_send = None):
if telegram_id is None or telegram_id == '':
print('[RPA][ERROR] - Telegram ID missing for telegram()')
return False

if text_to_send is None or text_to_send == '':
print('[RPA][ERROR] - text message missing for telegram()')
return False

# in case number is given instead of string
telegram_id = str(telegram_id)

telegram_endpoint = 'https://tebel.org/rpapybot'
telegram_params = {'chat_id': telegram_id, 'text': text_to_send}

if _python2_env():
import json; import urllib
telegram_endpoint = telegram_endpoint + '/sendMessage.php?' + urllib.urlencode(telegram_params)
telegram_response = urllib.urlopen(telegram_endpoint).read()
return json.loads(telegram_response)['ok']

else:
import json; import urllib.request; import urllib.parse
telegram_endpoint = telegram_endpoint + '/sendMessage.php?' + urllib.parse.urlencode(telegram_params)
telegram_response = urllib.request.urlopen(telegram_endpoint).read()
return json.loads(telegram_response)['ok']

def keyboard(keys_and_modifiers = None):
if not _started():
print('[RPA][ERROR] - use init() before using keyboard()')
Expand Down

0 comments on commit 1dcbb98

Please sign in to comment.