2023-10-07 06:47:08 +00:00
|
|
|
# Teams Bot
|
|
|
|
|
|
|
|
This bot connects your team to the outside
|
|
|
|
and makes it addressable.
|
|
|
|
|
|
|
|
Configure this bot with your team address
|
|
|
|
(e.g. helpdesk@example.org),
|
|
|
|
and add all your **team members** to the **crew**.
|
|
|
|
Then,
|
|
|
|
every time **an outsider** writes to your team address,
|
|
|
|
the bot opens a new **relay group** with all of you;
|
|
|
|
you can use the relay group to discuss the request in private
|
|
|
|
and when you have come to a conclusion,
|
|
|
|
**answer** the **request**.
|
|
|
|
The bot will forward the answer to the outsider
|
|
|
|
in the name of the team,
|
|
|
|
hiding the identities of the team members.
|
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
2023-10-07 18:55:41 +00:00
|
|
|
To install this bot,
|
|
|
|
run:
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone https://git.0x90.space/missytake/teams-bot
|
|
|
|
cd teams-bot
|
|
|
|
pip install .
|
|
|
|
```
|
|
|
|
|
|
|
|
Now you can configure it
|
|
|
|
with an email address
|
|
|
|
you want to use as a team:
|
|
|
|
|
|
|
|
```
|
2023-10-08 14:54:08 +00:00
|
|
|
teams-bot init --email helpdesk@example.org --password p455w0rD
|
2023-10-07 18:55:41 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
This command will show a QR code;
|
|
|
|
scan it with Delta Chat
|
|
|
|
to become part of the "team",
|
|
|
|
the verified group which manages the Teams Bot.
|
|
|
|
|
|
|
|
Now to run it,
|
|
|
|
simply execute:
|
|
|
|
|
|
|
|
```
|
2023-10-09 07:17:56 +00:00
|
|
|
teams-bot run -v
|
2023-10-07 18:55:41 +00:00
|
|
|
```
|
2023-10-07 06:47:08 +00:00
|
|
|
|
2023-10-07 18:55:41 +00:00
|
|
|
The bot only works as long as this command is running.
|
|
|
|
Read more about [running bots on
|
|
|
|
bots.delta.chat](https://bots.delta.chat/howto.html).
|
2023-10-07 06:47:08 +00:00
|
|
|
|
2023-10-08 12:15:42 +00:00
|
|
|
|
|
|
|
### Deploy with pyinfra
|
|
|
|
|
|
|
|
If you use [pyinfra](https://pyinfra.com/) to manage a server,
|
|
|
|
you can deploy this bot with it.
|
|
|
|
Just import it into your [deploy.py file](https://docs.pyinfra.com/en/2.x/getting-started.html#create-a-deploy) like this:
|
|
|
|
|
|
|
|
```
|
|
|
|
from teams_bot.pyinfra import deploy_teams_bot
|
|
|
|
|
|
|
|
deploy_teams_bot(
|
2023-10-08 14:54:08 +00:00
|
|
|
unix_user='root', # an existing UNIX user (doesn't need root or sudo privileges)
|
|
|
|
bot_email='helpdesk@example.org', # the email address your team wants to use
|
|
|
|
bot_passwd='p4ssw0rd', # the password to the email account
|
2023-10-08 12:15:42 +00:00
|
|
|
)
|
|
|
|
```
|
|
|
|
|
|
|
|
After you deployed it,
|
|
|
|
you need to do two steps manually:
|
|
|
|
|
|
|
|
First,
|
|
|
|
to initialize the bot,
|
|
|
|
create the crew,
|
2023-10-09 07:15:09 +00:00
|
|
|
and join the crew,
|
|
|
|
login to the user with ssh
|
|
|
|
and run:
|
|
|
|
|
|
|
|
```
|
|
|
|
export $(cat ~/.env | xargs) && ~/.local/lib/teams-bot.venv/bin/teams-bot init
|
|
|
|
```
|
2023-10-08 12:15:42 +00:00
|
|
|
|
2023-10-09 07:15:09 +00:00
|
|
|
Then,
|
2023-10-08 12:15:42 +00:00
|
|
|
to start the bot
|
2023-10-09 07:15:09 +00:00
|
|
|
and keep it running in the background,
|
|
|
|
run:
|
|
|
|
|
|
|
|
```
|
|
|
|
systemctl --user start teams-bot
|
|
|
|
```
|
2023-10-08 12:15:42 +00:00
|
|
|
|
|
|
|
You can view the log output
|
|
|
|
with `journalctl --user -fu teams-bot`
|
|
|
|
to confirm that it works.
|
|
|
|
|
2023-10-07 08:14:11 +00:00
|
|
|
## Development Environment
|
|
|
|
|
|
|
|
To get started with developing,
|
|
|
|
run:
|
|
|
|
|
|
|
|
```
|
|
|
|
python3 -m venv venv
|
|
|
|
. venv/bin/activate
|
2023-10-07 12:59:25 +00:00
|
|
|
pip install pytest tox black pytest-xdist
|
2023-10-07 08:14:11 +00:00
|
|
|
pip install -e .
|
2023-10-07 12:59:25 +00:00
|
|
|
DCC_NEW_TMP_EMAIL='https://ci.testrun.org/new_email?t=1h_2364962873z' tox
|
2023-10-07 08:14:11 +00:00
|
|
|
```
|