Jump to content




Connect to IRC using HTTP API?


20 replies to this topic

#1 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 27 September 2012 - 11:24 PM

I was wondering, if it is possible to connect to IRC channels using the HTTP API? I know people make IRC clients all the time, but I want to make one for Rednet. Nothing fancy, but something that you could post and read. Or at the very least, just read. Such as have an IRC feed of #ComputerCraft.

#2 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 27 September 2012 - 11:33 PM

Only possibility I know of is writing a php script that grabs irc traffic and returns the records as a response to a http request from the http api. I'm quite certain that the HTTP api only connects to ports 80 and 443. IRC is on lots of ports, but normally not those. : )

#3 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 27 September 2012 - 11:37 PM

Well that's rather dissapointing....Why did you have to come over here and kill my dreams?
*sigh*
Oh well, unless somebody has a dissenting opinion or some other advice, I'll have to crawl back into my cave and work on other *less interesting* things....

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 September 2012 - 12:23 AM

There's a peripheral that will allow this functionality. Someone has in fact already made an IRC client that connects to actual IRC servers with that peripheral.

#5 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 28 September 2012 - 12:58 AM

View PostLyqyd, on 28 September 2012 - 12:23 AM, said:

There's a peripheral that will allow this functionality. Someone has in fact already made an IRC client that connects to actual IRC servers with that peripheral.
I'm looking more for something that can be accessed just with the http api. Reason being is because i want to release the program on the forum, and not require any dependencies on other installations outside of ComputerCraft. This is so anyone with ComputerCraft can use it.

#6 CallMeGavin

  • New Members
  • 169 posts
  • LocationGeevancraft!

Posted 28 September 2012 - 01:03 AM

This is actually my idea. That i told to CraniumKid22 and btw thanks for asking people for some help!

This would be an awesome program because my server uses MonsterIRC and if the program connected to #Geevancraft, it could basically talk on my server!

#7 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 28 September 2012 - 03:13 AM

Sorryy to burst your bubble, Gav...but you just reminded me of it. I remember seeing someone posted something like this before, but had to modify ComputerCraft HEAVILY to make it work. Like I said though, I do want this to work out of the box, for someone to just download the script and be ready to go.

#8 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 28 September 2012 - 05:40 AM

That's not really going to happen. At all.

The only possibility is if there were some PHP (or suchlike) page hosted someplace that would provide an API of sorts via http to connect to arbitrary IRC channels/servers. If you find that, you'll have a chance at making it work.

#9 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 28 September 2012 - 04:17 PM

Well, I know my friend is learning some PHP. Maybe we can work on a project for CCIRC(name pending) so that you can connect to JUST #computercraft on IRC. That would be really nice.

#10 DSlink2010

  • Members
  • 50 posts

Posted 02 October 2012 - 12:21 AM

Actually, its possible!
I'm working on it!
You see, you just have to use
string.sub()
to get the chat out with the args arg2: "string.len" arg1: "htmlCode"!
So it actually is possible, heres the code I am working on.
local htmlCode = http.get("http://webchat.esper.net/?channels=#computercraft")
local htmlLength = string.len(htmlCode)
local htmlLengthP = table.tostring(htmlLength)
local polishedHtml = string.sub(htmlCode, htmlLengthP)
write(polishedHtml.readAll())
I'm trying to extract the chat from the code...

#11 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 02 October 2012 - 12:28 AM

View PostDSlink2010, on 02 October 2012 - 12:21 AM, said:

Actually, its possible!
I'm working on it!
You see, you just have to use
string.sub()
to get the chat out with the args arg2: "string.len" arg1: "htmlCode"!
So it actually is possible, heres the code I am working on.
local htmlCode = http.get("http://webchat.esper.net/?channels=#computercraft")
local htmlLength = string.len(htmlCode)
local htmlLengthP = table.tostring(htmlLength)
local polishedHtml = string.sub(htmlCode, htmlLengthP)
write(polishedHtml.readAll())
I'm trying to extract the chat from the code...

That's not connecting to IRC, that's scraping chat from a web interface. You can't send chat that way, can you? You certainly can't interact with it to the degree that an actual client would be able to.

#12 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 02 October 2012 - 02:06 AM

View PostLyqyd, on 02 October 2012 - 12:28 AM, said:

View PostDSlink2010, on 02 October 2012 - 12:21 AM, said:

Actually, its possible!
I'm working on it!
You see, you just have to use
string.sub()
to get the chat out with the args arg2: "string.len" arg1: "htmlCode"!
So it actually is possible, heres the code I am working on.
local htmlCode = http.get("http://webchat.esper.net/?channels=#computercraft")
local htmlLength = string.len(htmlCode)
local htmlLengthP = table.tostring(htmlLength)
local polishedHtml = string.sub(htmlCode, htmlLengthP)
write(polishedHtml.readAll())
I'm trying to extract the chat from the code...

That's not connecting to IRC, that's scraping chat from a web interface. You can't send chat that way, can you? You certainly can't interact with it to the degree that an actual client would be able to.

Actually, webchat.esper.net uses qwebirc, which seems to use JavaScript for the UI, and a custom Python server for the IRC/HTTP bridge. Since communication from the client to the bridge is HTTP, you could probably use it from CC.
Scraping the page is not the way to do it, though.

#13 MrBarry

  • Members
  • 29 posts
  • LocationColorado, USA

Posted 04 October 2012 - 08:01 AM

Search google for http irc proxy. There is already software and services out there that you could interface with.

#14 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 04 October 2012 - 04:42 PM

Thanks, I did not know what to search with. On first search, I found this: http://ircproxy.sourceforge.net/
Is this something I can use for what I want? I know nothing of programs outside of ComputerCraft, but I am willing to learn a bit of everything if I need to. It doesn't need to be elaborate, just functional.

#15 MrBarry

  • Members
  • 29 posts
  • LocationColorado, USA

Posted 04 October 2012 - 06:51 PM

I don't know, but it is probably as good a starting point as any. I suppose it depends on how big a sysadmin / server geek you are. If it was me, I'd look for something hosted. There might even be something free out there.

#16 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 04 October 2012 - 07:48 PM

Ugh... I hate slogging through the net to find what I need. I know someone already made something that can connect with a peripheral that was created, but I want to have as little dependencies as possible. If something out there already exists, then I'll use it, otherwise, I give up on it.

#17 Jajnick

  • New Members
  • 41 posts
  • LocationPoland

Posted 05 October 2012 - 07:00 AM

You simply can't connect to IRC using the HTTP API, those are two different protocols. Also, even if you'd use website to do that, its host would connect, and not your computer.
Additionally, looks like you don't even know how hard is to create such a website. A standard, free PHP web hosting doesn't offer enough features to keep the connection alive. You would need a dedicated server, and run your own application (written in C# for example) that can be remotely controlled via HTTP.
If you seriously want to establish a connection, you should forget about the HTTP API. If I were you, I'd create my own IRC client that can be controlled using the file system, f.e. by editing text files and writing command to them.
Well, since a C# program isn't too big, you could attach it to your Lua script and voila! you have a beautiful working IRC client. But without it, forget about connecting.

#18 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 05 October 2012 - 03:31 PM

View PostJajnick, on 05 October 2012 - 07:00 AM, said:

You simply can't connect to IRC using the HTTP API, those are two different protocols. Also, even if you'd use website to do that, its host would connect, and not your computer.
Additionally, looks like you don't even know how hard is to create such a website. A standard, free PHP web hosting doesn't offer enough features to keep the connection alive. You would need a dedicated server, and run your own application (written in C# for example) that can be remotely controlled via HTTP.
If you seriously want to establish a connection, you should forget about the HTTP API. If I were you, I'd create my own IRC client that can be controlled using the file system, f.e. by editing text files and writing command to them.
Well, since a C# program isn't too big, you could attach it to your Lua script and voila! you have a beautiful working IRC client. But without it, forget about connecting.
Thank you for your input. I had already given up on connecting, except through a peripheral.

#19 B00mX0r

  • New Members
  • 20 posts

Posted 06 October 2012 - 03:13 AM

Sorry, but, *facepalm*. There are three general types of web protocols; HTTP, TCP, and UDP. HTTP is the one that is used for websites that you see, like computercraft.info and google.com. TCP is used for sockets and data to be sent through them (or UDP sometimes), like an interactive online flash game. HTTP API is what it says; it's HTTP, not TCP or UDP. Last I checked, you can't make an IRC with HTTP unless you want to to a gigantic .txt file with jquery (which I would strongly not recommend you do).

#20 Fatal_Exception

  • New Members
  • 105 posts

Posted 06 October 2012 - 03:20 AM

Except that's not really accurate either, because HTTP is built on top of TCP. HTTP is an application-level protocol, TCP and UDP are at the transport level.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users