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:
authordiSabler <dissy@ya.ru>2020-03-18 18:10:00 +0300
committerdiSabler <dissy@ya.ru>2020-03-18 18:10:00 +0300
commitfcb6d163456571ca87b67561d280342440a6dfd4 (patch)
tree2b6beb304234baeac9f6278608a6b2e5f04f981b
parentdc92a1144cb94ef4f0039e505c534c81544c8631 (diff)
add: yandex currency rate
-rw-r--r--.gitignore1
-rwxr-xr-xkernel.py4
-rw-r--r--plugins/yandexcurrency.py52
3 files changed, 55 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index e6545b9..1b4ff6d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -97,5 +97,6 @@ desktop.ini
data/chatlog/-[0-9]*
data/chatlog/[0-9]*
+data/chatlog/*@*
# The end is near!
diff --git a/kernel.py b/kernel.py
index 9b67ffc..6717d63 100755
--- a/kernel.py
+++ b/kernel.py
@@ -346,7 +346,7 @@ def get_os_version():
else:
isidaOs = 'unknown'
return isidaOs
-
+
# Get color by name on Linux
def get_color(c):
color = os.environ.has_key('TERM')
@@ -504,7 +504,7 @@ def send_document(raw_in, document, custom={}):
FLS = {}
else:
MSG = { 'chat_id': raw_in['message']['chat'].get('id', '') }
- FLS = {'document': (document, open(document, "rb"))}
+ FLS = {'document': (document, open(document, "rb"))}
MSG.update(custom)
return send_raw(raw_in, 'sendDocument', MSG, FLS)
diff --git a/plugins/yandexcurrency.py b/plugins/yandexcurrency.py
new file mode 100644
index 0000000..98c5589
--- /dev/null
+++ b/plugins/yandexcurrency.py
@@ -0,0 +1,52 @@
+ο»Ώ#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# --------------------------------------------------------------------------- #
+# #
+# iSida bot VI plugin #
+# Copyright (C) VitaliyS <hetleven@yandex.ua> #
+# Copyright (C) diSabler <dsy@dsy.name> #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+# --------------------------------------------------------------------------- #
+
+def cmd_yandex_currency(raw_in):
+ try:
+ import ssl
+ ssl._create_default_https_context = ssl._create_unverified_context
+ data = requests.get('https://yandex.ru').content
+ regexp = '''
+ <span class="inline-stocks__value_inner">(.*?)</span></span><span.*?>(.*?)</span>\
+ .*?<span class="inline-stocks__value_inner">(.*?)</span></span><span.*?>(.*?)</span>\
+ .*?<span class="inline-stocks__value_inner">(.*?)</span></span><span.*?>(.*?)<span
+ '''.replace('\t', '').replace('\n', '').strip()
+ res = re.findall(regexp , data)
+ r = [res[0][t:t+2] for t in xrange(0, len(res[0]), 2)]
+ print 4
+ msg = '<b>Yandex exchange rates</b><pre>'
+ icons = [['USD', 'πŸ‡ΊπŸ‡Έ'], ['EUR', 'πŸ‡«πŸ‡²'], ['OIL', 'πŸ›’']]
+ for n, i in enumerate(icons):
+ print n, i
+ msg += '\n%s %-7s %-7s %s' % (i[1], i[0], r[n][0].replace(',', '.'), r[n][1].replace(',', '.'))
+ msg += '</pre>'
+ print 5
+ except:
+ raise
+ msg = 'Ooops! The market collapsed, the salary will not be!'
+ send_msg(raw_in, msg)
+
+commands = [['ycurr', cmd_yandex_currency, False, 'raw', 'Yandex exchange rate']]
+
+# The end is near!