mirror of
https://github.com/thewesker/ebooks_example.git
synced 2025-12-20 12:21:16 -05:00
BESPOKE CHANGES FOR ROBINBOT
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -1,5 +1,5 @@
|
|||||||
source 'http://rubygems.org'
|
source 'http://rubygems.org'
|
||||||
ruby '2.1.3'
|
ruby '2.1.3'
|
||||||
|
|
||||||
gem 'twitter_ebooks', '3.0.6'
|
gem 'twitter_ebooks', '3.0.7'
|
||||||
gem 'dotenv'
|
gem 'dotenv'
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ GEM
|
|||||||
dotenv (1.0.2)
|
dotenv (1.0.2)
|
||||||
engtagger (0.2.0)
|
engtagger (0.2.0)
|
||||||
equalizer (0.0.9)
|
equalizer (0.0.9)
|
||||||
eventmachine (1.0.4)
|
|
||||||
faraday (0.9.1)
|
faraday (0.9.1)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
fast-stemmer (1.0.2)
|
fast-stemmer (1.0.2)
|
||||||
@@ -24,7 +23,7 @@ GEM
|
|||||||
http (0.6.3)
|
http (0.6.3)
|
||||||
http_parser.rb (~> 0.6.0)
|
http_parser.rb (~> 0.6.0)
|
||||||
http_parser.rb (0.6.0)
|
http_parser.rb (0.6.0)
|
||||||
json (1.8.1)
|
json (1.8.2)
|
||||||
memoizable (0.4.2)
|
memoizable (0.4.2)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
@@ -52,9 +51,8 @@ GEM
|
|||||||
memoizable (~> 0.4.0)
|
memoizable (~> 0.4.0)
|
||||||
naught (~> 1.0)
|
naught (~> 1.0)
|
||||||
simple_oauth (~> 0.3.0)
|
simple_oauth (~> 0.3.0)
|
||||||
twitter_ebooks (3.0.6)
|
twitter_ebooks (3.0.7)
|
||||||
engtagger
|
engtagger
|
||||||
eventmachine (~> 1.0.3)
|
|
||||||
fast-stemmer
|
fast-stemmer
|
||||||
gingerice
|
gingerice
|
||||||
highscore
|
highscore
|
||||||
@@ -72,4 +70,4 @@ PLATFORMS
|
|||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
dotenv
|
dotenv
|
||||||
twitter_ebooks (= 3.0.6)
|
twitter_ebooks (= 3.0.7)
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -1,18 +1,17 @@
|
|||||||
# boodoo_ebooks
|
# mu_ebooks
|
||||||
|
|
||||||
A turn-key, beginner-friendly, ready-to-deploy implementation of a traditional \_ebooks bot using Mispy's [twitter_ebooks](https://github.com/mispy/twitter_ebooks) library.
|
I'M SORRY IT'S COME TO THIS
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Create your [Twitter app](https://apps.twitter.com) and generate access tokens with *Read, Write and Direct Messages* privileges.
|
Click this:
|
||||||
|
[](https://heroku.com/deploy?template=https://github.com/BooDoo/ebooks_example/tree/robinbot)
|
||||||
|
|
||||||
[](https://heroku.com/deploy?template=https://github.com/BooDoo/ebooks_example/tree/deploy)
|
Put your API secrets into Heroku Config Vars using the web dashboard.
|
||||||
|
|
||||||
Put your BOT_NAME, SOURCE_USERNAME, and API secrets into Heroku Config Vars using the web dashboard.
|
|
||||||
|
|
||||||
Scale your app to 1 dyno using the Heroku web dashboard.
|
Scale your app to 1 dyno using the Heroku web dashboard.
|
||||||
|
|
||||||
Bob's your uncle.
|
You're ready to go.
|
||||||
|
|
||||||
## Default Behavior
|
## Default Behavior
|
||||||
Tweets once on startup.
|
Tweets once on startup.
|
||||||
@@ -25,11 +24,3 @@ Favorites tweets that it likes.
|
|||||||
- **BANNED_TERMS**: words or phrases to obscure/censor
|
- **BANNED_TERMS**: words or phrases to obscure/censor
|
||||||
- DM commands (tweet, follow, unfollow, block, mention...)
|
- DM commands (tweet, follow, unfollow, block, mention...)
|
||||||
- Follower parity (periodically compares following/followers and follows/unfollows as needed)
|
- Follower parity (periodically compares following/followers and follows/unfollows as needed)
|
||||||
- Want something else? Create an [issue](https://github.com/BooDoo/ebooks_example/issues). No promises.
|
|
||||||
|
|
||||||
## TODO:
|
|
||||||
- Support full archive (via CSV uploaded elsewhere)
|
|
||||||
|
|
||||||
# DISCLAIMER:
|
|
||||||
I'm making this because I wrote a two-part tutorial for an older version of the twitter_ebooks gem and my mentions turned into a tech support hellscape for months.
|
|
||||||
Please [create issues](https://github.com/BooDoo/ebooks_example/issues) if you have trouble. 🙏 Please do not tweet at me. 🙏
|
|
||||||
|
|||||||
8
app.json
8
app.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "BooDooBooks",
|
"name": "robinbot",
|
||||||
"description": "Turn-key _ebooks deployment using twitter_ebooks",
|
"description": "Turn-key _ebooks deployment using twitter_ebooks",
|
||||||
"repository": "https://github.com/BooDoo/ebooks_example/tree/deploy",
|
"repository": "https://github.com/BooDoo/ebooks_example/tree/robinbot",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"twitter",
|
"twitter",
|
||||||
"bot",
|
"bot",
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"LANG": "en_US.UTF-8",
|
"LANG": "en_US.UTF-8",
|
||||||
"BOT_NAME": "",
|
"BOT_NAME": "mu_ebooks",
|
||||||
"SOURCE_USERNAME": "",
|
"SOURCE_USERNAME": "calaminii",
|
||||||
"CONSUMER_KEY": "",
|
"CONSUMER_KEY": "",
|
||||||
"CONSUMER_SECRET": "",
|
"CONSUMER_SECRET": "",
|
||||||
"ACCESS_TOKEN": "",
|
"ACCESS_TOKEN": "",
|
||||||
|
|||||||
16
bots.rb
16
bots.rb
@@ -63,11 +63,10 @@ class BoodooBot
|
|||||||
@attempts = 0
|
@attempts = 0
|
||||||
@followers = []
|
@followers = []
|
||||||
@following = []
|
@following = []
|
||||||
@archive_path = "corpus/#{@original}.json"
|
@archive_path = "corpus/robin.csv"
|
||||||
@model_path = "model/#{@original}.model"
|
@model_path = "model/robin.model"
|
||||||
|
|
||||||
if can_run?
|
if can_run?
|
||||||
get_archive!
|
|
||||||
make_model!
|
make_model!
|
||||||
else
|
else
|
||||||
missing_fields.each {|missing|
|
missing_fields.each {|missing|
|
||||||
@@ -101,12 +100,6 @@ class BoodooBot
|
|||||||
scheduler.interval @update_follows_interval do
|
scheduler.interval @update_follows_interval do
|
||||||
follow_parity
|
follow_parity
|
||||||
end
|
end
|
||||||
|
|
||||||
scheduler.interval @refresh_model_interval do
|
|
||||||
log "Refreshing archive/model..."
|
|
||||||
get_archive!
|
|
||||||
make_model!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def on_message(dm)
|
def on_message(dm)
|
||||||
@@ -229,8 +222,11 @@ class BoodooBot
|
|||||||
def load_model!
|
def load_model!
|
||||||
return if @model
|
return if @model
|
||||||
|
|
||||||
@model_path ||= "model/#{original}.model"
|
@corpus_path ||= "corpus/robin.csv"
|
||||||
|
@model_path ||= "model/robin.model"
|
||||||
|
|
||||||
|
log "Consuming corpus #{@corpus_path}"
|
||||||
|
Ebooks::Model.consume(@corpus_path).save(@model_path)
|
||||||
log "Loading model #{model_path}"
|
log "Loading model #{model_path}"
|
||||||
@model = Ebooks::Model.load(model_path)
|
@model = Ebooks::Model.load(model_path)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
BOT_NAME=
|
BOT_NAME=mu_ebooks
|
||||||
SOURCE_USERNAME=
|
SOURCE_USERNAME=calaminii
|
||||||
CONSUMER_KEY=
|
CONSUMER_KEY=
|
||||||
CONSUMER_SECRET=
|
CONSUMER_SECRET=
|
||||||
ACCESS_TOKEN=
|
ACCESS_TOKEN=
|
||||||
|
|||||||
Reference in New Issue
Block a user