Skip to content

Commit

Permalink
added bet ratio command & linked users guide
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonp committed Oct 17, 2014
1 parent 3256935 commit 8dddbdd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
25 changes: 25 additions & 0 deletions botspade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,31 @@ def check_for_raffle_entry(message, nick)
end
end

on :channel, /^!ratio/i do
open_bets = db_get_all_open_bets
number_of_win_bets = 0
number_of_loss_bets = 0
number_of_tie_bets = 0
number_of_bets = open_bets.count
if number_of_bets == 0
msg channel, "There are no outstanding bets."
else
open_bets.each do |open_bet|
if open_bet[2] == 1
number_of_win_bets = number_of_win_bets + 1
elsif open_bet[2] == 2
number_of_loss_bets = number_of_loss_bets + 1
elsif open_bet[2] == 3
number_of_tie_bets = number_of_tie_bets + 1
end
end
win_bet_ratio = number_of_win_bets.to_f / number_of_bets.to_f * 100
loss_bet_ratio = number_of_loss_bets.to_f / number_of_bets.to_f * 100
tie_bet_ratio = number_of_tie_bets.to_f / number_of_bets.to_f * 100
msg channel, "Bets ratio: #{win_bet_ratio}% bet win, #{loss_bet_ratio}% bet loss, #{tie_bet_ratio}% bet tie."
end
end

# Method for users to give points to other viewers
# !give user points

Expand Down
2 changes: 1 addition & 1 deletion db_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def db_get_inventory_for(user_id)
end

# DB fucntions for betting
# bet[0] = id, [1] = user_id, [2] = bet (0/1/2), [3] = bet_amount, [4] = result (was the bet a winner), [5] = timestamp
# bet[0] = id, [1] = user_id, [2] = bet (1/2/3), [3] = bet_amount, [4] = result (was the bet a winner), [5] = timestamp

def db_create_bet(user_id, bet, bet_amount, result)
return true if @db.execute( "INSERT INTO bets ( user_id, bet, bet_amount, result, timestamp ) VALUES ( ?, ?, ?, ?, ? )", [user_id, bet, bet_amount, result, Time.now.utc.to_i])
Expand Down
31 changes: 3 additions & 28 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Allow your viewers to bet with virtual points on your wins and losses, and other things. Watch or Star this GitHub to follow updates.

See the [User's Guide / Quick Reference here](https://github.com/jasonp/botspade/wiki/User's-Guide) for a list of commands you and your users can make use of.

BotSpade can:
* Change its name to yours! e.g. "BotEtheco"
* Provide basic call-and-response in chat, e.g. !settings
Expand Down Expand Up @@ -86,34 +88,7 @@ You can exit (stop) the bot by typing:

### Use / Admin

!togglebets - Toggles betting open/closed. Bets will auto-close after 5 minutes or whatever default time you set.

!reportgame [win/loss/tie] - Report the game you just played, tally bets and distribute winnings or losses.

!addcommand [command] [description] e.g.
!addcommand !spade Spade doesn't dial the wrong number, you answer the wrong phone

!removecommand [command], e.g. !removecommand !spade

!additem [Spade's Fedora] 20 This is Spade's infamous Fedora.

!removeitem [Spade's Fedora]

!addspecial [Fedora] 20 Make spade wear a fedora on stream

!removespecial [Fedora]

!startstream - start stream timer

!endstream - ends stream timer

!uptime - shows stream uptime

!checkin - checks the user in and provides points per the checkin-points amount.

!bet [points] [win/loss/tie]

!shop - lists items in the shop.
All available use/admin related commands are now listed in the [user's guide](https://github.com/jasonp/botspade/wiki/User's-Guide).

### Contributing

Expand Down

0 comments on commit 8dddbdd

Please sign in to comment.