Discord Bot

From Nottinghack Wiki
Jump to navigation Jump to search

The discord bot monitors MQTT traffic and builds a cache of information, so that it is able to respond to commands via Discord without accessing any databases. There are a number of supported features:

  • Built-in commands, such as:
    • !battery - Shows a list of WirelessThings battery levels.
    • !humidity - Shows a list of room humidities (also from WirelessThings sensors).
    • !status - Shows (25 most recent) service statuses from the nh/status topic. These timeout and go 'bad' after 1 minute.
    • !temp - Show temperature readings from around the hackspace.
    • !tools - Show current status of bookable tools, e.g. who is using it now, who will be using it next, and when.
    • !wiki [search term] - Queries this wiki's API to perform a search
  • Alerts on certain MQTT messages
    • Forwards doorbell alerts as silent messages to #bot-spam
  • Relays messages to and from MQTT
    • messages to MQTT Topic nh/discord/tx will be forwarded to #bot-spam
    • messages to MQTT Topic nh/discord/tx/{channel} will be forwarded to #{channel}
    • messages to MQTT TOPIC nh/discord/tx/pm/{nick} will be sent as a DM to {nick}
    • messages posted in Discod channels which do not end in "-private" are relayed to MQTT Topic nh/discord/tx/{channel}/{nick}

The code is currently available on Aaron's GitHub, with the intent of moving this to Nottinghack GitHub org eventually.

https://github.com/AaronJackson/nh-discord