With the latest updated the OmnomIRC protocol changed A LOT.
So I decided to make a topic about it!
In general all data received now is json, while sending didn't change, base64 encoded url parameters.
First, when loading the page, OmnomIRC does a call to config.php?js
That file is built like following:
{
"hostname":"www.omnimaga.org",
"channels":
[
{
"chan":"#omnimaga",
"high":false,
"ex":false,
"id":1,
"order":1
},
{
"chan":"#omnimaga-spam",
"high":false,
"ex":false,
"id":2,
"order":2
}
],
"smileys":
[
{
"pic":"smileys\/smiley.gif",
"alt":"smiley",
"code":":)",
"inMenu":true,
"regex":"(^| )(:\\)|:-\\))",
"replace":"$1<img src=\"PIC\" alt=\"ALT\" title=\"ALT\" ADDSTUFF>"
},
{
"pic":"smileys\/wink.gif",
"alt":"Wink",
"code":";)",
"inMenu":true,
"regex":"(^| )(;\\)|;-\\))",
"replace":"$1<img src=\"PIC\" alt=\"ALT\" title=\"ALT\" ADDSTUFF>"
}
],
"networks":
[
{
"id":0,
"normal":"<b>NICK<\/b>",
"userlist":"!NICK",
"name":"Server"
},
{
"normal":"<a target=\"_top\" href=\"#NICKENCODE\">NICK<\/a>",
"userlist":"<a target=\"_top\" href=\"NICKENCODE\"><img src=\"omni.png\">NICK<\/a>",
"name":"OmnomIRC"
}
],
"network":1,
"checkLoginUrl":"http:\/\/www.omnimaga.org\/checkLogin.php?sid=<stuff>",
"defaults":"TTF-TTFFFFTT3FTTF",
"websockets":{
"use":true,
"host":"direct.omnimaga.org",
"port":61839,
"ssl":true
}
}
In the channels the 'high' is just simpley if it is been highlighted, transmitted as false for default to make it easier for me. The ex is if it is an external channel.
For smileys the PIC text will be replaced with the pic url, the ALT text with the alt url and the ADDSTUFF with some aditional style stuff, due to the re-write nothing, so it is pretty useless as it will be removed.
For networks NICK is been replaced with the html escaped nick and NICKENCODE with the url encoded nick.
Next OmnomIRC does a call on the checkLoginUrl, adding a jQuery JSON callback, due to cross origin stuff.
That request looks like following:
{
"nick":"Sorunome",
"signature":"not telling you this!",
"uid":"2822"
}
Hm, i wonder why the UID is a string....
Anyways, that is basically data which registers you to your omnimaga profile thingy.
All get requests will have the following URL parameters, some have more in addition:
nick = base64.encode(nick)
signature = base64.encode(signature)
time = unix timestamp
id = uid
channel = base64.encode(channel)
network = network id
Now, to enter a channel, it loads Load.php, with the following aditional URL parameter:
count = 125 // how many lines to load
Example:
Load.php?count=125&channel=I29tbmltYWdh&nick=U29ydW5vbWU,&signature=-snip-&time=1392652008907&id=2822
The reply will look like the following:
{
"banned":false,
"admin":true,
"lines":
[
<line object, discussed later>
],
"users":
[
{
"nick":"Sorunome",
"network":1
}
],
"ignores":["sorunome"]
}
ignores is an array with all the usernames in lowercase to be ignored, it could be that it is omitted, so first check if it exists!
If you pass the parameter "userlist" to Load.php it will
only reply the userlistt, useful for messages of the type reload_userlist.
Update.php is called then, over long http calls. It adds the following URL parameters:
high = 4 // chars need to highlight
lineNum = <some number> // last line id
Example:
Update.php?high=31&channel=1&lineNum=1509358&nick=U29ydW5vbWU,&signature=-snip-&time=1392653536747&id=2822
It will reply like the following:
{
"lines":
[
<line object>
]
}
So, how does this line object look like?
{
"curLine":1509360,
"type":"message",
"network":3,
"time":1392653711,
"name":"Derpy",
"message":"actually i just had to set the headers correctly",
"name2":"",
"chan":"1",
"uid":9001
}
The uid is -1 for messages which don't have user accs, such as IRC
The following types are possible:
reload - force a reload of the channel, calling again Load.php
reload_userlist - force a reload of the current userlist
relog - force a re-identifying with checkLogin
refresh - forces a refresh of the page
join - person joined a channel
part - person parted a channel
quit - person quit IRC
kick - user got kicked
message - normal message
action - /me message
topic - setting the topic
pm - private message
pmaction - /me private message
server - server message
internal - only used client-sided for interal messages
Make sure that you have a local instant of curLine and always replace it by the line one if it is larger, so that you can send it to Update.php
If types concern two nicks, like kick, then name2 is used.
WARNING: All messages by the server are plain text, the client will have to HTML escape on their own!Sending messages:
message = base64.encode(message)
Example:
message.php?message=aG0,&channel=1&nick=U29ydW5vbWU,&signature=-snip-&time=1392653812583&id=2822
The server will not reply to this call.
Every messages, including the sending ones, will also return a
warnings and
errors array.
In addition, a message may reply with a "relog" integer. If it is 0 then everything is fine. If it is 1 the soft-quota of the signature validity is reached - for future messages you should first re-fetch a checkLoginUrl and re-fetch a signature. If it is 2 then it didn't log you in, your sig key has expired. You should re-log and fetch the page again. If it returns 3 it means that your login was just false altogether.
Now, as of recently, there are also websockets. If conifg tells you to use it, you can connect to the websocket server with the provided information.
For the transmission: all lines sent and received are strings of JSON.
First the server expects an identification, it can look the following:
{
"action":"ident",
"nick":"Sorunome",
"signature":"yourEpicSecretPrivateSig",
"time":<unix timestamp>,
"id":9001,
"network":1
}
You get all this information from the checkLogin and the config. Note how no parameters are base64 encoded with websockets.
Received messages can have the relog parameter, please re-auth accordingly.
They can also have a line parameter, returning a line object.
To send a message send something like
{
"action":"message",
"message":"Hi there!"
}
Anyways, I hope this might be helpful for the one or the other if they want to do some projects