twitter_ebooks_poll 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +2 -0
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +167 -0
- data/Rakefile +2 -0
- data/bin/ebooks +449 -0
- data/data/adjectives.txt +1466 -0
- data/data/nouns.txt +2193 -0
- data/lib/twitter_ebooks/archive.rb +116 -0
- data/lib/twitter_ebooks/bot.rb +521 -0
- data/lib/twitter_ebooks/model.rb +336 -0
- data/lib/twitter_ebooks/nlp.rb +195 -0
- data/lib/twitter_ebooks/suffix.rb +104 -0
- data/lib/twitter_ebooks/sync.rb +52 -0
- data/lib/twitter_ebooks/version.rb +3 -0
- data/lib/twitter_ebooks.rb +22 -0
- data/skeleton/Gemfile +4 -0
- data/skeleton/Procfile +1 -0
- data/skeleton/bots.rb +65 -0
- data/skeleton/corpus/.gitignore +0 -0
- data/skeleton/gitignore +1 -0
- data/skeleton/image/.gitignore +0 -0
- data/skeleton/model/.gitignore +0 -0
- data/skeleton/stopwords.txt +843 -0
- data/spec/bot_spec.rb +216 -0
- data/spec/data/0xabad1dea.json +203945 -0
- data/spec/data/0xabad1dea.model +6158 -1
- data/spec/memprof.rb +37 -0
- data/spec/model_spec.rb +88 -0
- data/spec/spec_helper.rb +6 -0
- data/twitter_ebooks.gemspec +37 -0
- metadata +309 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
$debug = false
|
2
|
+
|
3
|
+
def log(*args)
|
4
|
+
STDERR.print args.map(&:to_s).join(' ') + "\n"
|
5
|
+
STDERR.flush
|
6
|
+
end
|
7
|
+
|
8
|
+
module Ebooks
|
9
|
+
GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
10
|
+
DATA_PATH = File.join(GEM_PATH, 'data')
|
11
|
+
SKELETON_PATH = File.join(GEM_PATH, 'skeleton')
|
12
|
+
TEST_PATH = File.join(GEM_PATH, 'test')
|
13
|
+
TEST_CORPUS_PATH = File.join(TEST_PATH, 'corpus/0xabad1dea.tweets')
|
14
|
+
INTERIM = :interim
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'twitter_ebooks/nlp'
|
18
|
+
require 'twitter_ebooks/archive'
|
19
|
+
require 'twitter_ebooks/sync'
|
20
|
+
require 'twitter_ebooks/suffix'
|
21
|
+
require 'twitter_ebooks/model'
|
22
|
+
require 'twitter_ebooks/bot'
|
data/skeleton/Gemfile
ADDED
data/skeleton/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
worker: bundle exec ebooks start
|
data/skeleton/bots.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'twitter_ebooks'
|
2
|
+
|
3
|
+
# This is an example bot definition with event handlers commented out
|
4
|
+
# You can define and instantiate as many bots as you like
|
5
|
+
|
6
|
+
class MyBot < Ebooks::Bot
|
7
|
+
# Configuration here applies to all MyBots
|
8
|
+
def configure
|
9
|
+
# Consumer details come from registering an app at https://dev.twitter.com/
|
10
|
+
# Once you have consumer details, use "ebooks auth" for new access tokens
|
11
|
+
self.consumer_key = '' # Your app consumer key
|
12
|
+
self.consumer_secret = '' # Your app consumer secret
|
13
|
+
|
14
|
+
# Users to block instead of interacting with
|
15
|
+
self.blacklist = ['tnietzschequote']
|
16
|
+
|
17
|
+
# Range in seconds to randomize delay when bot.delay is called
|
18
|
+
self.delay_range = 1..6
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_startup
|
22
|
+
scheduler.every '24h' do
|
23
|
+
# Tweet something every 24 hours
|
24
|
+
# See https://github.com/jmettraux/rufus-scheduler
|
25
|
+
# tweet("hi")
|
26
|
+
# pictweet("hi", "cuteselfie.jpg")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_message(dm)
|
31
|
+
# Reply to a DM
|
32
|
+
# reply(dm, "secret secrets")
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_follow(user)
|
36
|
+
# Follow a user back
|
37
|
+
# follow(user.screen_name)
|
38
|
+
end
|
39
|
+
|
40
|
+
def on_mention(tweet)
|
41
|
+
# Reply to a mention
|
42
|
+
# reply(tweet, "oh hullo")
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_timeline(tweet)
|
46
|
+
# Reply to a tweet in the bot's timeline
|
47
|
+
# reply(tweet, "nice tweet")
|
48
|
+
end
|
49
|
+
|
50
|
+
def on_favorite(user, tweet)
|
51
|
+
# Follow user who just favorited bot's tweet
|
52
|
+
# follow(user.screen_name)
|
53
|
+
end
|
54
|
+
|
55
|
+
def on_retweet(tweet)
|
56
|
+
# Follow user who just retweeted bot's tweet
|
57
|
+
# follow(tweet.user.screen_name)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Make a MyBot and attach it to an account
|
62
|
+
MyBot.new("{{BOT_NAME}}") do |bot|
|
63
|
+
bot.access_token = "" # Token connecting the app to this account
|
64
|
+
bot.access_token_secret = "" # Secret connecting the app to this account
|
65
|
+
end
|
File without changes
|
data/skeleton/gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
corpus/
|
File without changes
|
File without changes
|