Created
April 30, 2015 07:48
-
-
Save SwooshyCueb/fe1790333bff29e30245 to your computer and use it in GitHub Desktop.
Viv's blockee-reply ebooks script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'twitter_ebooks' | |
# This is an example bot definition with event handlers commented out | |
# You can define and instantiate as many bots as you like | |
class MyBot < Ebooks::Bot | |
# Configuration here applies to all MyBots | |
@blocks = [] | |
@replied = [] | |
def configure | |
# Consumer details come from registering an app at https://dev.twitter.com/ | |
# Once you have consumer details, use "ebooks auth" for new access tokens | |
self.consumer_key = '' # Your app consumer key | |
self.consumer_secret = '' # Your app consumer secret | |
# Users to block instead of interacting with | |
# self.blacklist = ['tnietzschequote'] | |
# Range in seconds to randomize delay when bot.delay is called | |
self.delay_range = 1..6 | |
end | |
def on_startup | |
@blocks = twitter.blocked_ids.to_a | |
@replied = [] | |
scheduler.every '24h' do | |
@blocks = twitter.blocked_ids.to_a | |
@replied = [] | |
# tweet("My pronoun is they") | |
end | |
end | |
def on_message(dm) | |
end | |
def on_follow(user) | |
end | |
def on_mention(tweet) | |
# Reply to a mention | |
meta = meta(tweet) | |
if conversation(tweet).is_bot?(tweet.user.screen_name) | |
log "Not replying to suspected bot @#{tweet.user.screen_name}" | |
return false | |
end | |
if @blocks.include?(tweet.user.id) | |
log "@#{tweet.user.screen_name} is blocked." | |
if @replied.include?(tweet.user.id) | |
log "We've already replied to this user once in the current 24h period." | |
return false | |
else | |
log "Replying to @#{tweet.user.screen_name}." | |
@replied << tweet.user.id | |
reply = twitter.update_with_media(meta.reply_prefix, File.new("obsessed.jpg"), in_reply_to_status_id: tweet.id) | |
# conversation(reply).add(reply) # we don't need this? | |
reply | |
end | |
else | |
return false | |
end | |
end | |
def on_timeline(tweet) | |
end | |
def on_favorite(user, tweet) | |
end | |
end | |
# Make a MyBot and attach it to an account | |
MyBot.new("[username]") do |bot| | |
bot.access_token = "" # Token connecting the app to this account | |
bot.access_token_secret = "" # Secret connecting the app to this account | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment