Skip to content

Instantly share code, notes, and snippets.

@TheLinx
Created July 7, 2011 12:02
Show Gist options
  • Save TheLinx/1069371 to your computer and use it in GitHub Desktop.
Save TheLinx/1069371 to your computer and use it in GitHub Desktop.
Good Luck bot
assert(pcall(require, "twitter"), "You need ltwitter (https://github.com/TheLinx/ltwitter)")
print("Let's generate a configuration file for GoodLuckBot.")
base = [[username = "%s"
password = "%s"
consumerkey = "%s"
consumersecret = "%s"
tokenkey = "%s"
tokensecret = "%s"]]
file = assert(io.open("config.lua", "w"))
io.write("Username: ")
username = io.read("*l")
io.write("Password: ")
password = io.read("*l")
io.write("Twitter API consumer key: ")
consumerkey = io.read("*l")
io.write("Twitter API consumer secret: ")
consumersecret = io.read("*l")
cl = twitter.client(consumerkey, consumersecret)
print(("Open the following url in your browser (while logged in as your good luck bot): %s"):format(cl:startLogin()))
io.write("Confirmation code: ")
code = io.read("*l")
cl:confirmLogin(code)
file:write(base:format(username, password, consumerkey, consumersecret, cl.oauthclient.m_oauth_token, cl.oauthclient.m_oauth_token_secret))
file:close()
print("We're done! The configuration has been written to config.lua")
require("twitter")
require("socket")
require("mime")
require("json")
dofile("config.lua")
local strings = {}
for str in io.lines("strings.txt") do
table.insert(strings, str)
end
local twttr = twitter.client(consumerkey, consumersecret, tokenkey, tokensecret)
local cl = socket.tcp()
cl:connect("stream.twitter.com", 80)
cl:send(([[POST /1/statuses/filter.json HTTP/1.1
Host: stream.twitter.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 19
Authorization: Basic %s
track=kill%smyself
]]):format(mime.b64(("%s:%s"):format(username, password)), '%20'))
while true do
data = cl:receive("*l")
if data and data:sub(1,1) == "{" then
success, data = pcall(json.decode, data)
if success and data.text:find("kill myself") then -- just in case
if pcall(twttr.updateStatus, twttr, {status = ("@%s %s!"):format(data.user.screen_name, strings[math.random(#strings)]):upper(), in_reply_to_status_id = data.id_str}) then
print("tweeted an encouragement to " .. data.user.screen_name)
end
end
end
end
get to it
what are you waiting for
i'll bury you
do it faggot
do it you cunt
no one will miss you
there's nothing for you here
yeah, kill yourself
just do it already
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment