diff options
author | VitaliyS <hetleven@yandex.ua> | 2017-03-18 16:59:17 +0300 |
---|---|---|
committer | VitaliyS <hetleven@yandex.ua> | 2017-03-18 16:59:17 +0300 |
commit | 54fa663954efb0774e6faad2b2c79da5bae8f69e (patch) | |
tree | e1664de70e3482dd9e27d1d686a17f1201258e80 /kernel.py | |
parent | a89086fa8d4bb722d5212121d30bccc8d3a7cb5d (diff) |
upd: oboobs plugin
Diffstat (limited to 'kernel.py')
-rw-r--r-- | kernel.py | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -479,15 +479,25 @@ def send_msg(raw_in, msg, parse_mode = 'HTML', custom={}): # Send photo
def send_photo(raw_in, photo, custom={}):
- MSG = { 'chat_id': raw_in['message']['chat'].get('id', '') }
- FLS = {'photo': (photo, open(photo, "rb"))}
+ if re.match('https?://.*\.(jpe?g|png|gif)$', photo.lower()):
+ MSG = { 'chat_id': raw_in['message']['chat'].get('id', ''),
+ 'photo': photo }
+ FLS = {}
+ else:
+ MSG = { 'chat_id': raw_in['message']['chat'].get('id', '') }
+ FLS = {'photo': (photo, open(photo, "rb"))}
MSG.update(custom)
return send_raw(raw_in, 'sendPhoto', MSG, FLS)
# Send document
def send_document(raw_in, document, custom={}):
- MSG = { 'chat_id': raw_in['message']['chat'].get('id', '') }
- FLS = {'document': (document, open(document, "rb"))}
+ if re.match('https?://.*\.(pdf|zip|gif)$', document.lower()):
+ MSG = { 'chat_id': raw_in['message']['chat'].get('id', ''),
+ 'document': document }
+ FLS = {}
+ else:
+ MSG = { 'chat_id': raw_in['message']['chat'].get('id', '') }
+ FLS = {'document': (document, open(document, "rb"))}
MSG.update(custom)
return send_raw(raw_in, 'sendDocument', MSG, FLS)
|