Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/isida/vi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaliyS <hetleven@yandex.ua>2017-03-18 16:59:17 +0300
committerVitaliyS <hetleven@yandex.ua>2017-03-18 16:59:17 +0300
commit54fa663954efb0774e6faad2b2c79da5bae8f69e (patch)
treee1664de70e3482dd9e27d1d686a17f1201258e80 /kernel.py
parenta89086fa8d4bb722d5212121d30bccc8d3a7cb5d (diff)
upd: oboobs plugin
Diffstat (limited to 'kernel.py')
-rw-r--r--kernel.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel.py b/kernel.py
index 2477b1b..b7f6088 100644
--- a/kernel.py
+++ b/kernel.py
@@ -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)