Author Topic: OmnomIRC Protocol Information  (Read 8759 times)

0 Members and 2 Guests are viewing this topic.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
OmnomIRC Protocol Information
« on: February 17, 2014, 11:20:41 am »
With the latest updated the OmnomIRC protocol changed A LOT.

So I decided to make a topic about it! :D

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:
Code: [Select]
{
"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:
Code: [Select]
{
"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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
{
"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:
Code: [Select]
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:
Code: [Select]
{
"lines":
[
<line object>
]
}

So, how does this line object look like?
Code: [Select]
{
"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:
Code: [Select]
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:
Code: [Select]
{
"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
Code: [Select]
{
"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 :)
« Last Edit: November 15, 2015, 11:40:46 am by Sorunome »

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: OmnomIRC Protocol Information
« Reply #1 on: February 17, 2014, 11:28:26 am »
Woo, JSON! Thanks Soru!

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: OmnomIRC Protocol Information
« Reply #2 on: February 17, 2014, 11:39:11 am »
Hehe, no problem, it only took me the whole weekend to program that :P
EDIT: oh, and because JSON is so awesome the config server-side is in json by now too :)
« Last Edit: February 17, 2014, 01:19:59 pm by Sorunome »

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: OmnomIRC Protocol Information
« Reply #3 on: August 20, 2014, 06:40:41 pm »
Main channels are now IDs, so just a number. config.php sends information as to which channel has which ID.
EDIT: Main channels being channels which are sent from the server, so usually the ones starting with a #.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: OmnomIRC Protocol Information
« Reply #4 on: August 20, 2014, 10:32:03 pm »
Nice, hopefully that is easier to manage. Also was JSON invented by someone called Jason (just wondering due to the name)? :P

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: OmnomIRC Protocol Information
« Reply #5 on: August 21, 2014, 05:15:38 am »
JSON stands for JavaScript Object Notation. I think it is now pretty clear to you where it all comes from :P

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: OmnomIRC Protocol Information
« Reply #6 on: September 14, 2014, 05:46:15 am »
Gosh, this was outdated, I think it should be up-to-date now

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: OmnomIRC Protocol Information
« Reply #7 on: March 14, 2015, 02:40:32 pm »
Added information on websockets!

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!