torgeirl / tradingpost-errbot Goto Github PK
View Code? Open in Web Editor NEWBot for Slack that fetches Magic: the Gathering card pictures, oracle texts, prices and flavor texts on request
License: MIT License
Bot for Slack that fetches Magic: the Gathering card pictures, oracle texts, prices and flavor texts on request
License: MIT License
Randomization tasks was moved to another plugin in 7d2b9af, but it currently has to be installed manully:
!repos install https://github.com/torgeirl/random-errbot.git
Installing https://github.com/torgeirl/random-errbot.git...
A new plugin repository has been installed correctly from https://github.com/torgeirl/random-errbot.git.
Refreshing the plugins commands...
Plugins reloaded.
!card
command doesn't work for DFCs in Zendikar Rising (ZNR). !oracle
works for the same cards, and !card
works for last DFC in boosters before that (Nicol Bolas, the Ravager) and the original DFCs from ISD block:
INFO errbot.plugins.ACLs Matching ACL {} against username @torgeirl for command Tradingpost:card.
INFO errbot.core Processing command "card" with parameters "Umara Wizard" from @torgeirl
INFO errbot.plugins.tradingpost Connecting to https://api.scryfall.com
ERROR errbot.core An error happened while processing a message ("!card Umara Wizard"): Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/errbot/core.py", line 477, in _execute_and_send
reply = method(msg, match) if match else method(msg, args)
File "/app/plugins/tradingpost-errbot/tradingpost.py", line 39, in card
image=card['image_uris']['normal'],
KeyError: 'image_uris'
"
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/errbot/core.py", line 477, in _execute_and_send
reply = method(msg, match) if match else method(msg, args)
File "/app/plugins/tradingpost-errbot/tradingpost.py", line 39, in card
image=card['image_uris']['normal'],
KeyError: 'image_uris'
INFO errbot.plugins.ACLs Matching ACL {} against username @torgeirl for command Tradingpost:card.
INFO errbot.core Processing command "card" with parameters "huntmaster of the fells" from @torgeirl
Could be related to the API changes to Scryfall image URIs and download URIs in August.
If possible, we should provide text arguments along with the image responses of !card
and !sutcliffe
:
Warning from the execution of !card
:
/usr/local/lib/python3.10/site-packages/slack_sdk/web/internal_utils.py:258: UserWarning: The top-level `text` argument is missing in the request payload for a chat.postMessage call - It's a best practice to always provide a `text` argument when posting a message. The `text` argument is used in places where content cannot be rendered such as: system push notifications, assistive technology such as screen readers, etc.
warnings.warn(message, UserWarning)
After switching to the new SlackRTM backend in 644b41c, the!sutcliffe
command still doesn't work:
An error happened while processing a message ("!sutcliffe Rampant Growth (M12) / Cultivate"):
(...)
slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'method_deprecated', 'response_metadata': {'messages': ['[ERROR] This method is retired and can no longer be used. Please use conversations.list or users.conversations instead. Learn more: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api.']}}
We didn't want to use Github Packages in July since it didn't offer non-authorized pulls.
That changed on September 1, with the introduction to Github Container Registry. It would be nice to remove Docker Hub from the project's workflow.
Seems to have been introduced after the bot got containerized (issue #12):
TORGEIRL 09:16
!uptime
TRADINGPOST 09:16
I've been up for 37 hours and 23 minutes (since Monday, Aug 31 at 17:53).
I've been up for 37 hours and 23 minutes (since Monday, Aug 31 at 17:53).
I've been up for 37 hours and 23 minutes (since Monday, Aug 31 at 17:53).
I've been up for 37 hours and 23 minutes (since Monday, Aug 31 at 17:53).
I've been up for 37 hours and 23 minutes (since Monday, Aug 31 at 17:53).
Trading Post has been prepared for the changes coming to Slack's rtm.start
API method in September with Errbot's new SlackV3
backend. However, Slack have been asking us to migrate away from the RTM API for a while now:
While the RTM API will remain unchanged, we do encourage you to migrate to modern Slack apps and Socket Mode instead.
Luckily, the new Errbot backend also supports more modern integration methods such as Slack apps and Socket Mode so it shouldn't require too much work.
The current mana emojis doesn't follow some standard, making the first time setup time consuming. We could instead switch to supporting Scryfall's Manamoji repo, the de facto standard for mana emojis.
It would also make it easy to switch between our and Scryfall's Slack bots, or run them together.
Errbot 6.0.0 was released yesterday. They dropped support for Python 3.5 so the upgrade to 3.7 I long have delayed needs to come soon, and might require some adjustments.
I hope the fix to dependency handling for Docker installations also solved issue #3 ๐ค
The !standard
command (issue #20) no longer works. The backend seems OK and isn't deprecated, but for some reason it no longer is able to calculate the Standard dates:
2021-10-13 12:39:18,618 INFO errbot.plugins.ACLs Matching ACL {} against username @torgeirl for command Tradingpost:standard.
2021-10-13 12:39:18,618 INFO errbot.core Processing command "standard" with parameters "" from @torgeirl
2021-10-13 12:39:18,619 INFO errbot.plugins.tradingpost Connecting to https://whatsinstandard.com
2021-10-13 12:39:18,928 ERROR errbot.core An error happened while processing a message ("!standard"): Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/errbot/core.py", line 555, in _execute_and_send
reply = method(msg, match) if match else method(msg, args)
File "/app/plugins/tradingpost-errbot/tradingpost.py", line 158, in standard
enter_date = datetime.strptime(set['enterDate']['exact'], rfc3339).date()
TypeError: strptime() argument 1 must be str, not None
"
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/errbot/core.py", line 555, in _execute_and_send
reply = method(msg, match) if match else method(msg, args)
File "/app/plugins/tradingpost-errbot/tradingpost.py", line 158, in standard
enter_date = datetime.strptime(set['enterDate']['exact'], rfc3339).date()
TypeError: strptime() argument 1 must be str, not None
The Errbot backend switch from Slack
to SlackV3
in we did in January has made it impossible to set more than one bot admin.
It seems the issue is caused by some problem with ACL matching multiple Slack user IDs. SlackV3 issue: errbotio/err-backend-slackv3#63
Update: the issue predate the backend switch, and is now solved.
Add a command that prints sets legal in Standard and banned cards using the whatsinstandard API.
Submodule changes has to be fetched manually using the following command:
$ git submodule update --remote
Perhaps there's something wrong with the .gitmodule
setup?
Edit: this seems to requires updates to the Github Action workflows for both repositories.
If you write a bot command in reply to a Slack message (thread), the bot currently sends the answer to the channel for some of the commands:
!card
(using Errbot's send_card
)Slackv3
v0.2.1 (October 3, 2022) โ๏ธ!sutcliffe
(using Errbot's send_stream_request
)HTTPSConnectionPool(host='www.wizards.com', port=443): Max retries exceeded with url: /Magic/PlaneswalkerPoints/JavaScript/GetPointsHistoryModal (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))
Showstoppers like the following should be caught by tests:
$ microk8s.kubectl logs tradingpost-deployment-59886df5b9-5dfrx
2020-10-18 06:34:49,189 INFO errbot.bootstrap Found Storage plugin: Shelf.
2020-10-18 06:34:49,197 INFO errbot.bootstrap Found Backend plugin: Slack
2020-10-18 06:34:49,245 ERROR errbot.backends.slack Could not start the Slack back-end
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/errbot/backends/slack.py", line 24, in <module>
from slackclient import SlackClient
ModuleNotFoundError: No module named 'slackclient'
2020-10-18 06:34:49,246 CRITICAL errbot.backends.slack You need to install the slackclient support in order to use the Slack backend.
You can do `pip install errbot[slack]` to install it
It seems Errbot for Slack doesn't work with Python 3.9 due to a problem with one of Errbot's dependencies; Dulwich:
Step 8/17 : RUN pip install --prefix=/install --no-warn-script-location errbot[slack]==6.1.5
Collecting errbot[slack]==6.1.5
Downloading errbot-6.1.5-py3-none-any.whl (210 kB)
(...)
Collecting dulwich>=0.19.16
Downloading dulwich-0.20.6.tar.gz (388 kB)
(...)
Building wheels for collected packages: dulwich, pygments-markdown-lexer, ansi, slackclient, MarkupSafe
Building wheel for dulwich (setup.py): started
Building wheel for dulwich (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-orbtbp3w/dulwich/setup.py'"'"'; __file__='"'"'/tmp/pip-install-orbtbp3w/dulwich/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-vm9mzhfc
cwd: /tmp/pip-install-orbtbp3w/dulwich/
It could look like Python 3.9 doesn't include the same pre-build of Dulwich as 3.8:
Step 8/17 : RUN pip install --prefix=/install --no-warn-script-location errbot[slack]==6.1.5
---> Running in d221b509f8f1
Collecting errbot[slack]==6.1.5
Downloading errbot-6.1.5-py3-none-any.whl (210 kB)
(...)
Collecting dulwich>=0.19.16
Downloading dulwich-0.20.6-cp38-cp38-manylinux2010_x86_64.whl (504 kB)
(...)
Installing collected packages: (...) dulwich, (...) slackclient, errbot
Successfully installed (...) dulwich-0.20.6 (...) errbot-6.1.5 slackclient-1.3.2
Errbot automatically installs dependencies if a plugin provides a requirements.txt
file.
Even with AUTOINSTALL_DEPS = True
it fails (tested with Pillow==5.4.*
, already installed in venv):
Some plugins failed to start during bot startup:
<class 'subprocess.CalledProcessError'>: Command '['pip', 'install', '--requirement', '/home/self-assembler/self-assembler-bot/plugins/tradingpost-errbot/requirements.txt']' returned non-zero exit status 2
File "/home/self-assembler/self-assembler-bot/venv/lib/python3.5/site-packages/errbot/plugin_manager.py", line 76, in install_packages subprocess.check_call(['pip', 'install', '--requirement', req_path])
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call raise CalledProcessError(retcode, cmd)
Added first draft for a Dockerfile
in commit 46034bf, based on Python:3.7-alpine
. With multi-stage builds it's down to 136MB vs Python:3.7-slim's 226MB.
Probably going to need some adjustments before it's working well.
Current fields will be deprecated on April 1, 2019.
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.