Created
January 24, 2017 18:28
-
-
Save helrond/3df866d3a96efbcd921d52177e42c0ce to your computer and use it in GitHub Desktop.
This file contains 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 | |
attr_accessor :model, :model_path | |
# 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 = 'NONE OF YOUR DAMN BIZNESS' # Your app consumer key | |
self.consumer_secret = 'NOPE, NOT TELLING YOU THAT EITHER' # 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 | |
return if @model | |
@model_path ||= "model/rumi.model" | |
log "Loading model #{model_path}" | |
@model = Ebooks::Model.load(model_path) | |
scheduler.every '3h' do | |
tweet(model.make_statement(140)) | |
end | |
end | |
def on_message(dm) | |
# Reply to a DM | |
# reply(dm, "secret secrets") | |
end | |
def on_follow(user) | |
# Follow a user back | |
# follow(user.screen_name) | |
end | |
def on_mention(tweet) | |
# Reply to a mention | |
delay do | |
reply(tweet, model.make_response(meta(tweet).mentionless, meta(tweet).limit)) | |
end | |
end | |
def on_timeline(tweet) | |
# Reply to a tweet in the bot's timeline | |
# reply(tweet, "nice tweet") | |
end | |
def on_favorite(user, tweet) | |
# Follow user who just favorited bot's tweet | |
# follow(user.screen_name) | |
end | |
def on_retweet(tweet) | |
# Follow user who just retweeted bot's tweet | |
# follow(tweet.user.screen_name) | |
end | |
end | |
# Make a MyBot and attach it to an account | |
MyBot.new("rumi_cloud") do |bot| | |
bot.access_token = "YOU WISH" # Token connecting the app to this account | |
bot.access_token_secret = "KEEP ON DREAMING" # 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