Second commit:

Merge ENV on top of defaults.env to get SETTINGS
Added basic controls via DM
This commit is contained in:
Joel McCoy
2014-12-18 14:58:40 -05:00
parent cfd7b74d3d
commit a331b24cfd
5 changed files with 39 additions and 9492 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
Gemfile.lock
secret.env

View File

@@ -1,72 +0,0 @@
GEM
remote: http://rubygems.org/
specs:
addressable (2.3.6)
awesome_print (1.2.0)
bloomfilter-rb (2.1.1)
redis
buftok (0.2.0)
coderay (1.1.0)
engtagger (0.2.0)
equalizer (0.0.9)
eventmachine (1.0.3)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
fast-stemmer (1.0.2)
gingerice (1.2.2)
addressable
awesome_print
highscore (1.2.0)
bloomfilter-rb (>= 2.1.1)
whatlanguage (>= 1.0.0)
htmlentities (4.3.2)
http (0.6.3)
http_parser.rb (~> 0.6.0)
http_parser.rb (0.6.0)
json (1.8.1)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.8.2)
multipart-post (2.0.0)
naught (1.0.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
redis (3.1.0)
rufus-scheduler (3.0.9)
tzinfo
simple_oauth (0.3.0)
slop (3.6.0)
thread_safe (0.3.4)
twitter (5.13.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (~> 0.0.9)
faraday (~> 0.9.0)
http (~> 0.6.0)
http_parser.rb (~> 0.6.0)
json (~> 1.8)
memoizable (~> 0.4.0)
naught (~> 1.0)
simple_oauth (~> 0.3.0)
twitter_ebooks (3.0.0)
engtagger
eventmachine (~> 1.0.3)
fast-stemmer
gingerice
highscore
htmlentities
pry
rufus-scheduler
simple_oauth
twitter (~> 5.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
whatlanguage (1.0.5)
PLATFORMS
ruby
DEPENDENCIES
twitter_ebooks

38
bots.rb
View File

@@ -4,8 +4,9 @@ require 'dotenv'
include Ebooks::Boodoo
# Read .env file and set values:
SETTINGS = Dotenv.load
# Read defaults and lay env vars on top:
SETTINGS = Dotenv.load('defaults.env').merge(ENV)
# Information about a particular Twitter user we know
class UserInfo
@@ -55,7 +56,7 @@ class CloneBot < BoodooBot
# @pester_count = parse_num(SETTINGS['PESTER_COUNT'])
@timeout_sleep = parse_num(SETTINGS['TIMEOUT_SLEEP'])
# from example
# from upstream example
@userinfo = {}
# added for BooDoo variant
@@ -96,11 +97,40 @@ class CloneBot < BoodooBot
end
def on_direct_message(dm)
# TODO: Add controls here! Especially "tweet"
from_owner = dm.user.screen_name.downcase == @original
if from_owner
action = dm.text.split.first.downcase
strip_re = Regexp.new("^#{command}\s*", "i")
payload = dm.text.sub(strip_re, "")
#TODO: Add blacklist/whitelist/reject(banned phrase)
#TODO? Move this into a DMController class or equivalent?
case action
when "tweet"
tweet model.make_response(payload, 140)
when "follow"
follow payload
when "unfollow"
unfollow payload
when "block"
block payload
when "mention"
pre = payload + " "
limit = 140 - pre.size
message = "#{pre}#{model.make_statement(limit)}"
tweet message
when "cheating"
tweet payload
else
log "Don't have behavior for command: #{command}"
reply(dm, model.make_response(dm.text))
end
else
#otherwise, just reply like a mention
delay(dm_delay) do
reply(dm, model.make_response(dm.text))
end
end
end
def on_mention(tweet)
# Become more inclined to pester a user when they talk to us

View File

@@ -4,7 +4,6 @@ CONSUMER_KEY=
CONSUMER_SECRET=
ACCESS_TOKEN=
ACCESS_TOKEN_SECRET=
UPDATE_FOLLOWS_INTERVAL=90m
TWEET_INTERVAL=2m
TWEET_CHANCE=0.8
BLACKLIST=tinysubversions, dril
@@ -16,3 +15,4 @@ MENTION_DELAY=5..60
TIMELINE_DELAY=10..600
TIMEOUT_SLEEP=5
MAX_ERROR_RETRIES=10
UPDATE_FOLLOWS_INTERVAL=90m

File diff suppressed because it is too large Load Diff