Skip to content

Commit

Permalink
fixed remove command, admin bug, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonp committed Aug 24, 2014
1 parent 1cfcc6f commit 73b0654
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Binary file modified botspade.db
Binary file not shown.
31 changes: 26 additions & 5 deletions botspade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@
# Create a table for custom user-generated call and response.
@db.execute "CREATE TABLE IF NOT EXISTS commands (id INTEGER PRIMARY KEY, command TEXT, response TEXT, timestamp BIGINT)"

# Create a table for initializations and options/settings.
# @db.execute "CREATE TABLE IF NOT EXISTS options (id INTEGER PRIMARY KEY, option TEXT, value TEXT, timestamp BIGINT)"

# Create a table for custom user-generated items.
@db.execute "CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name TEXT, description TEXT, price INT, ownable INT, timestamp BIGINT)"
@db.execute "CREATE TABLE IF NOT EXISTS inventory (id INTEGER PRIMARY KEY, user_id INT, item_id INT, timestamp BIGINT)"
@db.execute "CREATE TABLE IF NOT EXISTS queue (id INTEGER PRIMARY KEY, item_id INT, timestamp BIGINT)"

# Track bets made. Resets every time bets are tallied.
@betsdb = {}
# @betsdb = {} deprecated

# Toggle whether or not bets are allowed
@betsopen = FALSE
Expand Down Expand Up @@ -156,7 +159,7 @@ def pretty_uptime
def user_is_an_admin?(user)
puts "checking admin for: #{@streamer}"
check_this_user = get_user(user)
if (check_this_user[6] == 1) || check_this_user == @streamer
if (check_this_user[6] == 1) || user == @streamer
return true
else
return false
Expand Down Expand Up @@ -204,8 +207,10 @@ def respond_to_commands(message)
on :channel, /^!removecommand/i do
if user_is_an_admin?(nick)
newmessage = message.gsub("!removecommand ", "")
command_to_remove = message.split(' ')[0].downcase
command = db_get_command(command_to_remove)
command_to_remove = newmessage.split(' ')[0].downcase
puts "#{command_to_remove}"
command = db_get_command(command_to_remove)[0]
puts "about to delete command"
msg channel, "success" if db_remove_command(command[0])
end
end
Expand Down Expand Up @@ -391,6 +396,21 @@ def respond_to_commands(message)
end
end

on :channel, /^!list$/i do
if talkative?
if user_is_an_admin?(nick)
commands = db_get_all_commands
if (commands)
list_of_commands = []
commands.each do |command|
list_of_commands << command[1] + " "
end
msg channel, "#{list_of_commands}"
end
end
end
end

on :channel, /^!removeadmin (.*)/i do |first|
user_to_make_admin = first.downcase
user = get_user(user_to_make_admin)
Expand Down Expand Up @@ -744,7 +764,8 @@ def respond_to_commands(message)
if (newuser)
if db_checkins_get(newuser[0])
total_checkins = db_user_checkins_count(newuser[0])
give_points(nick, 14)
points_for_checking_in = 10 + @checkin_points
give_points(nick, points_for_checking_in)
give_points(referrer, 10)
msg channel, "Welcome #{nick}! You & #{referrer} have been awarded 10 #{@botmaster} Points! You have also been checked in for 4 #{@botmaster} Points."
end
Expand Down

0 comments on commit 73b0654

Please sign in to comment.