From 1db238244b5e029aa398b171bd9655be763211f4 Mon Sep 17 00:00:00 2001 From: skillet Date: Fri, 27 Jan 2023 12:58:14 -0500 Subject: [PATCH] Added example for pulling discord token from environment variable and setup init run config --- .idea/DiscordWhitelist.iml | 10 ++++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ autowl/__init__.py | 17 +++++++++++++++++ autowl/__main__.py | 16 ++++++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 .idea/DiscordWhitelist.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 autowl/__main__.py diff --git a/.idea/DiscordWhitelist.iml b/.idea/DiscordWhitelist.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/DiscordWhitelist.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c9fd31e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..05d918e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/autowl/__init__.py b/autowl/__init__.py index 0dc0f7f..5680cd7 100644 --- a/autowl/__init__.py +++ b/autowl/__init__.py @@ -1,2 +1,19 @@ +import os import discord + +# run init stuff inside this function +def init(): + # make sure this prints the discord token + # set this up as a runtime environment variable, DO NOT HARDCODE THE TOKEN + try: + disToken = os.environ[ + 'DISCORD_TOKEN'] # grabs the discord token from the environment variable, if not there, exit + except: + print("ERROR: unable to find discord token in environment variables!") + exit(1) + + print("discord Token:"+disToken) + + +init() diff --git a/autowl/__main__.py b/autowl/__main__.py new file mode 100644 index 0000000..b014ecc --- /dev/null +++ b/autowl/__main__.py @@ -0,0 +1,16 @@ +import os +import discord + + +# main runtime function +def main(): + try: + disToken = os.environ['DISCORD_TOKEN'] # grabs the discord token from the environment variable, if not there, exit + except: + print("ERROR: unable to find discord token in environment variables!") + exit(1) + + print("hello world") + + +main()