Skip to content

Commit

Permalink
added tables, need to rewrite viewerdb funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonp committed Jul 9, 2014
1 parent a28e6f5 commit 166d006
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
4 changes: 4 additions & 0 deletions botconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
# How many points should a user be given when they !checkin to your stream?
@checkin_points = 4

# How long should bets remain active before auto-closing? Default is 5 minutes.
# NOT IMPLEMENTED YET
@bets_auto_close_in = 5 # minutes

# What is your twitch username? This is the "channel" your bot needs to join.
# The channel MUST begin with '#'
@botchan = "#watchspade"
Expand Down
Binary file modified botspade.db
Binary file not shown.
33 changes: 11 additions & 22 deletions botspade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,19 @@

# Initial Tables - points / checkin / viewers / games / bets
# We will generate a custom user table so we have a relational ID for other tables.
@db.execute "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username TEXT, points INT, first_seen BIGINT, last_seen BIGINT)"
@db.execute "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username TEXT, points INT, first_seen BIGINT, last_seen BIGINT, profile TEXT)"
@db.execute "CREATE UNIQUE INDEX IF NOT EXISTS username ON users (username)"

# migration assist - will remove eventually
# @db.execute "ALTER TABLE users ADD COLUMN profile TEXT;"

# Each checkin will have its own row, With related ID from users table and timestamp of when.
@db.execute "CREATE TABLE IF NOT EXISTS checkins (id INTEGER PRIMARY KEY, user_id INT, timestamp BIGINT)"
# Change win (1) / lose (2) / tie (3) to INTs for database optimisation.
@db.execute "CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY, status TINYINT, timestamp BIGINT)"

# Keeps track of a user's points. DB is persistent.
# e.g. {watchspade => 34}
# @pointsdb = {}
@users = {}
#if File::exists?('pointsdb.txt')
# pointsfile = File.read('pointsdb.txt')
# @pointsdb = JSON.parse(pointsfile)
#end

# Track whether or not we've given points today already. DB is persistent.
# e.g. {watchspade => [987239487234, 12398429837]}
#@checkindb = {}
#if File::exists?('checkindb.txt')
# checkinfile = File.read('checkindb.txt')
# @checkindb = JSON.parse(checkinfile)
#end
# 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)"

# Establish a database of Spade's viewers
# e.g. {viewer => {country => USA, strength => 12}}
Expand All @@ -61,11 +50,11 @@

# Keeps track of wins / losses & maybe other stats eventually.
# e.g. {wincount => 5, losscount => 20, 298273429834 => win, 2094203498234 => loss}
@gamesdb = {}
if File::exists?('gamesdb.txt')
gamesfile = File.read('gamesdb.txt')
@gamesdb = JSON.parse(gamesfile)
end
#@gamesdb = {}
#if File::exists?('gamesdb.txt')
# gamesfile = File.read('gamesdb.txt')
# @gamesdb = JSON.parse(gamesfile)
#end

# Track bets made. Resets every time bets are tallied.
@betsdb = {}
Expand Down
10 changes: 8 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This is a work in progress, including the documentation.

## Instructions

BotSpade runs in Ruby 2.1.0 on top of the Isaac IRC chat bot gem. It's best to run it on a server like the ones you can get for $5/month from [Digital Ocean](http://digitalocean.com), but you can also run it on your mac or Linux based system. You can run it on a PC, too, but it's a pain in the ass.
BotSpade runs in Ruby 2.1.0 on top of the Isaac IRC chat bot gem. It's best to run it on a server like the ones you can get for $5/month from [Digital Ocean](http://digitalocean.com), but you can also run it on your mac or Linux based system. You can run it on a PC, too, but I don't know the steps for that and we'll have to add that later.

On your server, I recommend using [RVM](http://rvm.io). To do this you will need to SSH in to your server, or on a Mac you need to open Terminal. Ultimately, I'll explain that here, but for now: Google.

Expand Down Expand Up @@ -68,7 +68,13 @@ Now you can type

exit

to end your SSH session and your bot will still be running.
to end your SSH session and your bot will still be running. To get back to your "screen" later, SSH back in to the server and type:

screen -r

You can exit (stop) the bot by typing:

ctrl+c

### Contributing

Expand Down

0 comments on commit 166d006

Please sign in to comment.