https://github.com/flipdot/voucherbot
https://github.com/flipdot/voucherbot
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/flipdot/voucherbot
- Owner: flipdot
- Created: 2019-10-20T18:42:10.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-07-24T05:15:13.000Z (11 months ago)
- Last Synced: 2025-07-24T08:46:32.998Z (11 months ago)
- Language: Python
- Size: 42 KB
- Stars: 0
- Watchers: 11
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# voucherbot for discourse
The voucherbot manages the distribution of vouchers via Discourse. It was originally created for distributing the
vouchers for the 36C3.
A voucher is usable a single time, but replicates itself. The idea is therefore to pass the generated tokens to your
friends.
We, flipdot, receive a list of vouchers. We distribute them via Discourse to our members, who can then pass them
to their friends. As soon as all their friends bought their ticket, they should send them back to us, so we can
distribute it to another member.
This bot simplifies this process by automating parts of it. A yaml file serves as a database, containing a mapping
of vouchers and member accounts. Optionally, you can enter a number of persons, so you are able to estimate how
long the voucher will be on it's way.
## Features
- Updates a post in the forum. The post contains a table with the information which member received a vouchers
- Sends the voucher via forum message to the member
- Receives a returned voucher and updates the yaml file with the new one
- Broadcast: Allows to send a message to all current voucher owners
## Usage
Python 3.7 required (TODO: require 3.8 to be able to use TypedDict eventually)
Copy `example_voucher.yml` to `voucher.yml`. Enter your vouchers and their owners. Make a backup of this file (we do not make one for
you and we **WILL** modify this file. Don't cry if something get's lost).
Open `constants.py` and change `VOUCHER_TABLE_POST_ID`. This post will be constantly updated with the table of members
who currently own a voucher.
pip install -r requirements.txt
DISCOURSE_API_KEY=deadbeef python src/app.py --dry # leave out --dry if you are brave
The script will send a message with a voucher to each person who is in `voucher.yml`. It will save the Discourse topic
id in the file as `message_id`, so it won't send the same message twice.
If a user replies to that message, the script will scan for the string `CHAOS[a-zA-Z0-9]+` in their messages. If it
finds a new voucher, the old voucher in the yml file get's replaced by the new one and all other fields will be reset.