Skip to content

Instantly share code, notes, and snippets.

@FluffyPira
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FluffyPira/d41aa8f4b96947b64310 to your computer and use it in GitHub Desktop.
Save FluffyPira/d41aa8f4b96947b64310 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'twitter_ebooks'
include Ebooks
CONSUMER_KEY = ""
CONSUMER_SECRET = ""
OATH_TOKEN = "" # oauth token for ebooks account
OAUTH_TOKEN_SECRET = "" # oauth secret for ebooks account
TWITTER_USERNAME = "PornyPira_Bot" # Ebooks account username
AUTHOR_NAME = "FluffyPira" # Put your twitter handle in here
DELAY = 2..30 # Simulated human reply delay range in seconds
BLACKLIST = ['insomnius', 'upulie'] # Grumpy users to avoid interaction with
SPECIAL_WORDS = ['bot', 'sexy', 'catgirl', 'girlcock', 'penis', 'vagina', 'tail', 'tentacle']
TRIGGER_WORDS = ['cunt', 'bot', 'bitch', 'zoe', 'anita', 'tranny', 'shemale', 'faggot', 'fag', 'ethics in games journalism']
# Thanks to @vex0rian and @parvitude for the random seed/post_pic method to keep it from posting duplicates near eachother.
# You are both cuties ~<3.
class GenBot
def initialize(bot, modelname)
@bot = bot
bot.consumer_key = CONSUMER_KEY
bot.consumer_secret = CONSUMER_SECRET
bot.on_startup do
@pics = Dir.entries("pictures/") - %w[.. . .DS_Store]
@status_count = @bot.twitter.user.statuses_count
garbage = Random.new.bytes(5)
bot.tweet(garbage)
@lewd = 0
end
bot.on_message do |dm|
# We don't actually want the bot to really say anything, rather just post lots of cute pics.
shit = Random.new.bytes(5)
bot.delay DELAY do
bot.reply dm, "Talk to #{AUTHOR_NAME} #{shit}"
end
end
bot.on_follow do |user|
bot.delay DELAY do
bot.follow user[:screen_name]
end
end
bot.on_mention do |tweet, meta|
tokens = NLP.tokenize(tweet[:text])
special = tokens.find { |t| SPECIAL_WORDS.include?(t) }
trigger = tokens.find { |t| TRIGGER_WORDS.include?(t) }
if special
favourite(tweet) if rand < 0.2
elsif trigger
block(tweet)
end
end
bot.on_timeline do |tweet, meta|
next if BLACKLIST.include?(tweet[:user][:screen_name])
tokens = NLP.tokenize(tweet[:text])
special = tokens.find { |t| SPECIAL_WORDS.include?(t) }
trigger = tokens.find { |t| TRIGGER_WORDS.include?(t) }
if special
favourite(tweet) if rand < 0.1
elsif trigger
block(tweet) if rand < 0.2
end
end
# Schedule a tweet for every 20 minutes
bot.scheduler.every '1200' do
if @lewd > 0
post_picture()
@lewd -= 1
end
end
# Twelve pics starting at 19:30
bot.scheduler.cron '30 19 * * *' do
@lewd = 12
end
end
def favourite(tweet)
@bot.log "Favoriting @#{tweet[:user][:screen_name]}: #{tweet[:text]}"
@bot.twitter.favorite(tweet[:id])
end
def next_index()
seq = (0..(@pics.size - 1)).to_a
seed = @status_count / @pics.size
r = Random.new(seed)
seq.shuffle!(random: r)
res = seq[@status_count % @pics.size]
@status_count = @status_count + 1
return res
end
def post_picture()
pic = @pics[next_index]
@bot.twitter.update_with_media("$lewd", File.new("pictures/#{pic}"))
@bot.log "posted pictures/#{pic}"
end
def block(tweet)
@bot.log "Blocking and reporting @#{tweet[:user][:screen_name]}"
@bot.twitter.block(tweet[:user][:screen_name])
@bot.twitter.report_spam(tweet[:user][:screen_name])
end
end
def make_bot(bot, modelname)
GenBot.new(bot, modelname)
end
Ebooks::Bot.new(TWITTER_USERNAME) do |bot|
bot.oauth_token = OATH_TOKEN
bot.oauth_token_secret = OAUTH_TOKEN_SECRET
make_bot(bot, TWITTER_USERNAME)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment