twitter-ebooks/skeleton/bots.rb

66 lines
1.7 KiB
Ruby
Raw Permalink Normal View History

2013-11-08 06:02:05 +11:00
require 'twitter_ebooks'
# This is an example bot definition with event handlers commented out
2014-12-05 22:57:32 +11:00
# You can define and instantiate as many bots as you like
class MyBot < Ebooks::Bot
# Configuration here applies to all MyBots
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
2013-11-08 06:02:05 +11:00
2014-12-05 22:57:32 +11:00
def on_startup
scheduler.every '24h' do
# Tweet something every 24 hours
# See https://github.com/jmettraux/rufus-scheduler
2014-12-06 00:17:54 +11:00
# tweet("hi")
# pictweet("hi", "cuteselfie.jpg")
2014-12-05 22:57:32 +11:00
end
end
2013-11-08 06:02:05 +11:00
2014-12-05 22:57:32 +11:00
def on_message(dm)
2013-11-08 06:02:05 +11:00
# Reply to a DM
2014-12-06 00:17:54 +11:00
# reply(dm, "secret secrets")
2013-11-08 06:02:05 +11:00
end
2014-12-05 22:57:32 +11:00
def on_follow(user)
2013-11-08 06:02:05 +11:00
# Follow a user back
2014-12-06 00:17:54 +11:00
# follow(user.screen_name)
2013-11-08 06:02:05 +11:00
end
2014-12-05 22:57:32 +11:00
def on_mention(tweet)
2013-11-08 06:02:05 +11:00
# Reply to a mention
# reply(tweet, "oh hullo")
2013-11-08 06:02:05 +11:00
end
2014-12-05 22:57:32 +11:00
def on_timeline(tweet)
2013-11-08 06:02:05 +11:00
# Reply to a tweet in the bot's timeline
# reply(tweet, "nice tweet")
2013-11-08 06:02:05 +11:00
end
def on_favorite(user, tweet)
# Follow user who just favorited bot's tweet
# follow(user.screen_name)
end
2016-01-13 02:27:24 -08:00
def on_retweet(tweet)
# Follow user who just retweeted bot's tweet
# follow(tweet.user.screen_name)
end
2014-12-05 22:57:32 +11:00
end
2013-11-08 06:02:05 +11:00
2014-12-05 22:57:32 +11:00
# Make a MyBot and attach it to an account
MyBot.new("{{BOT_NAME}}") do |bot|
bot.access_token = "" # Token connecting the app to this account
bot.access_token_secret = "" # Secret connecting the app to this account
2013-11-08 06:02:05 +11:00
end