diff --git a/Gemfile b/Gemfile index 27a8024..67ae1e8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'http://rubygems.org' ruby '2.1.3' -gem 'twitter_ebooks', '3.0.6' +gem 'twitter_ebooks', '3.0.7' gem 'dotenv' diff --git a/Gemfile.lock b/Gemfile.lock index 9bb735b..46f905c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,6 @@ GEM dotenv (1.0.2) engtagger (0.2.0) equalizer (0.0.9) - eventmachine (1.0.4) faraday (0.9.1) multipart-post (>= 1.2, < 3) fast-stemmer (1.0.2) @@ -24,7 +23,7 @@ GEM http (0.6.3) http_parser.rb (~> 0.6.0) http_parser.rb (0.6.0) - json (1.8.1) + json (1.8.2) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) method_source (0.8.2) @@ -52,9 +51,8 @@ GEM memoizable (~> 0.4.0) naught (~> 1.0) simple_oauth (~> 0.3.0) - twitter_ebooks (3.0.6) + twitter_ebooks (3.0.7) engtagger - eventmachine (~> 1.0.3) fast-stemmer gingerice highscore @@ -72,4 +70,4 @@ PLATFORMS DEPENDENCIES dotenv - twitter_ebooks (= 3.0.6) + twitter_ebooks (= 3.0.7) diff --git a/README.md b/README.md index c716538..848d929 100644 --- a/README.md +++ b/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 -Create your [Twitter app](https://apps.twitter.com) and generate access tokens with *Read, Write and Direct Messages* privileges. +Click this: +[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/BooDoo/ebooks_example/tree/robinbot) -[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/BooDoo/ebooks_example/tree/deploy) - -Put your BOT_NAME, SOURCE_USERNAME, and API secrets into Heroku Config Vars using the web dashboard. +Put your API secrets into Heroku Config Vars using the web dashboard. Scale your app to 1 dyno using the Heroku web dashboard. -Bob's your uncle. +You're ready to go. ## Default Behavior Tweets once on startup. @@ -25,11 +24,3 @@ Favorites tweets that it likes. - **BANNED_TERMS**: words or phrases to obscure/censor - DM commands (tweet, follow, unfollow, block, mention...) - 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. 🙏 diff --git a/app.json b/app.json index a7a09c3..70187f3 100644 --- a/app.json +++ b/app.json @@ -1,7 +1,7 @@ { - "name": "BooDooBooks", + "name": "robinbot", "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": [ "twitter", "bot", @@ -12,8 +12,8 @@ ], "env": { "LANG": "en_US.UTF-8", - "BOT_NAME": "", - "SOURCE_USERNAME": "", + "BOT_NAME": "mu_ebooks", + "SOURCE_USERNAME": "calaminii", "CONSUMER_KEY": "", "CONSUMER_SECRET": "", "ACCESS_TOKEN": "", diff --git a/bots.rb b/bots.rb index 5f0ccc6..9397488 100644 --- a/bots.rb +++ b/bots.rb @@ -63,11 +63,10 @@ class BoodooBot @attempts = 0 @followers = [] @following = [] - @archive_path = "corpus/#{@original}.json" - @model_path = "model/#{@original}.model" + @archive_path = "corpus/robin.csv" + @model_path = "model/robin.model" if can_run? - get_archive! make_model! else missing_fields.each {|missing| @@ -101,12 +100,6 @@ class BoodooBot scheduler.interval @update_follows_interval do follow_parity end - - scheduler.interval @refresh_model_interval do - log "Refreshing archive/model..." - get_archive! - make_model! - end end def on_message(dm) @@ -229,8 +222,11 @@ class BoodooBot def load_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}" @model = Ebooks::Model.load(model_path) end diff --git a/defaults.env b/defaults.env index 9b80925..273b7fc 100644 --- a/defaults.env +++ b/defaults.env @@ -1,5 +1,5 @@ -BOT_NAME= -SOURCE_USERNAME= +BOT_NAME=mu_ebooks +SOURCE_USERNAME=calaminii CONSUMER_KEY= CONSUMER_SECRET= ACCESS_TOKEN=