Skip to content

Commit

Permalink
env: Add variable network in environment instead of hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
Nephos committed Mar 27, 2021
1 parent 1bb9e07 commit 091c3ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ crystal b -s --release src/DashBot.cr
# Configure the database
psql -U postgres postgres -c "CREATE USER root WITH PASSWORD 'toor' SUPERUSER;"
psql -U postgres postgres -c "CREATE DATABASE dash_bot"
echo "PG_URL=postgres://root:toor@localhost/dash_bot" > .env
echo "PG_URL=postgres://root:toor@localhost/dash_bot
NETWORK_HOST=chat.freenode.net
NETWORK_PORT=6697
NETWORK_SSL=true
NICKNAME=Dasshyx" > .env
# Update the database
./bin/micrate up
# Run the bot
Expand Down
8 changes: 7 additions & 1 deletion src/DashBot.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ end
module DashBot
def start
Arguments.new.use
client = Crirc::Network::Client.new(ip: "chat.freenode.net", port: 6697_u16, ssl: true, nick: "Dasshyx#{rand(1..9)}", read_timeout: 300_u16)
client = Crirc::Network::Client.new(
ip: ENV["NETWORK_HOST"],
port: ENV["NETWORK_PORT"].to_u16,
ssl: ENV["NETWORK_SSL"] == "true",
nick: ENV["NICKNAME"] + "#{rand(1..9)}",
read_timeout: 300_u16,
)
client.connect
client.start do |bot|
Plugins::BasicCommands.bind(bot)
Expand Down

0 comments on commit 091c3ff

Please sign in to comment.