A bot living in the channels of the Erfurt Hackspace 'Bytespeicher' or the Makerspace, serving its users.
Interfacing a matrix network, using the matrix-sdk. Written in Python 3.6.
Concept phase and build environment setup
Prototyping login and triggering
Implementing standard and maintenance plugins
Re-implementing IRC-Bot plugins
- WinPython 3.6.6.2 including Python 3.6.6
- Also tested with Python 3.5 on Debian Linux 9 (Stretch)
- pip 18.1
- virtualenv 16.0.0
- tmux for start/stop/update scripts on Linux
- the matrix sdk package https://github.com/matrix-org/matrix-python-sdk
- schedule package https://pypi.org/project/schedule/
- if dependency building fails for obscure reasons, delete Pipfile and re-add dependencies manually via pipenv
- subclass Plugin in plugin.py for own plugins
- (re-)implement at least
- __init__() for setting up the plugin
- callback() for the code to be executed on keyword recognition
- get_help() to return a short help text and usage description
- call superclass constructor with
Plugin.__init__(self, name, bot)
- register regex match rules like
self.add_matcher(re.compile("![Dd]ates"))
(you can add multiple) - register scheduled calls like
bot.schedule.every(1).minutes.do(self.dates_announce_next_talks)
- save reference to bot for later use in scheduled tasks if needed (e.g. as
self.bot
)
- send messages via
room.send_text()
- get calling command via
event['content']['body']
for further analysis or matching
- return string for us ein !help command.
- approx. one line per command/function
- use "\n" in string for line breaks
- any function or method can be scheduled via registration in __init__
- there is no
room
orevent
parameter, so send messages to all rooms viaself.bot.all_rooms.send_text()
- Change private_settings.py with username, password, servername and room
- use 'git update-index --assume-unchanged private_settings.py' to no longer track changes and not accidentally upload your password
- Start a tmux session with tmux new -d -s bytebot (only needed once per reboot)
- Start with ./start.sh (will start the bot inside a tmux shell by the name of 'bytebot')
- add ./gitupdate.sh to your crontab if you want to track github changes to the current branch (bot will stop, update, restart if changes are available)
- use 'tmux a -t bytebot' to connect to the session and see the terminal printout
- use ./stop.sh to stop the process (but keep the tmux session)
- use 'tmux kill-session -t bytebot' to also close the session
See LICENSE file for GPLv3 license of this software.
Uses (but not includes) packages and libraries as listed above and below. Links to original sources are given as documentation and credit to the authors.
Uses Scriptacular - gitupdate.sh Copyright 2013 Christopher Simpkins MIT License
schedule python package https://pypi.org/project/schedule/ Daniel Bader - @dbader_org - mailto://mail@dbader.org MIT license
pytest - Python testing framework https://pytest.org MIT License
python-codacy-coverage https://github.com/codacy/python-codacy-coverage BSD 3-Clause "New" or "Revised" License
pytest-cov - coverage plugin for pytest https://github.com/pytest-dev/pytest-cov MIT License
Based on (and contains snipets of code from) https://github.com/Bytespeicher/Bytebot MIT License
See LICENCSE_MIT file for the license text.
The matrix bot api at https://github.com/shawnanastasio/python-matrix-bot-api GPLv3 License was part of this project but has since been completely removed.