twitter_ebooks 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8e2a04dcaab428f83c3814fb13fcd5688fb2a5c
4
- data.tar.gz: 1013e835b68fdfe716e8728be804b2d808393f13
3
+ metadata.gz: 216097fd35b255ddec313b23165d2567ca7531c3
4
+ data.tar.gz: 2b54bf321d33cb4b9a72f86049283f1ac8eb4bc8
5
5
  SHA512:
6
- metadata.gz: aabe87ca2f3291a7a61bc365f08b8ce61069bbe73fd1a2833df81951561cab34b01d40aea86c2fddd3ccfb76d2b7ca25618680c08af04642be1f42b1bdfcde1c
7
- data.tar.gz: cb12aa96a44f773bb5ef65b3b7bf75fc52c275d7c752e83b4b2af2ddaf8860107f2674dc5faa68560ac49a1eb8b9d3ba68632989f054293ca0b15d21168d71d1
6
+ metadata.gz: 7fe62a7fa1c3ac656b8cd9f241a585cf0f12cbb8c3bd426cb2f0b41d62fc84e88ac0fed2a265280784ad79658b9afcfda5967fcfad2f3bbdd1ad02618a361453
7
+ data.tar.gz: 59dc22b0ba45436013e64a0047253eeeaf743e79a2a1f80fccd1533dc480a2365f94dd667962257b559802cd49c083ec1e84ad786da7c828a6808f7f0793ea05
data/README.md CHANGED
@@ -17,7 +17,7 @@ A framework for building interactive twitterbots which respond to mentions/DMs.
17
17
  - Non-participating users in a mention chain will be dropped after a few tweets
18
18
  - [API documentation](http://rdoc.info/github/mispy/twitter_ebooks) and tests
19
19
 
20
- Note that 3.0 is not backwards compatible with 2.x, so upgrade carefully!
20
+ Note that 3.0 is not backwards compatible with 2.x, so upgrade carefully! In particular, **make sure to regenerate your models** since the storage format changed.
21
21
 
22
22
  ## Installation
23
23
 
@@ -40,8 +40,8 @@ class MyBot < Ebooks::Bot
40
40
  def configure
41
41
  # Consumer details come from registering an app at https://dev.twitter.com/
42
42
  # Once you have consumer details, use "ebooks auth" for new access tokens
43
- self.consumer_key = '' # Your app consumer key
44
- self.consumer_secret = '' # Your app consumer secret
43
+ self.consumer_key = "" # Your app consumer key
44
+ self.consumer_secret = "" # Your app consumer secret
45
45
 
46
46
  # Users to block instead of interacting with
47
47
  self.blacklist = ['tnietzschequote']
@@ -87,7 +87,7 @@ MyBot.new("abby_ebooks") do |bot|
87
87
  end
88
88
  ```
89
89
 
90
- 'ebooks start' will run all defined bots in their own threads. The easiest way to run bots in a semi-permanent fashion is with [Heroku](https://www.heroku.com); just make an app, push the bot repository to it, enable a worker process in the web interface and it ought to chug along merrily forever.
90
+ `ebooks start` will run all defined bots in their own threads. The easiest way to run bots in a semi-permanent fashion is with [Heroku](https://www.heroku.com); just make an app, push the bot repository to it, enable a worker process in the web interface and it ought to chug along merrily forever.
91
91
 
92
92
  The underlying streaming and REST clients from the [twitter gem](https://github.com/sferik/twitter) can be accessed at `bot.stream` and `bot.twitter` respectively.
93
93
 
data/bin/ebooks CHANGED
@@ -58,6 +58,7 @@ STR
58
58
  end
59
59
 
60
60
  FileUtils.cp_r(Ebooks::SKELETON_PATH, path)
61
+ FileUtils.mv(File.join(path, 'gitignore'), File.join(path, '.gitignore'))
61
62
 
62
63
  File.open(File.join(path, 'bots.rb'), 'w') do |f|
63
64
  template = File.read(File.join(Ebooks::SKELETON_PATH, 'bots.rb'))
@@ -50,7 +50,7 @@ module Ebooks
50
50
  @client = client || make_client
51
51
 
52
52
  if File.exists?(@path)
53
- @tweets = JSON.parse(File.read(@path), symbolize_names: true)
53
+ @tweets = JSON.parse(File.read(@path, :encoding => 'utf-8'), symbolize_names: true)
54
54
  log "Currently #{@tweets.length} tweets for #{@username}"
55
55
  else
56
56
  @tweets.nil?
@@ -180,12 +180,17 @@ module Ebooks
180
180
  @seen_tweets ||= {}
181
181
 
182
182
  @username = username
183
+ @delay_range ||= 1..6
183
184
  configure
184
185
 
185
186
  b.call(self) unless b.nil?
186
187
  Bot.all << self
187
188
  end
188
189
 
190
+ def configure
191
+ raise ConfigurationError, "Please override the 'configure' method for subclasses of Ebooks::Bot."
192
+ end
193
+
189
194
  # Find or create the conversation context for this tweet
190
195
  # @param tweet [Twitter::Tweet]
191
196
  # @return [Ebooks::Conversation]
@@ -379,7 +384,8 @@ module Ebooks
379
384
  end
380
385
 
381
386
  log "Replying to @#{ev.user.screen_name} with: #{meta.reply_prefix + text}"
382
- tweet = twitter.update(meta.reply_prefix + text, opts.merge({in_reply_to_status_id: ev.id}))
387
+ text = meta.reply_prefix + text unless text.match /@#{Regexp.escape ev.user.screen_name}/i
388
+ tweet = twitter.update(text, opts.merge(in_reply_to_status_id: ev.id))
383
389
  conversation(tweet).add(tweet)
384
390
  tweet
385
391
  else
@@ -1,3 +1,3 @@
1
1
  module Ebooks
2
- VERSION = "3.0.4"
2
+ VERSION = "3.0.5"
3
3
  end
data/skeleton/bots.rb CHANGED
@@ -39,12 +39,12 @@ class MyBot < Ebooks::Bot
39
39
 
40
40
  def on_mention(tweet)
41
41
  # Reply to a mention
42
- # reply(tweet, meta(tweet).reply_prefix + "oh hullo")
42
+ # reply(tweet, "oh hullo")
43
43
  end
44
44
 
45
45
  def on_timeline(tweet)
46
46
  # Reply to a tweet in the bot's timeline
47
- # reply(tweet, meta(tweet).reply_prefix + "nice tweet")
47
+ # reply(tweet, "nice tweet")
48
48
  end
49
49
  end
50
50
 
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_ebooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaiden Mispy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -260,11 +260,11 @@ files:
260
260
  - lib/twitter_ebooks/nlp.rb
261
261
  - lib/twitter_ebooks/suffix.rb
262
262
  - lib/twitter_ebooks/version.rb
263
- - skeleton/.gitignore
264
263
  - skeleton/Gemfile
265
264
  - skeleton/Procfile
266
265
  - skeleton/bots.rb
267
266
  - skeleton/corpus/.gitignore
267
+ - skeleton/gitignore
268
268
  - skeleton/model/.gitignore
269
269
  - spec/bot_spec.rb
270
270
  - spec/data/0xabad1dea.json