[Solved] Irc client help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
hatninja
Prole
Posts: 30
Joined: Sun Apr 07, 2013 1:31 am
Contact:

[Solved] Irc client help

Post by hatninja »

I have been trying to make an irc client with love2d as a fun project of mine, and it works... well sorta.
It connects to the irc server absolutely fine, but it receives nothing!

Updated summary of the code:

Code: Select all

local username = "USERNAME"
local nickname = "Username"
local ip = "irc.freenode.net"
local port = "6667"
local channel = "#(ARealWorkingChannel)"
local irc = socket.tcp()

print(irc:connect(ip,tonumber(port)))
irc:settimeout(1)
irc:send("USER "..username.." 8 * :"..username.."\r\n")
irc:send("NICK "..nickname.."\r\n")
irc:send("JOIN "..channel.."\r\n")

--to help get a better understanding of how irc works:
function love.update(dt)
print(irc:receive())
end
Summary of log:

Code: Select all

Running client!
0 timeout
nil timeout
nil closed
nil closed
nil closed
Etc.
I'm dumbfounded as to why it isn't working, please help?

EDIT: Oh, what do you know! changed the port to 8000 and it worked!
Last edited by hatninja on Mon Dec 30, 2013 11:31 pm, edited 2 times in total.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Irc client help

Post by Nixola »

Shouldn't the port be 6667?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
hatninja
Prole
Posts: 30
Joined: Sun Apr 07, 2013 1:31 am
Contact:

Re: Irc client help

Post by hatninja »

6697 seems to be the only port that the client can connect to
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Irc client help

Post by Nixola »

My IRC bot connects to Freenode through the port 6667, I don't think Freenode accepts connections on other ports
EDIT: Just tested your code, setting the port to 6667 fixes it for me. Also, storing it as string and only using it with tonumber is quite useless, you might want to store it as number directly
Last edited by Nixola on Mon Dec 30, 2013 6:50 pm, edited 1 time in total.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
hatninja
Prole
Posts: 30
Joined: Sun Apr 07, 2013 1:31 am
Contact:

Re: Irc client help

Post by hatninja »

Using port 6667 just times it out.
Could i possibly take a look at your irc bot?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Irc client help

Post by Nixola »

Sure! You can find the code here, you'll probably only want to look at main.lua and settings.lua for now
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
hatninja
Prole
Posts: 30
Joined: Sun Apr 07, 2013 1:31 am
Contact:

Re: Irc client help

Post by hatninja »

Our code is nearly identical, so i guess something is preventing me from connecting to freenode...
That can't be right at all!
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Irc client help

Post by Nixola »

Can you connect using other clients?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
hatninja
Prole
Posts: 30
Joined: Sun Apr 07, 2013 1:31 am
Contact:

Re: Irc client help

Post by hatninja »

Yes, of course.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Irc client help

Post by Nixola »

That's a weird issue then. Can you try to download my bot and see if it works? To run it, you can cd into its directory and run "lua main.lua"; it could work with Love, I think, even if the window would look unresponsive

Edit: I just noticed something, setting the timeout to 0 is a bad idea unless you need nonblocking network operations. If you let LuaSocket wait until it receives a message you'll save a lot of CPU cycles which would go wasted otherwise.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests