Created
August 4, 2008 22:56
-
-
Save vanpelt/3990 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module Jabber | |
def self.read | |
size = $stdin.read(2).unpack(">h") | |
$stdin.read(size).split(':') | |
end | |
def self.write(success) | |
answer = success ? 1 : 0 | |
token = "2#{answer}".pack(">hh") | |
$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 |
This file contains hidden or 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
def from_ejabberd(): | |
input_length = sys.stdin.read(2) | |
(size,) = unpack('>h', input_length) | |
return sys.stdin.read(size).split(':') | |
def to_ejabberd(bool): | |
answer = 0 | |
if bool: | |
answer = 1 | |
token = pack('>hh', 2, answer) | |
sys.stdout.write(token) | |
sys.stdout.flush() |
This file contains hidden or 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
def self.read | |
size = $stdin.read(2).unpack(">h") | |
$stdin.read(size).split(':') | |
end | |
def self.write(success) | |
answer = success ? 1 : 0 | |
token = "2#{answer}".pack(">hh") | |
$stdout.write(token) | |
$stdout.flush | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment