Skip to content

Commit

Permalink
update: Fix compatibility with crystal v1.0.0 and lastest db
Browse files Browse the repository at this point in the history
  • Loading branch information
Nephos committed Mar 23, 2021
1 parent 8786aa1 commit 1bb9e07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 3 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: DashBot
version: 0.1.0
version: 1.0.0

authors:
- Arthur Poulet <arthur.poulet@mailoo.org>

license: MIT

crystal: 1.0.0

dependencies:
# irc
crirc:
Expand Down
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: "Dasshyx#{rand(1..9)}", read_timeout: 300_u16)
client = Crirc::Network::Client.new(ip: "chat.freenode.net", port: 6697_u16, ssl: true, nick: "Dasshyx#{rand(1..9)}", read_timeout: 300_u16)
client.connect
client.start do |bot|
Plugins::BasicCommands.bind(bot)
Expand Down
6 changes: 2 additions & 4 deletions src/DashBot/plugins/points.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ module DashBot::Plugins::Points
def bind_add(bot)
bot.on("PRIVMSG", message: /^!p +([[:graph:]]+) +([[:graph:]]+)/, doc: {"!p", "!p type someone"}) do |msg, match|
match = match.as Regex::MatchData
DB.exec "INSERT INTO points (assigned_to, assigned_by, type, created_at)
VALUES ($1, $2, $3, NOW())", [match[2], msg.source.source_id, match[1].downcase]
n = DB.query_one("SELECT COUNT(*) FROM points WHERE assigned_to = $1 AND type = $2",
[match[2], match[1].downcase], as: {Int64})
DB.exec "INSERT INTO points (assigned_to, assigned_by, type, created_at) VALUES ($1, $2, $3, NOW())", match[2], msg.source.source_id, match[1].downcase
n = DB.query_one("SELECT COUNT(*) FROM points WHERE assigned_to = $1 AND type = $2", match[2], match[1].downcase, as: {Int64})
bot.reply msg, "#{match[2]} has now #{n} point#{n > 1 ? "s" : ""} #{match[1]}"
end
end
Expand Down

0 comments on commit 1bb9e07

Please sign in to comment.