Hello community, here is the log from the commit of package python-telepot for openSUSE:Factory checked in at 2019-04-19 18:38:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-telepot (Old) and /work/SRC/openSUSE:Factory/.python-telepot.new.5536 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-telepot" Fri Apr 19 18:38:22 2019 rev:2 rq:693160 version:12.7 Changes: -------- --- /work/SRC/openSUSE:Factory/python-telepot/python-telepot.changes 2018-03-07 10:36:38.698220704 +0100 +++ /work/SRC/openSUSE:Factory/.python-telepot.new.5536/python-telepot.changes 2019-04-19 18:38:24.455186580 +0200 @@ -1,0 +2,12 @@ +Thu Apr 11 09:24:15 UTC 2019 - pgajdos@suse.com + +- version update to 12.7 + * Await `aiohttp.ClientSession.close()` + * Upgraded dependency `aiohttp>=3.0.0` + * Bot API 3.6 + * Added `parse_mode` to all methods and namedtuples supporting `caption` + * Added `supports_streaming` and `connected_website` to relevant + methods and namedtuples + * Fixed downloading through proxy in `telepot.aio.api` module + +------------------------------------------------------------------- Old: ---- v12.5.tar.gz New: ---- v12.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-telepot.spec ++++++ --- /var/tmp/diff_new_pack.yiE2kZ/_old 2019-04-19 18:38:25.015187292 +0200 +++ /var/tmp/diff_new_pack.yiE2kZ/_new 2019-04-19 18:38:25.019187297 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-telepot # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,19 +12,19 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define pyname telepot Name: python-telepot -Version: 12.5 +Version: 12.7 Release: 0 Summary: Python framework for Telegram Bot API License: MIT Group: Development/Languages/Python -Url: https://github.com/nickoala/telepot +URL: https://github.com/nickoala/telepot Source: https://github.com/nickoala/telepot/archive/v%{version}.tar.gz BuildRequires: %{python_module setuptools} BuildRequires: %{python_module urllib3 >= 1.9.1} @@ -32,10 +32,11 @@ BuildRequires: python-rpm-macros BuildRequires: python3-aiohttp >= 2.0.0 Requires: python-urllib3 >= 1.9.1 -BuildArch: noarch %ifpython3 Requires: python3-aiohttp >= 2.0.0 %endif +BuildArch: noarch + %python_subpackages %description @@ -49,9 +50,11 @@ %install %python_install - %python_expand %fdupes -s %{buildroot}%{$python_sitelib}/ +%check +# online tests + %files %{python_files} %doc CHANGELOG.md README.md %license LICENSE.md ++++++ v12.5.tar.gz -> v12.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/CHANGELOG.md new/telepot-12.7/CHANGELOG.md --- old/telepot-12.5/CHANGELOG.md 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/CHANGELOG.md 2018-05-26 18:31:52.000000000 +0200 @@ -1,5 +1,18 @@ # telepot changelog +## 12.7 (2018-05-27) + +- Await `aiohttp.ClientSession.close()` +- Upgraded dependency `aiohttp>=3.0.0` + +## 12.6 (2018-02-24) + +- Bot API 3.6 +- Added `parse_mode` to all methods and namedtuples supporting `caption` +- Added `supports_streaming` and `connected_website` to relevant methods and + namedtuples +- Fixed downloading through proxy in `telepot.aio.api` module + ## 12.5 (2017-11-28) - Bot API 3.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/README.md new/telepot-12.7/README.md --- old/telepot-12.5/README.md 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/README.md 2018-05-26 18:31:52.000000000 +0200 @@ -1,6 +1,6 @@ # telepot - Python framework for Telegram Bot API -**[Bot API 3.5](https://core.telegram.org/bots/api)**-compliant! +**[Bot API 3.6](https://core.telegram.org/bots/api)**-compliant! ### [Introduction »](http://telepot.readthedocs.io/en/latest/) ### [Reference »](http://telepot.readthedocs.io/en/latest/reference.html) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/examples/README.md new/telepot-12.7/examples/README.md --- old/telepot-12.5/examples/README.md 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/examples/README.md 2018-05-26 18:31:52.000000000 +0200 @@ -29,3 +29,7 @@ ## Payment How to handle payments. + +## Event + +Use the built-in scheduler to schedule custom events diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/examples/event/alarm.py new/telepot-12.7/examples/event/alarm.py --- old/telepot-12.5/examples/event/alarm.py 1970-01-01 01:00:00.000000000 +0100 +++ new/telepot-12.7/examples/event/alarm.py 2018-05-26 18:31:52.000000000 +0200 @@ -0,0 +1,64 @@ +import sys +import time +import telepot +from telepot.loop import MessageLoop +from telepot.delegate import per_chat_id, create_open, pave_event_space + +""" +$ python3.6 alarm.py <token> + +Send a number which indicates the delay in seconds. The bot will send you an +alarm message after such a delay. It illustrates how to use the built-in +scheduler to schedule custom events for later. + +To design a custom event, you first have to invent a *flavor*. To prevent flavors +from colliding with those of Telegram messages, events are given flavors prefixed +with `_` by convention. Then, follow these steps, which are further detailed by +comments in the code: + +1. Customize routing table so the correct function gets called on seeing the event +2. Define event-handling function +3. Provide the event spec when scheduling events +""" + +class AlarmSetter(telepot.helper.ChatHandler): + def __init__(self, *args, **kwargs): + super(AlarmSetter, self).__init__(*args, **kwargs) + + # 1. Customize the routing table: + # On seeing an event of flavor `_alarm`, call `self.on__alarm`. + # To prevent flavors from colliding with those of Telegram messages, + # events are given flavors prefixed with `_` by convention. Also by + # convention is that the event-handling function is named `on_` + # followed by flavor, leading to the double underscore. + self.router.routing_table['_alarm'] = self.on__alarm + + # 2. Define event-handling function + def on__alarm(self, event): + print(event) # see what the event object actually looks like + self.sender.sendMessage('Beep beep, time to wake up!') + + def on_chat_message(self, msg): + try: + delay = float(msg['text']) + + # 3. Schedule event + # The second argument is the event spec: a 2-tuple of (flavor, dict). + # Put any custom data in the dict. Retrieve them in the event-handling function. + self.scheduler.event_later(delay, ('_alarm', {'payload': delay})) + self.sender.sendMessage('Got it. Alarm is set at %.1f seconds from now.' % delay) + except ValueError: + self.sender.sendMessage('Not a number. No alarm set.') + + +TOKEN = sys.argv[1] + +bot = telepot.DelegatorBot(TOKEN, [ + pave_event_space()( + per_chat_id(), create_open, AlarmSetter, timeout=10), +]) +MessageLoop(bot).run_as_thread() +print('Listening ...') + +while 1: + time.sleep(10) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/examples/event/alarma.py new/telepot-12.7/examples/event/alarma.py --- old/telepot-12.5/examples/event/alarma.py 1970-01-01 01:00:00.000000000 +0100 +++ new/telepot-12.7/examples/event/alarma.py 2018-05-26 18:31:52.000000000 +0200 @@ -0,0 +1,65 @@ +import sys +import asyncio +import telepot +from telepot.aio.loop import MessageLoop +from telepot.aio.delegate import per_chat_id, create_open, pave_event_space + +""" +$ python3.6 alarma.py <token> + +Send a number which indicates the delay in seconds. The bot will send you an +alarm message after such a delay. It illustrates how to use the built-in +scheduler to schedule custom events for later. + +To design a custom event, you first have to invent a *flavor*. To prevent flavors +from colliding with those of Telegram messages, events are given flavors prefixed +with `_` by convention. Then, follow these steps, which are further detailed by +comments in the code: + +1. Customize routing table so the correct function gets called on seeing the event +2. Define event-handling function +3. Provide the event spec when scheduling events +""" + +class AlarmSetter(telepot.aio.helper.ChatHandler): + def __init__(self, *args, **kwargs): + super(AlarmSetter, self).__init__(*args, **kwargs) + + # 1. Customize the routing table: + # On seeing an event of flavor `_alarm`, call `self.on__alarm`. + # To prevent flavors from colliding with those of Telegram messages, + # events are given flavors prefixed with `_` by convention. Also by + # convention is that the event-handling function is named `on_` + # followed by flavor, leading to the double underscore. + self.router.routing_table['_alarm'] = self.on__alarm + + # 2. Define event-handling function + async def on__alarm(self, event): + print(event) # see what the event object actually looks like + await self.sender.sendMessage('Beep beep, time to wake up!') + + async def on_chat_message(self, msg): + try: + delay = float(msg['text']) + + # 3. Schedule event + # The second argument is the event spec: a 2-tuple of (flavor, dict). + # Put any custom data in the dict. Retrieve them in the event-handling function. + self.scheduler.event_later(delay, ('_alarm', {'payload': delay})) + await self.sender.sendMessage('Got it. Alarm is set at %.1f seconds from now.' % delay) + except ValueError: + await self.sender.sendMessage('Not a number. No alarm set.') + + +TOKEN = sys.argv[1] + +bot = telepot.aio.DelegatorBot(TOKEN, [ + pave_event_space()( + per_chat_id(), create_open, AlarmSetter, timeout=10), +]) + +loop = asyncio.get_event_loop() +loop.create_task(MessageLoop(bot).run_forever()) +print('Listening ...') + +loop.run_forever() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/setup.py new/telepot-12.7/setup.py --- old/telepot-12.5/setup.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/setup.py 2018-05-26 18:31:52.000000000 +0200 @@ -36,7 +36,7 @@ if PY_35: # one more dependency for Python 3.5 (async version) - install_requires += ['aiohttp>=2.0.0'] + install_requires += ['aiohttp>=3.0.0'] else: # do not copy/compile async version for older Python cmdclass['build_py'] = nocopy_async diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/telepot/__init__.py new/telepot-12.7/telepot/__init__.py --- old/telepot-12.5/telepot/__init__.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/telepot/__init__.py 2018-05-26 18:31:52.000000000 +0200 @@ -18,7 +18,7 @@ from . import exception -__version_info__ = (12, 5) +__version_info__ = (12, 7) __version__ = '.'.join(map(str, __version_info__)) @@ -520,6 +520,7 @@ def sendPhoto(self, chat_id, photo, caption=None, + parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): @@ -539,6 +540,7 @@ def sendAudio(self, chat_id, audio, caption=None, + parse_mode=None, duration=None, performer=None, title=None, @@ -555,6 +557,7 @@ def sendDocument(self, chat_id, document, caption=None, + parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): @@ -571,6 +574,8 @@ width=None, height=None, caption=None, + parse_mode=None, + supports_streaming=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): @@ -584,6 +589,7 @@ def sendVoice(self, chat_id, voice, caption=None, + parse_mode=None, duration=None, disable_notification=None, reply_to_message_id=None, @@ -883,6 +889,7 @@ def editMessageCaption(self, msg_identifier, caption=None, + parse_mode=None, reply_markup=None): """ See: https://core.telegram.org/bots/api#editmessagecaption diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/telepot/aio/__init__.py new/telepot-12.7/telepot/aio/__init__.py --- old/telepot-12.5/telepot/aio/__init__.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/telepot/aio/__init__.py 2018-05-26 18:31:52.000000000 +0200 @@ -107,6 +107,7 @@ async def sendPhoto(self, chat_id, photo, caption=None, + parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): @@ -126,6 +127,7 @@ async def sendAudio(self, chat_id, audio, caption=None, + parse_mode=None, duration=None, performer=None, title=None, @@ -142,6 +144,7 @@ async def sendDocument(self, chat_id, document, caption=None, + parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): @@ -158,6 +161,8 @@ width=None, height=None, caption=None, + parse_mode=None, + supports_streaming=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): @@ -171,6 +176,7 @@ async def sendVoice(self, chat_id, voice, caption=None, + parse_mode=None, duration=None, disable_notification=None, reply_to_message_id=None, @@ -470,6 +476,7 @@ async def editMessageCaption(self, msg_identifier, caption=None, + parse_mode=None, reply_markup=None): """ See: https://core.telegram.org/bots/api#editmessagecaption diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/telepot/aio/api.py new/telepot-12.7/telepot/aio/api.py --- old/telepot-12.5/telepot/aio/api.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/telepot/aio/api.py 2018-05-26 18:31:52.000000000 +0200 @@ -25,12 +25,22 @@ else: _proxy = (url, basic_auth) if basic_auth else (url,) -def _close_pools(): +def _proxy_kwargs(): + if _proxy is None or len(_proxy) == 0: + return {} + elif len(_proxy) == 1: + return {'proxy': _proxy[0]} + elif len(_proxy) == 2: + return {'proxy': _proxy[0], 'proxy_auth': aiohttp.BasicAuth(*_proxy[1])} + else: + raise RuntimeError("_proxy has invalid length") + +async def _close_pools(): global _pools for s in _pools.values(): - s.close() + await s.close() -atexit.register(_close_pools) +atexit.register(lambda: _loop.create_task(_close_pools())) # have to wrap async function def _create_onetime_pool(): return aiohttp.ClientSession( @@ -124,11 +134,7 @@ async def request(req, **user_kw): fn, args, kwargs, timeout, cleanup = _transform(req, **user_kw) - if _proxy: - kwargs['proxy'] = _proxy[0] - if len(_proxy) > 1: - kwargs['proxy_auth'] = aiohttp.BasicAuth(*_proxy[1]) - + kwargs.update(_proxy_kwargs()) try: if timeout is None: async with fn(*args, **kwargs) as r: @@ -146,10 +152,17 @@ raise exception.TelegramError('Connection Error', 400, {}) finally: - if cleanup: - cleanup() # e.g. closing one-time session + if cleanup: # e.g. closing one-time session + if asyncio.iscoroutinefunction(cleanup): + await cleanup() + else: + cleanup() def download(req): session = _create_onetime_pool() - return session, session.get(_fileurl(req), timeout=_timeout) + + kwargs = {} + kwargs.update(_proxy_kwargs()) + + return session, session.get(_fileurl(req), timeout=_timeout, **kwargs) # Caller should close session after download is complete diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/telepot/namedtuple.py new/telepot-12.7/telepot/namedtuple.py --- old/telepot-12.5/telepot/namedtuple.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/telepot/namedtuple.py 2018-05-26 18:31:52.000000000 +0200 @@ -478,6 +478,7 @@ _Field('pinned_message', constructor=_Message), _Field('invoice', constructor=Invoice), _Field('successful_payment', constructor=SuccessfulPayment), + 'connected_website', ]) # incoming @@ -590,6 +591,7 @@ 'title', 'description', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -605,6 +607,7 @@ 'thumb_url', 'title', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -620,6 +623,7 @@ 'thumb_url', 'title', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -633,6 +637,7 @@ 'thumb_url', 'title', 'caption', + 'parse_mode', 'video_width', 'video_height', 'video_duration', @@ -648,6 +653,7 @@ 'audio_url', 'title', 'caption', + 'parse_mode', 'performer', 'audio_duration', 'reply_markup', @@ -661,6 +667,7 @@ 'voice_url', 'title', 'caption', + 'parse_mode', 'voice_duration', 'reply_markup', 'input_message_content', @@ -672,6 +679,7 @@ 'id', 'title', 'caption', + 'parse_mode', 'document_url', 'mime_type', 'description', @@ -743,6 +751,7 @@ 'title', 'description', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -754,6 +763,7 @@ 'gif_file_id', 'title', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -765,6 +775,7 @@ 'mpeg4_file_id', 'title', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -786,6 +797,7 @@ 'document_file_id', 'description', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -798,6 +810,7 @@ 'title', 'description', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -809,6 +822,7 @@ 'voice_file_id', 'title', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -819,6 +833,7 @@ 'id', 'audio_file_id', 'caption', + 'parse_mode', 'reply_markup', 'input_message_content', ]) @@ -828,6 +843,7 @@ _Field('type', default='photo'), 'media', 'caption', + 'parse_mode', ]) # outgoing @@ -835,9 +851,11 @@ _Field('type', default='video'), 'media', 'caption', + 'parse_mode', 'width', 'height', 'duration', + 'supports_streaming', ]) # incoming diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/test/test27_send.py new/telepot-12.7/test/test27_send.py --- old/telepot-12.5/test/test27_send.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/test/test27_send.py 2018-05-26 18:31:52.000000000 +0200 @@ -126,7 +126,7 @@ bot.sendPhoto(chat_id, file_id, caption='Show original message and keyboard', reply_to_message_id=msg_id, reply_markup=nt_show_keyboard) time.sleep(0.5) - bot.sendPhoto(chat_id, file_id, caption='Hide keyboard', reply_markup=remove_keyboard) + bot.sendPhoto(chat_id, file_id, caption='_Hide keyboard_', parse_mode='Markdown', reply_markup=remove_keyboard) time.sleep(0.5) furl = urllib2.urlopen('http://i.imgur.com/35HSRQ6.png') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/test/test3_send.py new/telepot-12.7/test/test3_send.py --- old/telepot-12.5/test/test3_send.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/test/test3_send.py 2018-05-26 18:31:52.000000000 +0200 @@ -124,7 +124,7 @@ bot.sendPhoto(chat_id, file_id, caption='Show original message and keyboard', reply_to_message_id=msg_id, reply_markup=nt_show_keyboard) time.sleep(0.5) - bot.sendPhoto(chat_id, file_id, caption='Hide keyboard', reply_markup=remove_keyboard) + bot.sendPhoto(chat_id, file_id, caption='_Hide keyboard_', parse_mode='Markdown', reply_markup=remove_keyboard) time.sleep(0.5) furl = urllib.request.urlopen('http://i.imgur.com/35HSRQ6.png') @@ -365,6 +365,9 @@ TOKEN = sys.argv[1] USER_ID = int(sys.argv[2]) +# Edit /etc/tinyproxy/tinyproxy.conf to allow access +# telepot.api.set_proxy('http://192.168.0.103:8888') + bot = telepot.Bot(TOKEN) test_webhook_getupdates_exclusive() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/telepot-12.5/test/test3a_send_updates.py new/telepot-12.7/test/test3a_send_updates.py --- old/telepot-12.5/test/test3a_send_updates.py 2017-11-28 10:01:11.000000000 +0100 +++ new/telepot-12.7/test/test3a_send_updates.py 2018-05-26 18:31:52.000000000 +0200 @@ -101,7 +101,7 @@ await bot.sendPhoto(chat_id, file_id, caption='Show original message and keyboard', reply_to_message_id=msg_id, reply_markup=nt_show_keyboard) - await bot.sendPhoto(chat_id, file_id, caption='Hide keyboard', reply_markup=remove_keyboard) + await bot.sendPhoto(chat_id, file_id, caption='_Hide keyboard_', parse_mode='Markdown', reply_markup=remove_keyboard) async with aiohttp.ClientSession() as session: async with session.get('http://i.imgur.com/35HSRQ6.png') as r: @@ -328,6 +328,9 @@ TOKEN = sys.argv[1] USER_ID = int(sys.argv[2]) +# Edit /etc/tinyproxy/tinyproxy.conf to allow access +# telepot.aio.api.set_proxy('http://192.168.0.104:8888') + bot = telepot.aio.Bot(TOKEN) loop = asyncio.get_event_loop()