update python-telegram-bot API
This commit is contained in:
parent
94ab4bed13
commit
1875ba2f7b
3 changed files with 16 additions and 10 deletions
|
@ -41,7 +41,7 @@ You can use the content of the *mastodon-bot* directory to create your own Masto
|
|||
|
||||
# License
|
||||
|
||||
Copyright 2003-2018 Davide Alberani <da@erlug.linux.it>
|
||||
Copyright 2003-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.
|
||||
|
|
|
@ -9,6 +9,8 @@ RUN \
|
|||
git clone https://github.com/alberanid/fortunes-spam.git
|
||||
COPY fortunes-spam-bot.py /fortunes-spam
|
||||
|
||||
VOLUME /fortunes
|
||||
|
||||
WORKDIR /fortunes-spam
|
||||
|
||||
ENTRYPOINT ["python3", "fortunes-spam-bot.py"]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Build it with: docker build -t fortunes-spam-bot .
|
||||
Run it with something like: docker run -ti --rm -e SPAMBOT_TOKEN=your-telegram-token fortunes-spam-bot
|
||||
|
||||
Copyright 2018 Davide Alberani <da@erlug.linux.it> Apache 2.0 license
|
||||
Copyright 2018-2021 Davide Alberani <da@erlug.linux.it> Apache 2.0 license
|
||||
"""
|
||||
|
||||
import os
|
||||
|
@ -17,8 +17,12 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
EXTERNAL_VOL = '/fortunes'
|
||||
|
||||
def getSpam(section):
|
||||
extPath = os.path.join(EXTERNAL_VOL, section)
|
||||
if os.path.isfile(extPath):
|
||||
section = extPath
|
||||
cmd = ['fortune', '-o', section]
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
|
@ -35,22 +39,22 @@ def getSpam(section):
|
|||
return stdout
|
||||
|
||||
|
||||
def serve(section, bot, update):
|
||||
def serve(section, update, context):
|
||||
spam = getSpam(section)
|
||||
logging.info('%s wants some spam; serving:\n%s' % (update.message.from_user.name, spam))
|
||||
logging.info('%s wants some spam; serving:\n%s' % (update.effective_user.username, spam))
|
||||
update.message.reply_text(spam)
|
||||
|
||||
|
||||
def en(bot, update):
|
||||
return serve('spam-o', bot, update)
|
||||
def en(update, context):
|
||||
return serve('spam-o', update, context)
|
||||
|
||||
|
||||
def it(bot, update):
|
||||
return serve('spam-ita-o', bot, update)
|
||||
def it(update, context):
|
||||
return serve('spam-ita-o', update, context)
|
||||
|
||||
|
||||
def about(bot, update):
|
||||
logging.info('%s required more info' % update.message.from_user.name)
|
||||
def about(update, context):
|
||||
logging.info('%s required more info' % update.effective_user.username)
|
||||
update.message.reply_text('See https://github.com/alberanid/fortunes-spam')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue