Skip to content

Commit

Permalink
Fix random
Browse files Browse the repository at this point in the history
  • Loading branch information
Nephos committed Nov 29, 2017
1 parent 45a2571 commit 0f6325a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/DashBot.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
module DashBot
def start
Arguments.new.use
client = Crirc::Network::Client.new(ip: "irc.mozilla.org", port: 6667_u16, ssl: false, nick: "Dasshyxtest2", read_timeout: 300_u16)
client = Crirc::Network::Client.new(ip: "irc.mozilla.org", port: 6667_u16, ssl: false, nick: "Dasshyx#{rand(1..9)}", read_timeout: 300_u16)
client.connect
client.start do |bot|
Plugins::BasicCommands.bind(bot)
Expand Down
4 changes: 2 additions & 2 deletions src/DashBot/plugins/random.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module DashBot::Plugins::Random
extend self

def bind(bot)
bot.on("PRIVMSG", message: /^!random +([[:alnum:]]+(, ?[[:alnum:]]+))+/, doc: {"!random", "!random word1,word2,word3"}) do |msg, match|
bot.on("PRIVMSG", message: /^!random +([^,]+(?:,[^,]+)+)/, doc: {"!random", "!random word1, word2, word3"}) do |msg, match|
match = match.as(Regex::MatchData)
list = match[1]
values = list.split(/(, )|([^,] )/)
values = list.split(',').map(&.strip)
bot.reply msg, "Values: #{values}"
bot.reply msg, values.sample
end
Expand Down

0 comments on commit 0f6325a

Please sign in to comment.