Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module Jabber
def self.read
size = $stdin.read(2).unpack("n").first
$stdin.read(size).split(':')
end
def self.write(success)
answer = success ? 1 : 0
token = [2, answer].pack("nn")
$stdout.write(token)
$stdout.flush
end
def self.auth(uname, server, pass)
uname == "vanpelt"
end
def self.isuser(uname, server)
uname == "vanpelt"
end
def self.setpass(uname, server, pass)
false
end
end
while true do
data = Jabber.read
success = case data[0]
when "auth": Jabber.auth(*data[1,3])
when "isuser": Jabber.isuser(*data[1,2])
when "setpass": Jabber.setpass(*data[1,3])
else false
end
Jabber.write(success)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment