gomatrixbot/README.md
2025-05-09 21:53:23 +12:00

2.5 KiB

GoMatrixBot

Listens to matrix events and performs many actions:

  • Can upload text/images to a snac2 instance by reacting
  • Quote bot - React with a 📝 to store quotes in a database
  • Gifs / Weather / IMDB / Wiki / UrbanDictionary / XKCD searches
  • Downloads videos from links and uploads using yt-dlp
  • Fetches metar/tafs
  • Much more.. But this is constantly evolving proof of concept :)

This project has evolved and not had much love, but it works for us. I have tried to document as much config/setup as possible but some things may be missing.

Setup

As I have build this an run it in an isolated LXC container - Beware, everything is set to run as root. You can change the config as needed.

  1. Install Go
  2. Clone repository + create directories + create environment file
git clone git@github.com:idanoo/gomatrixbot.git ~/gomatrixbot
cd ~/gomatrixbot/src && go build cmd/gomatrixbot/main.go
mkdir -p ~/data/output
mkdir -p ~/data/reaction_pics
mkdir -p ~/data/the_greats
echo 'MATRIX_HOST=""
MATRIX_USERNAME=""
MATRIX_PASSWORD=""
MATRIX_ADMIN_ROOM=""

GIPHY_API_KEY=""
TENOR_API_KEY=""
OPENWEATHERMAP_API_KEY=""

SNAC_HOST=""
SNAC_ACCESS_TOKEN=""
' > ~/data/environment

Why folders? Just so stuff can glob and not get mixed up!

~/data/output # This is used for temp files/uploads
~/data/reaction_pics # Used with .rb to generate text on images
~/data/the_greats # used with 📷️ to store a legendary image

Commands

These may become outdated and may not all work:


🤠 react to faceswap iamge
🍌 react to upload to <snac instance>
📝 react to quote message
🐫 react to save picture for future quote usage
☝️ react to set room topic
📷️ react to save picture for future lulz

.r <?quote>- Returns a random quote (can search quotes)
.rb <?quote> - Returns a random quote on a random bird pic (with optional search)
.remindme <time - 1w1h> <reminder> - Triggers a reminder
.imdb <search> - Search IMDB
.gif <search> - Get a gif from tenor
.giphy <search> - Get a gif from giphy
.metar <ICAO> - Returns current METAR for airport
.taf <ICAO> - Returns TAF for airport
.ud <word> - Urban Dictionary search
.vid <weblink> - yt-dlp a video
.weather <location> - Get weather
.wiki <search> - Search Wikipedia
.xkcd <search> - Search XKCD

.stats - Quote stats
.top - Top saved images
.quake - Returns geonet stuff
.delquote <quote ID> - Deltes a saved quote
.ping - Check if bot is alive
.flip - flips the last message