Skip to content

Commit

Permalink
No longer need channel id to be set in the env
Browse files Browse the repository at this point in the history
  • Loading branch information
freyamade committed Mar 13, 2019
1 parent 6291f57 commit 3df776f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .env.sample.bash
@@ -1,7 +1,5 @@
# Sample environment file for use in the bash shell

# channel_id
export CRCOPHONY_CHANNEL_ID=""
# token
export CRCOPHONY_TOKEN=""
# user id
Expand Down
2 changes: 0 additions & 2 deletions .env.sample.fish
@@ -1,7 +1,5 @@
# Sample environment file for use in the fish shell

# channel_id
set -x CRCOPHONY_CHANNEL_ID ""
# token
set -x CRCOPHONY_TOKEN ""
# user id
Expand Down
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -57,13 +57,11 @@ If you run into any issues, check the `.log` files that have been created. If an
To use the system, you must gather the following information and export the data as environment variables.
These variables are as follows;

- `CRCOPHONY_CHANNEL_ID`: The ID of the channel you wish to connect to (temporary, will be removed once I have sorted out the channel switching functionality)
- `CRCOPHONY_TOKEN`: Your user token used to authenticate yourself with the client
- `CRCOPHONY_USER_ID`: Your user id (might not be necessary, requires investigation and could be removed at a later point)

Here are the instructions for you to get these bits of data;
1. Turn on [Developer Mode](https://discordia.me/developer-mode)
2. To get the `channel_id`, right click on the channel you want to join and click "Copy ID". This is the value you should put in as the `channel_id`
3. To get the `user_id`, right click on your own name in the Users sidebar of any channel and click "Copy ID". This is the value you should put in as the `user_id`
4. Follow [this guide](https://discordhelp.net/discord-token) to get your token.

Expand Down
18 changes: 0 additions & 18 deletions src/config.cr
Expand Up @@ -4,38 +4,20 @@ module Crcophony
# Environment variable config loader class
class Config
# Env key names
@@CHANNEL_ID_KEY = "CRCOPHONY_CHANNEL_ID"
@@TOKEN_KEY = "CRCOPHONY_TOKEN"
@@USER_ID_KEY = "CRCOPHONY_USER_ID"

# Config variables
@channel_id : UInt64
@token : String
@user_id : UInt64

# The ID of the channel to connect to (will be removed as soon as channel switching is implemented)
getter channel_id
# The user token used to log in
getter token
# The user id (isn't necessary to specify initially so I might get rid of this requirement)
getter user_id

# Attempt to load configuration from the environment
def initialize
# Channel ID
if ENV[@@CHANNEL_ID_KEY]?
channel_id = ENV[@@CHANNEL_ID_KEY]
if channel_id.to_u64?
@channel_id = channel_id.to_u64
else
puts "Crcophony Config Error: Could not load `#{@@CHANNEL_ID_KEY}` as it is not a valid 64 bit unsigned integer.".colorize :red
Process.exit 1
end
else
puts "Crcophony Config Error: Could not load `#{@@CHANNEL_ID_KEY}`. Have you set the environment variable?".colorize :red
Process.exit 1
end

# User token
if ENV[@@TOKEN_KEY]?
@token = ENV[@@TOKEN_KEY]
Expand Down

0 comments on commit 3df776f

Please sign in to comment.