mirror of
https://github.com/thewesker/ebooks_example.git
synced 2025-12-20 04:11:13 -05:00
Second commit:
Merge ENV on top of defaults.env to get SETTINGS Added basic controls via DM
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Gemfile.lock
|
||||||
|
secret.env
|
||||||
72
Gemfile.lock
72
Gemfile.lock
@@ -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
|
|
||||||
42
bots.rb
42
bots.rb
@@ -4,8 +4,9 @@ require 'dotenv'
|
|||||||
|
|
||||||
include Ebooks::Boodoo
|
include Ebooks::Boodoo
|
||||||
|
|
||||||
# Read .env file and set values:
|
# Read defaults and lay env vars on top:
|
||||||
SETTINGS = Dotenv.load
|
SETTINGS = Dotenv.load('defaults.env').merge(ENV)
|
||||||
|
|
||||||
|
|
||||||
# Information about a particular Twitter user we know
|
# Information about a particular Twitter user we know
|
||||||
class UserInfo
|
class UserInfo
|
||||||
@@ -55,7 +56,7 @@ class CloneBot < BoodooBot
|
|||||||
# @pester_count = parse_num(SETTINGS['PESTER_COUNT'])
|
# @pester_count = parse_num(SETTINGS['PESTER_COUNT'])
|
||||||
@timeout_sleep = parse_num(SETTINGS['TIMEOUT_SLEEP'])
|
@timeout_sleep = parse_num(SETTINGS['TIMEOUT_SLEEP'])
|
||||||
|
|
||||||
# from example
|
# from upstream example
|
||||||
@userinfo = {}
|
@userinfo = {}
|
||||||
|
|
||||||
# added for BooDoo variant
|
# added for BooDoo variant
|
||||||
@@ -96,9 +97,38 @@ class CloneBot < BoodooBot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def on_direct_message(dm)
|
def on_direct_message(dm)
|
||||||
# TODO: Add controls here! Especially "tweet"
|
from_owner = dm.user.screen_name.downcase == @original
|
||||||
delay(dm_delay) do
|
if from_owner
|
||||||
reply(dm, model.make_response(dm.text))
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ CONSUMER_KEY=
|
|||||||
CONSUMER_SECRET=
|
CONSUMER_SECRET=
|
||||||
ACCESS_TOKEN=
|
ACCESS_TOKEN=
|
||||||
ACCESS_TOKEN_SECRET=
|
ACCESS_TOKEN_SECRET=
|
||||||
UPDATE_FOLLOWS_INTERVAL=90m
|
|
||||||
TWEET_INTERVAL=2m
|
TWEET_INTERVAL=2m
|
||||||
TWEET_CHANCE=0.8
|
TWEET_CHANCE=0.8
|
||||||
BLACKLIST=tinysubversions, dril
|
BLACKLIST=tinysubversions, dril
|
||||||
@@ -16,3 +15,4 @@ MENTION_DELAY=5..60
|
|||||||
TIMELINE_DELAY=10..600
|
TIMELINE_DELAY=10..600
|
||||||
TIMEOUT_SLEEP=5
|
TIMEOUT_SLEEP=5
|
||||||
MAX_ERROR_RETRIES=10
|
MAX_ERROR_RETRIES=10
|
||||||
|
UPDATE_FOLLOWS_INTERVAL=90m
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user