This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Connect to IRC using HTTP API?
Started by Cranium, 27 September 2012 - 10:24 PMPosted 28 September 2012 - 12:24 AM
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.
Posted 28 September 2012 - 12:33 AM
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. : )
Posted 28 September 2012 - 12:37 AM
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….
*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….
Posted 28 September 2012 - 01: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.
Posted 28 September 2012 - 01:58 AM
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.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.
Posted 28 September 2012 - 02: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!
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!
Posted 28 September 2012 - 04: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.
Posted 28 September 2012 - 06: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.
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.
Posted 28 September 2012 - 05: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.
Posted 02 October 2012 - 01:21 AM
Actually, its possible!
I'm working on it!
You see, you just have to use
So it actually is possible, heres the code I am working on.
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…Posted 02 October 2012 - 01:28 AM
Actually, its possible!
I'm working on it!
You see, you just have to useto get the chat out with the args arg2: "string.len" arg1: "htmlCode"!string.sub()
So it actually is possible, heres the code I am working on.I'm trying to extract the chat from the code…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())
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.
Posted 02 October 2012 - 03:06 AM
Actually, its possible!
I'm working on it!
You see, you just have to useto get the chat out with the args arg2: "string.len" arg1: "htmlCode"!string.sub()
So it actually is possible, heres the code I am working on.I'm trying to extract the chat from the code…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())
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.
Posted 04 October 2012 - 09:01 AM
Search google for http irc proxy. There is already software and services out there that you could interface with.
Posted 04 October 2012 - 05: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.
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.
Posted 04 October 2012 - 07: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.
Posted 04 October 2012 - 08: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.
Posted 05 October 2012 - 08: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.
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.
Posted 05 October 2012 - 04:31 PM
Thank you for your input. I had already given up on connecting, except through a peripheral.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.
Posted 06 October 2012 - 04: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).
Posted 06 October 2012 - 04: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.
Posted 06 October 2012 - 11:29 AM
As previous speaker said, HTTP is built on top of TCP, it's just application-level protocol extension to it, it's called an overlay. This means that when you send a HTTP request or receive a response, you are using TCP, but with the data formatted as described here. And so it is with the IRC, except that it's formatted differently, as described here.<insert his post here>
Also, how are you going to use jQuery to connect to IRC, while ComputerCraft allows its users to send only HTTP requests? Seriously, wtf.