Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattetti/twitter_game_bot
A twitter bot
https://github.com/mattetti/twitter_game_bot
Last synced: about 11 hours ago
JSON representation
A twitter bot
- Host: GitHub
- URL: https://github.com/mattetti/twitter_game_bot
- Owner: mattetti
- License: mit
- Created: 2010-01-24T03:06:11.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2010-01-24T03:20:50.000Z (about 15 years ago)
- Last Synced: 2024-11-27T13:12:44.731Z (2 months ago)
- Language: Ruby
- Size: 78.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
Awesome Lists containing this project
README
= Twitter Game Bot
Just a simple bot skeleton which can be used by game developers to post content to twitter on a regular basis.
Implementation example:
require 'twitter_game_bot'
require 'CGI'class MyGame < SCEA::TweetBot
trigger_hourly :tweet_top_player_changes
trigger_daily :tweet_top_5, "14:00 - PST"
trigger_weekly :tweet_weekly_stats, "Monday - 15:00 - PST"
twitter_credentials :login => 'mnr', :password => 'sekrit'
game_api_credentials :login => 'mnr', :password => 'sekrit'
game_api_url 'http://mnr.com/beatit/'
def tweet_top_player_changes
last_top_5 = load_data[:last_top_5]
top_5 = game_api.top_5.to_hash # expected -> {1 => 'James', 2 => 'Peter', 3 => 'Louisa'}
save_data(:last_top_5, top_5)
diff = top_5.diff(last_top_5)
diff.each do |position, name|
tweet "#{CGI.escape(name)} is now #{position.ordinalize}"
end
end
def tweet_top_5
# let's convert {2 => 'Peter', 1 => 'James', 3 => 'Louisa'} to
# [[1,'James'], [2,'Peter'], [3,'Louisa']]
sorted_top_5 = game_api.top_5.sort
msg = sorted_top_5.map do |position, name|
"#{position.ordinalize}: #{CGI.escape(name)}"
end.join(' ')
tweet msg
end
def tweet_weekly_stats
# TODO
end
end== Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.== Copyright
Copyright (c) 2010 Matt Aimonetti. See LICENSE for details.