amanoteam / amanobot Goto Github PK
View Code? Open in Web Editor NEWPython framework for Telegram Bot API forked from Telepot.
Home Page: https://amanobot.readthedocs.io
License: MIT License
Python framework for Telegram Bot API forked from Telepot.
Home Page: https://amanobot.readthedocs.io
License: MIT License
Hello,
Every time I start my bot it fetches all the messages from the telegram API queue. Is there a way to get only the messages from when the bot is started on?
For now the code to start the bot looks like this:
bot = amanobot.aio.DelegatorBot(TOKEN, [
pave_event_space()(
per_chat_id(), create_open, MessageHandler, timeout=20),
])
loop = asyncio.get_event_loop()
loop.create_task(MessageLoop(bot).run_forever())
loop.run_forever()
And I would like to add an option to handle only the newest messages. Thanks in advance for the support!
It was added the field "my_chat_member" and "chat_member" in the chat messages, so it's occuring the error:
Traceback (most recent call last): File "/home/XXXX/.asdf/installs/python/3.8.0/lib/python3.8/site-packages/amanobot/loop.py", line 70, in run_forever self._update_handler(update) File "/home/XXXX/.asdf/installs/python/3.8.0/lib/python3.8/site-packages/amanobot/loop.py", line 159, in <lambda> collectloop.input_queue.put(_extract_message(update)[1])) File "/home/XXXX/.asdf/installs/python/3.8.0/lib/python3.8/site-packages/amanobot/loop.py", line 107, in _extract_message key = _find_first_key(update, ['message', File "/home/XXXX/.asdf/installs/python/3.8.0/lib/python3.8/site-packages/amanobot/__init__.py", line 72, in _find_first_key raise KeyError('No suggested keys %s in %s' % (str(keys), str(d))) KeyError: "No suggested keys ['message', 'edited_message', 'poll', 'channel_post', 'edited_channel_post', 'callback_query', 'inline_query', 'chosen_inline_result', 'shipping_query', 'pre_checkout_query'] in {'update_id': 000000002, 'my_chat_member': {'chat': {'id': 0000000000, 'first_name': 'FIRSTNAME', 'username': 'USERNAME', 'type': 'private'}, 'actor': {'id': 0000000000, 'is_bot': False, 'first_name': 'FIRSTNAME', 'username': 'USERNAME'}, 'date': 1615254657, 'old_chat_member': {'user': {'id': 0000000001, 'is_bot': True, 'first_name': 'BOTNAME', 'username': 'BOTUSERNAME'}, 'status': 'member'}, 'new_chat_member': {'user': {'id': 0000000001, 'is_bot': True, 'first_name': 'BOTNAME', 'username': 'BOTUSERNAME'}, 'status': 'kicked', 'until_date': 0}}}"
It's needed to change the suggested keys.
Looks like there are breaking changes for chat_member
and UUIDs =]
Since master
branch supports newer bot API, would be good to publish it as a release too
Might also be good to update doco (as there are things like ChatMemberUpdated to be added to doco).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.