From c4a67ae2f46b358cade76d5fd05ab2da8e11c2c7 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 9 Sep 2024 20:04:24 -0400 Subject: add post-text.py script --- post-text.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 post-text.py diff --git a/post-text.py b/post-text.py new file mode 100644 index 0000000..0ad949f --- /dev/null +++ b/post-text.py @@ -0,0 +1,17 @@ +from os import environ +import argparse +import discord + +ap = argparse.ArgumentParser() +ap.add_argument('channel', help='the discord id of the channel to post to') +ap.add_argument('text', help='the text to post') + +a = ap.parse_args() + +if 'TOKEN' not in environ: + print('please set an environment variable TOKEN with the bot token') + exit(1) + +token = environ['TOKEN'] + +discord.post(discord.session(token), f'/channels/{a.channel}/messages', {'content': a.text}) -- cgit v1.2.3