gem install twitter_ebooks
. Hopefully it installs successfully. If it doesn’t you probably don’t have XCode or Command Line Tools set up correctly, or you don’t have RVM (or an equivalent Ruby version manager) installed correctly (see above).
cd
and
mkdir
to make a folder for your bot project. When you’re in the proper directory, run
ebooks new my_test_bot
(or whatever you want to call your bot). Now open the
bots.rb
file in your code editor. This is where you tell your bot how to act and thus will be where we’ll do most of our coding.
bots.rb
in your text editor.
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
attr_accessor riginal, :model, :model_path
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
load_model!
scheduler.every '24h' do
# Tweet something every 24 hours
# See https://github.com/jmettraux/rufus-scheduler
# tweet("hi")
# pictweet("hi", "cuteselfie.jpg")
end
scheduler.every '57m' do
statement = model.make_statement(140)
tweet(statement)
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
# reply(tweet, "oh hullo")
end
def on_timeline(tweet)
# Reply to a tweet in the bot's timeline
# reply(tweet, "nice tweet")
end
private
def load_model!
return if @model
@model_path ||= "model/#{original}.model"
log "Loading model #{model_path}"
@model = Ebooks::Model.load(model_path)
end
end
# Make a MyBot and attach it to an account
MyBot.new("schlinkbot") do |bot|
bot.access_token = "" # Token connecting the app to this account
bot.access_token_secret = "" # Secret connecting the app to this account
bot.original = "sts10"
end
self.consumer_key
and
self.consumer_secret
. The second two go down at the bottom at
bot.access_token
and
bot.access_token_secret
. In all 4 cases, put the codes between the quotation marks.
"schlinkbot"
to the handle of your Twitterbot. And change
"sts10"
to whatever “real” Twitter account you want your bot to imitate. This “real” account with populate something that Twitter Ebooks calls the “model”.
bots.rb
file and go back to the command line. Now run the following lines from within your bots directory:
bundle install
ebooks archive sts10 corpus/sts10.json
ebooks consume corpus/sts10.json
ebooks start
. Since we only entered the bare minimum into the
bots.rb
file, your bot literally does nothing at this point, but if you saw something like:
@schlinkbot: Loading model model/sts10.model
@schlinkbot: starting tweet stream
@schlinkbot: Online!
scheduler.every '57m' do
statement = model.make_statement(140)
tweet(statement)
end
57m
.
def on_mention(tweet)
# Reply to a mention
statement = model.make_statment(120)
reply(tweet, statement)
end
@ryanvailbrown The last-ditch missile plan failed, sig up their Nobel Peace Prizes.
— Schlink Bot (@schlinkbot) December 20, 2014
ebooks start
.
bots.rb
settings.
bots.rb
file to play with—
on_message
on_follow
on_timeline
for example. For more ideas, check out You must login or register to view this content.
gem install twitter_ebooks
. Hopefully it installs successfully. If it doesn’t you probably don’t have XCode or Command Line Tools set up correctly, or you don’t have RVM (or an equivalent Ruby version manager) installed correctly (see above).
cd
and
mkdir
to make a folder for your bot project. When you’re in the proper directory, run
ebooks new my_test_bot
(or whatever you want to call your bot). Now open the
bots.rb
file in your code editor. This is where you tell your bot how to act and thus will be where we’ll do most of our coding.
bots.rb
in your text editor.
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
attr_accessor riginal, :model, :model_path
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
load_model!
scheduler.every '24h' do
# Tweet something every 24 hours
# See https://github.com/jmettraux/rufus-scheduler
# tweet("hi")
# pictweet("hi", "cuteselfie.jpg")
end
scheduler.every '57m' do
statement = model.make_statement(140)
tweet(statement)
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
# reply(tweet, "oh hullo")
end
def on_timeline(tweet)
# Reply to a tweet in the bot's timeline
# reply(tweet, "nice tweet")
end
private
def load_model!
return if @model
@model_path ||= "model/#{original}.model"
log "Loading model #{model_path}"
@model = Ebooks::Model.load(model_path)
end
end
# Make a MyBot and attach it to an account
MyBot.new("schlinkbot") do |bot|
bot.access_token = "" # Token connecting the app to this account
bot.access_token_secret = "" # Secret connecting the app to this account
bot.original = "sts10"
end
self.consumer_key
and
self.consumer_secret
. The second two go down at the bottom at
bot.access_token
and
bot.access_token_secret
. In all 4 cases, put the codes between the quotation marks.
"schlinkbot"
to the handle of your Twitterbot. And change
"sts10"
to whatever “real” Twitter account you want your bot to imitate. This “real” account with populate something that Twitter Ebooks calls the “model”.
bots.rb
file and go back to the command line. Now run the following lines from within your bots directory:
bundle install
ebooks archive sts10 corpus/sts10.json
ebooks consume corpus/sts10.json
ebooks start
. Since we only entered the bare minimum into the
bots.rb
file, your bot literally does nothing at this point, but if you saw something like:
@schlinkbot: Loading model model/sts10.model
@schlinkbot: starting tweet stream
@schlinkbot: Online!
scheduler.every '57m' do
statement = model.make_statement(140)
tweet(statement)
end
57m
.
def on_mention(tweet)
# Reply to a mention
statement = model.make_statment(120)
reply(tweet, statement)
end
@ryanvailbrown The last-ditch missile plan failed, sig up their Nobel Peace Prizes.
— Schlink Bot (@schlinkbot) December 20, 2014
ebooks start
.
bots.rb
settings.
bots.rb
file to play with—
on_message
on_follow
on_timeline
for example. For more ideas, check out You must login or register to view this content.
gem install twitter_ebooks
. Hopefully it installs successfully. If it doesn’t you probably don’t have XCode or Command Line Tools set up correctly, or you don’t have RVM (or an equivalent Ruby version manager) installed correctly (see above).
cd
and
mkdir
to make a folder for your bot project. When you’re in the proper directory, run
ebooks new my_test_bot
(or whatever you want to call your bot). Now open the
bots.rb
file in your code editor. This is where you tell your bot how to act and thus will be where we’ll do most of our coding.
bots.rb
in your text editor.
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
attr_accessor riginal, :model, :model_path
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
load_model!
scheduler.every '24h' do
# Tweet something every 24 hours
# See https://github.com/jmettraux/rufus-scheduler
# tweet("hi")
# pictweet("hi", "cuteselfie.jpg")
end
scheduler.every '57m' do
statement = model.make_statement(140)
tweet(statement)
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
# reply(tweet, "oh hullo")
end
def on_timeline(tweet)
# Reply to a tweet in the bot's timeline
# reply(tweet, "nice tweet")
end
private
def load_model!
return if @model
@model_path ||= "model/#{original}.model"
log "Loading model #{model_path}"
@model = Ebooks::Model.load(model_path)
end
end
# Make a MyBot and attach it to an account
MyBot.new("schlinkbot") do |bot|
bot.access_token = "" # Token connecting the app to this account
bot.access_token_secret = "" # Secret connecting the app to this account
bot.original = "sts10"
end
self.consumer_key
and
self.consumer_secret
. The second two go down at the bottom at
bot.access_token
and
bot.access_token_secret
. In all 4 cases, put the codes between the quotation marks.
"schlinkbot"
to the handle of your Twitterbot. And change
"sts10"
to whatever “real” Twitter account you want your bot to imitate. This “real” account with populate something that Twitter Ebooks calls the “model”.
bots.rb
file and go back to the command line. Now run the following lines from within your bots directory:
bundle install
ebooks archive sts10 corpus/sts10.json
ebooks consume corpus/sts10.json
ebooks start
. Since we only entered the bare minimum into the
bots.rb
file, your bot literally does nothing at this point, but if you saw something like:
@schlinkbot: Loading model model/sts10.model
@schlinkbot: starting tweet stream
@schlinkbot: Online!
scheduler.every '57m' do
statement = model.make_statement(140)
tweet(statement)
end
57m
.
def on_mention(tweet)
# Reply to a mention
statement = model.make_statment(120)
reply(tweet, statement)
end
@ryanvailbrown The last-ditch missile plan failed, sig up their Nobel Peace Prizes.
— Schlink Bot (@schlinkbot) December 20, 2014
ebooks start
.
bots.rb
settings.
bots.rb
file to play with—
on_message
on_follow
on_timeline
for example. For more ideas, check out You must login or register to view this content.Copyright © 2024, NextGenUpdate.
All Rights Reserved.