update python-telegram-bot API

This commit is contained in:
Davide Alberani 2021-06-12 15:08:17 +02:00
parent dc3cef7adf
commit 70f7a98092
3 changed files with 24 additions and 9 deletions

View file

@ -16,3 +16,17 @@ Requires https://github.com/jsvine/markovify
2019 - Storms provoke severe flooding on the Catalaunian Plains, Attila lays siege to the World Wide Web.
```
# License
Copyright 2019-2021 Davide Alberani <da@erlug.linux.it>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -3,7 +3,7 @@ LABEL \
maintainer="Davide Alberani <da@erlug.linux.it>"
RUN \
apk add --no-cache git python3 py3-cffi py3-six py3-requests py3-cryptography && \
apk add --no-cache git python3 py3-cffi py3-six py3-requests py3-cryptography py3-pip && \
pip3 install python-telegram-bot && \
pip3 install markovify && \
cd / && \

View file

@ -4,7 +4,7 @@
Build it with: docker build -t telegram-onthisday .
Run it with something like: docker run -ti --rm -e EVENTS_TOKEN=your-telegram-token telegram-onthisday
Copyright 2019 Davide Alberani <da@erlug.linux.it> Apache 2.0 license
Copyright 2019-2021 Davide Alberani <da@erlug.linux.it> Apache 2.0 license
"""
import os
@ -45,18 +45,19 @@ def getEvents(day=None):
return stdout
def events(bot, update, args=None):
def events(bot, update):
day = None
if args and args[0]:
day = args[0].strip()
txts = bot.message.text.split()
if len(txts) == 2:
day = txts[1]
events = getEvents(day)
logging.info('%s wants some news; serving:\n%s' % (update.message.from_user.name, events))
update.message.reply_text(events)
logging.info('%s wants some news; serving:\n%s' % (bot.effective_user.username, events))
bot.message.reply_text(events)
def about(bot, update):
logging.info('%s required more info' % update.message.from_user.name)
update.message.reply_text('See https://github.com/alberanid/onthisday\n\n/today to use the current date\n\n/date 07/30 for July 30')
logging.info('%s required more info' % bot.effective_user.username)
bot.message.reply_text('See https://github.com/alberanid/onthisday\n\n/today to use the current date\n\n/date 07/30 for July 30')
if __name__ == '__main__':