About Lain

Command Line-to-Discord Utility

Lain allows you to post messages to Discord from your Linux command line.


  • Download lain.py and sabi.py to the same directory
    • Using wget:
      • wget https://raw.githubusercontent.com/sabi/sabi/main/sabi.py
      • wget https://raw.githubusercontent.com/sabi/lain/main/lain.py
    • Using curl:
      • curl https://raw.githubusercontent.com/sabi/sabi/main/sabi.py > sabi.py
      • curl https://raw.githubusercontent.com/sabi/lain/main/lain.py > lain.py
  • Install Lain sudo python3 lain.py install

Adding Webhooks

  • Creating webhooks is easy on Discord. New webhooks should be added to /opt/sabi/lain/webhooks.conf in the format channel_nickname = https://discordapp.com/api/123/123
  • To create a new webhook in Discord:
    • In a channel you have proper permissions, right click a text channel.
    • Edit Channel -> Integrations -> Create Webhook
    • Copy the webhook URL into webhooks.conf

Use from command line

  • Lain can be used from the command line. Useful for cron reminders or piping inputs in.
    • lain channel_nickname -msg your_message
    • lain system-alerts -msg $hostname rebooted
  • Images can be attached to messages by copying them to the images directory at /opt/sabi/lain/images
    • lain channel_nickname -img your_message
    • lain motion-cameras -img $(date) Motion captured on front door camera

Use from TUI

  • /c /change - Change to a different Discord channel based off nicknames in webhooks.conf
    • Ex: /change twitch_friends
  • /h /help - Display the help screen
  • /i /image - Include images in lain/images directory
  • /q /quit - Quit the program
  • /t /tts - Enable Text-To-Speech for the curent message
    • Ex: /tts This message is being read aloud on your speakers lol
  • /v /version - Display version information

Use Cases

  • Get Discord notifications instead of emails for cron messages, mdadm alerts, snmp, etc.
  • Communicate with a public facing community, like a Twitch streamer community, as an anonymous admin identity and not as individuals.
  • Set reminders with cron and lain