balinterdi-hashtag_retweet_bot 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +34 -9
- data/Rakefile +4 -4
- data/bin/hashtag_retweet_bot +9 -4
- data/hashtag_retweet_bot.gemspec +5 -5
- data/lib/bot.rb +4 -3
- metadata +7 -5
data/README.markdown
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
# Hashtag retweet bot
|
2
2
|
|
3
|
-
A bot that retweets all tweets tagged by a certain
|
3
|
+
A bot that retweets all tweets tagged by a certain hashtag. Ideal for conferences, meetup groups, communities, etc.
|
4
|
+
|
5
|
+
As an example, let's say you want to retweet every tweet found with the hashtag #icecream every 5 minutes (300 seconds). This ruby gem will let you do it as easily as running:
|
6
|
+
|
7
|
+
hashtag_retweet_bot icecream 300
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
gem install balinterdi-hashtag_retweet_bot --source http://gems.github.com
|
8
12
|
|
9
|
-
Create the database
|
13
|
+
Create the database:
|
10
14
|
|
11
|
-
mysqladmin create
|
15
|
+
mysqladmin create my_conference_db
|
12
16
|
|
13
|
-
Create a directory where you will run the bot from:
|
17
|
+
Create a directory where you will run the bot from, and a config directory with 2 files in it: _database.yml_ for your database settings and _bot.yml_ for the login/password of the twitter account.
|
14
18
|
|
15
19
|
mkdir -p bot_for_my_conference/config
|
16
20
|
cd config/bot_for_my_conference
|
@@ -27,16 +31,37 @@ Put the database connection attributes in _database.yml_:
|
|
27
31
|
username: root
|
28
32
|
host: localhost
|
29
33
|
password:
|
30
|
-
database:
|
34
|
+
database: my_conference_db
|
35
|
+
|
36
|
+
And create the table on the database that will hold the tweets:
|
37
|
+
|
38
|
+
hashtag_retweet_bot create_db_table
|
31
39
|
|
32
40
|
## Run it
|
33
41
|
|
34
|
-
Now the only thing left to do is to
|
42
|
+
Now the only thing left to do is running the bot, telling it what tag to follow, like that:
|
43
|
+
|
44
|
+
hashtag_retweet_bot tag_to_follow
|
45
|
+
|
46
|
+
This will launch the bot with a default pause of 180 seconds. If you want a different time schedule you can specify other value for the seconds parameter, but I've experienced Twitter connection problems when trying to update every 60 seconds or less:
|
47
|
+
|
48
|
+
hashtag_retweet_bot tag_to_follow seconds_between_updates
|
49
|
+
|
50
|
+
Example:
|
51
|
+
|
52
|
+
hashtag_retweet_bot icecream
|
53
|
+
hashtag_retweet_bot icecream 240
|
54
|
+
|
55
|
+
## Live examples
|
56
|
+
|
57
|
+
Some twitterbots using hashtag_retweet_bot:
|
35
58
|
|
36
|
-
|
59
|
+
[@euruko_bot](http://twitter.com/euruko_bot)
|
60
|
+
[@confrorbot](http://twitter.com/confrorbot)
|
61
|
+
[The bot for the Budapest Ruby User Group](http://twitter.com/budapestrb)
|
37
62
|
|
38
63
|
## Credits
|
39
64
|
|
40
|
-
Original idea and script by [Mark Connell](http://github.com/mconnell) for Scotland on Rails 2009. Customization for Euruko '09 by [Jaime Iniesta](http://github.com/jaimeiniesta). Some improvements and gemification by [Balint Erdi](http://github.com/balinterdi).
|
65
|
+
Original idea and script by [Mark Connell](http://github.com/mconnell) for Scotland on Rails 2009. Customization for Euruko '09, and some improvements by [Jaime Iniesta](http://github.com/jaimeiniesta). Some improvements and gemification by [Balint Erdi](http://github.com/balinterdi).
|
41
66
|
|
42
|
-
Please send feedback and bug reports to <balint@
|
67
|
+
Please send feedback and bug reports to <balint.erdi@gmail.com>
|
data/Rakefile
CHANGED
@@ -2,11 +2,11 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('hashtag_retweet_bot', '0.1.
|
5
|
+
Echoe.new('hashtag_retweet_bot', '0.1.3') do |p|
|
6
6
|
p.description = "Script that listens to a tag and retweets messages with that tag. Originally made for Scotland on Rails '09 by Mark Connell (http://github.com/rubaidh)"
|
7
|
-
p.url = "http://github.com/
|
8
|
-
p.author = "
|
9
|
-
p.email = "
|
7
|
+
p.url = "http://github.com/jaimeiniesta/hashtag_retweet_bot"
|
8
|
+
p.author = "Jaime Iniesta"
|
9
|
+
p.email = "jaimeiniesta@gmail.com"
|
10
10
|
p.ignore_pattern = ["tmp/*", "config/*", "script/*", "*.txt", "pkg"]
|
11
11
|
p.development_dependencies = ["twibot >=0.1.7", "activerecord", "pauldix-feedzirra >=0.0.12"]
|
12
12
|
p.runtime_dependencies = ["twibot >=0.1.7", "activerecord", "pauldix-feedzirra >=0.0.12"]
|
data/bin/hashtag_retweet_bot
CHANGED
@@ -2,15 +2,20 @@
|
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'bot')
|
4
4
|
|
5
|
-
if ARGV.length
|
6
|
-
puts "Usage: hashtag_retweet_bot [tag_to_watch]"
|
5
|
+
if ARGV.length < 1
|
6
|
+
puts "Usage: hashtag_retweet_bot [tag_to_watch] [seconds_between_updates]"
|
7
|
+
puts "If you haven't created the database table, run:"
|
8
|
+
puts "hashtag_retweet_bot create_db_table"
|
7
9
|
exit
|
8
10
|
end
|
9
11
|
|
10
|
-
tag = ARGV
|
12
|
+
tag = ARGV[0]
|
13
|
+
seconds = ARGV[1] || 180
|
11
14
|
if tag.downcase == 'create_db_table'
|
15
|
+
puts "Creating the database"
|
12
16
|
require File.join(File.dirname(__FILE__), '..', 'create_db_table')
|
13
17
|
else
|
14
|
-
|
18
|
+
puts "Launching the twitterbot to track \##{tag} every #{seconds} seconds"
|
19
|
+
bot = HashtagRetweetBot.new(tag, seconds.to_i)
|
15
20
|
bot.run
|
16
21
|
end
|
data/hashtag_retweet_bot.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{hashtag_retweet_bot}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Balint Erdi"]
|
9
|
-
s.date = %q{2009-
|
8
|
+
s.authors = ["Balint Erdi", "Jaime Iniesta"]
|
9
|
+
s.date = %q{2009-08-16}
|
10
10
|
s.default_executable = %q{hashtag_retweet_bot}
|
11
11
|
s.description = %q{Script that listens to a tag and retweets messages with that tag. Originally made for Scotland on Rails '09 by Mark Connell (http://github.com/rubaidh)}
|
12
|
-
s.email = %q{
|
12
|
+
s.email = %q{jaimeiniesta@gmail.com}
|
13
13
|
s.executables = ["hashtag_retweet_bot"]
|
14
14
|
s.extra_rdoc_files = ["bin/hashtag_retweet_bot", "lib/bot.rb", "README.markdown"]
|
15
15
|
s.files = ["bin/hashtag_retweet_bot", "create_db_table.rb", "feed.rb", "hashtag_retweet_bot.gemspec", "lib/bot.rb", "Manifest", "Rakefile", "README.markdown"]
|
16
|
-
s.homepage = %q{http://github.com/
|
16
|
+
s.homepage = %q{http://github.com/jaimeiniesta/hashtag_retweet_bot}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Hashtag_retweet_bot", "--main", "README.markdown"]
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = %q{hashtag_retweet_bot}
|
data/lib/bot.rb
CHANGED
@@ -13,11 +13,13 @@ end
|
|
13
13
|
# 1. Listen to an rss feed and store that stuff
|
14
14
|
# 2. Work out which tweets need to be tweeted by the bot
|
15
15
|
# 3. send the tweets and mark them as 'tweeted'
|
16
|
+
# 4. repeat ad nauseam every x seconds (as indicated, 180 is recommended)
|
16
17
|
#
|
17
18
|
|
18
19
|
class HashtagRetweetBot
|
19
|
-
def initialize(tag)
|
20
|
+
def initialize(tag, seconds=180)
|
20
21
|
@tag = tag
|
22
|
+
@seconds = seconds
|
21
23
|
end
|
22
24
|
|
23
25
|
def run
|
@@ -30,7 +32,6 @@ class HashtagRetweetBot
|
|
30
32
|
begin
|
31
33
|
# fetch the feed
|
32
34
|
feed = get_tweets_tagged_with(@tag)
|
33
|
-
puts "XXX Feed entries length: #{feed.entries.length}"
|
34
35
|
feed.entries.reverse.each do |entry|
|
35
36
|
tweet = Tweets.find_or_create_by_twitter_id(
|
36
37
|
:twitter_id => entry.id,
|
@@ -57,7 +58,7 @@ class HashtagRetweetBot
|
|
57
58
|
end
|
58
59
|
rescue
|
59
60
|
end
|
60
|
-
sleep(
|
61
|
+
sleep(@seconds)
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: balinterdi-hashtag_retweet_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Balint Erdi
|
8
|
+
- Jaime Iniesta
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-
|
13
|
+
date: 2009-08-16 00:00:00 -07:00
|
13
14
|
default_executable: hashtag_retweet_bot
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +74,7 @@ dependencies:
|
|
73
74
|
version: 0.0.12
|
74
75
|
version:
|
75
76
|
description: Script that listens to a tag and retweets messages with that tag. Originally made for Scotland on Rails '09 by Mark Connell (http://github.com/rubaidh)
|
76
|
-
email:
|
77
|
+
email: jaimeiniesta@gmail.com
|
77
78
|
executables:
|
78
79
|
- hashtag_retweet_bot
|
79
80
|
extensions: []
|
@@ -92,7 +93,8 @@ files:
|
|
92
93
|
- Rakefile
|
93
94
|
- README.markdown
|
94
95
|
has_rdoc: false
|
95
|
-
homepage: http://github.com/
|
96
|
+
homepage: http://github.com/jaimeiniesta/hashtag_retweet_bot
|
97
|
+
licenses:
|
96
98
|
post_install_message:
|
97
99
|
rdoc_options:
|
98
100
|
- --line-numbers
|
@@ -118,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
120
|
requirements: []
|
119
121
|
|
120
122
|
rubyforge_project: hashtag_retweet_bot
|
121
|
-
rubygems_version: 1.
|
123
|
+
rubygems_version: 1.3.5
|
122
124
|
signing_key:
|
123
125
|
specification_version: 3
|
124
126
|
summary: Script that listens to a tag and retweets messages with that tag. Originally made for Scotland on Rails '09 by Mark Connell (http://github.com/rubaidh)
|