summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-09-09 20:04:24 -0400
committerBenji Dial <benji@benjidial.net>2024-09-09 20:04:24 -0400
commitc4a67ae2f46b358cade76d5fd05ab2da8e11c2c7 (patch)
tree9aa9357071d6a6470055c6b498192d787380adda
parentb07175f583db58cb1000e33cef5953b34fd3a7a9 (diff)
downloadbracket-bot-c4a67ae2f46b358cade76d5fd05ab2da8e11c2c7.tar.gz
add post-text.py script
-rw-r--r--post-text.py17
1 files changed, 17 insertions, 0 deletions
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})