From 17ef359de2b4d24f8aaca47eec1063ce3471d85f Mon Sep 17 00:00:00 2001 From: Mispy <^_^@mispy.me> Date: Mon, 28 Apr 2014 10:56:48 -0700 Subject: [PATCH] 2.2.3 - Avoid some mention edge cases --- README.md | 8 ++++---- lib/twitter_ebooks/bot.rb | 3 ++- lib/twitter_ebooks/version.rb | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 74f756c..18f179e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# twitter\_ebooks 2.2.2 +# twitter\_ebooks 2.2.3 Rewrite of my twitter\_ebooks code. While the original was solely a tweeting Markov generator, this framework helps you build any kind of interactive twitterbot which responds to mentions/DMs. @@ -63,7 +63,7 @@ The underlying [tweetstream](https://github.com/tweetstream/tweetstream) and [tw twitter\_ebooks comes with a syncing tool to download and then incrementally update a local json archive of a user's tweets. ``` zsh -➜ ebooks archive 0xabad1dea corpus/0xabad1dea.json +➜ ebooks archive 0xabad1dea corpus/0xabad1dea.json Currently 20209 tweets for 0xabad1dea Received 67 new tweets ``` @@ -75,7 +75,7 @@ The first time you'll run this, it'll ask for auth details to connect with. Due In order to use the included text modeling, you'll first need to preprocess your archive into a more efficient form: ``` zsh -➜ ebooks consume corpus/0xabad1dea.json +➜ ebooks consume corpus/0xabad1dea.json Reading json corpus from corpus/0xabad1dea.json Removing commented lines and sorting mentions Segmenting text into sentences @@ -84,7 +84,7 @@ Ranking keywords Corpus consumed to model/0xabad1dea.model ``` -Notably, this works with both json tweet archives and plaintext files (based on file extension), so you can make a model out of any kind of text. +Notably, this works with both json tweet archives and plaintext files (based on file extension), so you can make a model out of any kind of text. Text files use newlines and full stops to seperate statements. diff --git a/lib/twitter_ebooks/bot.rb b/lib/twitter_ebooks/bot.rb index 5eb8b9e..7b08929 100644 --- a/lib/twitter_ebooks/bot.rb +++ b/lib/twitter_ebooks/bot.rb @@ -103,7 +103,8 @@ module Ebooks mless = ev[:text] begin ev.attrs[:entities][:user_mentions].reverse.each do |entity| - mless = mless[0...entity[:indices][0]] + mless[entity[:indices][1]..-1].strip + last = mless[entity[:indices][1]..-1]||'' + mless = mless[0...entity[:indices][0]] + last.strip end rescue Exception p ev.attrs[:entities][:user_mentions] diff --git a/lib/twitter_ebooks/version.rb b/lib/twitter_ebooks/version.rb index 21f2be2..c8da643 100644 --- a/lib/twitter_ebooks/version.rb +++ b/lib/twitter_ebooks/version.rb @@ -1,3 +1,3 @@ module Ebooks - VERSION = "2.2.2" + VERSION = "2.2.3" end