kiwiirc / irc-framework

🛠️ A better IRC framework for node.js. For bots and full clients.
MIT License
181 stars 64 forks source link

Login to irc account #245

Closed MSIKT4AV closed 4 years ago

MSIKT4AV commented 4 years ago

Hi, how login with username and password to irc channel? simply add "password: 'ghffd'" not working

prawnsalad commented 4 years ago

It depends on the network. Most modern networks will use SASL so you would set the nick and password options. If the network doesn't support SASL then you may have to listen for the registered event and send the login command via .say('nickserv', 'identify ' + password)

MSIKT4AV commented 4 years ago

Like this?:

var password = 'simplepassword'

bot.on('registered', function() { bot.say('nickserv', 'identify ' + password) console.log('Connected!'); bot.join('#test000'); });

prawnsalad commented 4 years ago

Test it and see what happens. Does it work?

prawnsalad commented 4 years ago

Works for networks that use SASL:

var bot = new IRC.Client();
bot.connect({
    host: 'irc.irc.com',
    tls: true,
    port: 6697,
    nick: 'somenick',
    password: 'somepassword',
});

Works for networks that don't use SASL but uses nickserv:

var password = 'mypassword';
var username = 'myusername';

bot.on('registered', function() {
        bot.say('nickserv', 'identify ' + username + ' ' + password)
        console.log('Connected!');
        bot.join('#prawnsalad');
});
MSIKT4AV commented 4 years ago

This example does not work for my chat. In python this code work:

irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) irc.connect((server,port)) irc.setblocking(False) time.sleep(1) irc.send(("USER "+botnick+" "+botnick+" "+botnick+" :Hi, I'm just a bot!\r\n").encode()) time.sleep(1) irc.send(("NICK "+botnick+"\n").encode()) time.sleep(1) irc.send(("LOGIN "+botnick+" "+password+"\n").encode()) time.sleep(3) irc.send(("JOIN "+channel+"\n").encode())

and... I dont know how rewrite this in javascript

prawnsalad commented 4 years ago

LOGIN is not a standard command, that's why it doesn't work.

var password = 'mypassword';
var username = 'myusername';

bot.on('registered', function() {
        bot.raw('LOGIN', username + ' ' + password);
        console.log('Connected!');
        bot.join('#prawnsalad');
});
MSIKT4AV commented 4 years ago

Still not. Can you try login on this chat and write as bot? I can give you login/pass