Collection of (typically) single file utility scripts used in the workshop that don't have a home elsewhere
- Python 3.10+
pip install -r requirements.txt
- Set up Slack app using
manifest.json
cp config.json.example config.json
- Set
config.json
parametersslack/bot_token
- The bot token from your Slack app, only present after being installed to the workspaceslack/app_token
- Create an app level token with access toconnections:write
slack/notification_channel
- The channel where general notification messages should be senttidyhq/token
- A TidyHQ authentication tokentidyhq/ids
slack
- The custom field ID for a slack user ID
google/calendar_id
- The ID of your main event calendardownload_dir
- A directory to download files to
- Get
google.secret.json
by creating a google app with access to the calendar API. - Run
auth_google.py
to get a token usinggoogle.secret.json
Uses Slack's socket mode to listen for new channel creation events and sends a message to a preconfigured channel with the name of the new channel and who created it.
- Ensure that
slack/bot_token
,slack/app_token
, andslack/notification_channel
are set.
This script will need some form of detached execution. Whether that's a screen, systemd, or something else is up to you.
monitor_new_channels.py
Generates a HTML event report for event hosts that do not have access to TidyHQ. Initial code from eventReports
- Ensure that
tidyhq/token
is set - Adjust
event_report_template.html
cp events.json.example events.json
- Set up at least one report. The report name should be alphanumeric. Easiest way to get event IDs is to grab the number from the start of an event url.
event_report.py report_name > /var/www/reports/report_name.html
Creates repeating TidyHQ events
- Ensure that
tidyhq/token
is set
duplicate_events.py
- follow the prompts
Generates a JSON summary of upcoming calendar events from either Google Calendar or TidyHQ.
- Ensure
auth_google.py
has executed correctly and returned the details of the next event on the calendar if using Google Calendar. - Ensure
tidyhq/token
is set if using TidyHQ
This script will need some form of scheduled release. Recommend once a day.
export_calendar.py [tidyhq|gcal] > /var/www/reports/calendar.json
Matches TidyHQ contacts with Slack user accounts based on registration email. Only flags TidyHQ contacts missing on Slack if they have an active membership.
- Ensure that Slack and TidyHQ credentials have been set in
config.json
- Set a custom field for Slack IDs
- Set a Slack notification channel
link_slack_tidyhq.py [--debug --cron]
- debug: Adds debugging messages
- cron: Does not prompt for manual override and does not ask for confirmation before linking
- Capitalise contact names
- Strip whitespace
- Remove nicknames that match first names
- Ensure that TidyHQ credentials have been set in
config.json
correct_tidyhq_contacts.py [--debug --cron]
- debug: Adds debugging messages
- cron: Applies corrections automatically and with no output
Bulk create TidyHQ groups with a specific prefix.
- Ensure that TidyHQ credentials have been set in
config.json
add_groups.py
and follow the prompts.
Allow users to submit files in a slack channel and ingest them into other applications
- Ensure that Slack credentials have been set in
config.json
and a download directory has been set
dl_slack_files.py [-d] <channel_id>
-d
will run the script in "daemon" mode. The script will wait 60 seconds between loops.
Generate membership numbers for a particular date
- Ensure that a TidyHQ token has been set in
config.json
tidyhq_membership_snapshot.py
- Note this script will install
requests
andslack_bolt
itself. This allows it to be more easily deployed with a Paperless install deployed via Docker. - Ensure that a Slack bot token and channel has been set in
config.json
OR directly in the script - The URLs are currently hardcoded, update as desired.
- Point Paperless-NGX to the script via PAPERLESS_POST_CONSUME_SCRIPT
Triggered automatically
- Ensure that a Slack user token has been set in
config.json
- Ensure that group/emoji mappings are configured
- Set any status overrides as required. These will be applied after all automatic statuses
- Run via cron
This script assumes that it is the definitive source of truth for Slack statuses. As such the first thing it will do is purge all statuses it disagrees with. This can take some time.
Slack rate limiting means that the script can only change around 20 statuses per minute, be mindful when considering running this via cron etc.
slack_badges.py