ircanywhere / irc-factory

A rebuilt irc-factory from simple-irc-socket and irc-message. Get support at #ircanywhere on freenode
https://ircanywhere.com
MIT License
60 stars 14 forks source link

client.irc.raw("WHOIS", username) returns false #6

Closed Jazcash closed 10 years ago

Jazcash commented 10 years ago

The following code:

client.irc.raw("WHOIS", "Jazcash");
api.hookEvent('*', 'whois', function(msg) { 
    console.log(msg);
});

Only ever seems to print false. Can't figure out why, the user exists, the event is triggered and other events work fine, just not WHOIS.

rickihastings commented 10 years ago

Ok will look into this, odd though, the tests should pick a bug in this up..

rickihastings commented 10 years ago

Just tested this on freenode, it's working for me, are you sure your client is registered yet;

api.hookEvent('test', 'registered', function(message) {
    console.log('SENDING WHOIS');
    client.irc.raw('WHOIS', 'rickibalboa');
});
{ nickname: 'rickibalboa',
  username: '~ricki',
  hostname: 'unaffiliated/rickibalboa',
  realname: 'Ricki',
  raw:
   [ ':rajaniemi.freenode.net 311 simpleircbot rickibalboa ~ricki unaffiliated/rickibalboa * :Ricki',
     ':rajaniemi.freenode.net 312 simpleircbot rickibalboa orwell.freenode.net :NL',
     ':rajaniemi.freenode.net 671 simpleircbot rickibalboa :is using a secure connection',
     ':rajaniemi.freenode.net 330 simpleircbot rickibalboa rickibalboa :is logged in as' ],
  server: 'orwell.freenode.net',
  serverinfo: 'NL',
  secure: 'is using a secure connection',
  loggedin: 'rickibalboa',
  time: Thu Mar 13 2014 18:17:29 GMT+0000 (UTC) }
Jazcash commented 10 years ago

In that case I have a feeling I'm doing it wrong :( My code:

var factory = require('irc-factory');

var api = new factory.Api();
var client = api.createClient('jazbot', {
    nick : "Jazbot",
    user : "Jazbot",
    server : "uk.quakenet.org",
    realname: "Jazbot",
    port: 6667,
    secure: false
});

api.hookEvent('*', 'registered', function(msg) {
    myNick = msg.nickname;
    client.irc.join("#Jaztest");
});

api.hookEvent('*', 'privmsg', function(msg) {
    console.log("<"+msg.username+"> "+msg.message);
    if (msg.message == "!do"){
        client.irc.raw('WHOIS','Jazcash');
        api.hookEvent('*', 'whois', function(msg) {
            console.log(msg)
        });
    }
});

Console output:

<~Jazcash> !do
false
rickihastings commented 10 years ago

Strange indeed, doesn't look like your code. I've pushed an update to the master branch, you can test it by going into your node_modules folder and deleting irc-factory then doing git clone https://github.com/ircanywhere/irc-factory.git

If that works let me know. Hopefully it should fix it.

Jazcash commented 10 years ago

Works now, thanks!

rickihastings commented 10 years ago

Ok just published 1.3.3 with the new patch.