Nickserv Login Check

Back to PHP-IRC Feature Requests

Page: 1  
From User Message Body
Addramyr
Post #112
user avatar
Member
Date: 12:52 am, Feb 23 2006
Posts: 43


Need a system so the bot can detect if the user is logged into Nickserv

___________
Addramyr
CEO Skieweb Technologies
http://wwww.skieweb.com
Manick
Post #113
user avatar
Admin
Date: 4:56 am, Feb 23 2006
Posts: 223


Well, I believe this would be better served as a module than as an actual part of PHP-IRC. This is because not all irc servers work the same way, and the only way I could think of standard wise to do it would be to do a WHOIS on the user, but then that would have to run with a timer to catch the response to the whois. You also can't go whoising everybody all the time. That would probably be looked down upon as spam by administrators.

I have done something like this before, but the code is all integrated with mysql and I don't know how useful it would be to you.

--Manick
PHP-IRC Developer
Addramyr
Post #199
user avatar
Member
Date: 3:56 am, May 3 2006
Posts: 43


could be worth a look see :), either that for find a way for php-irc to keep users logged in, appart from being opped etc.... i was thinking of cookies or sessions, but they are not in irc....

___________
Addramyr
CEO Skieweb Technologies
http://wwww.skieweb.com
Manick
Post #202 - Reply to (#199) by Addramyr
user avatar
Admin
Date: 4:51 am, May 3 2006
Posts: 223


Okay, I checked the code and it looks like I was using the STATUS command (which is unique to certain services software) to check registered status. It basically returns 0 if unregistered, 1 if you're using a registered nick, and like 3 if you're fully registered (or something, I'm not sure)

Either way, I don't really have time to write the code here at the moment, but I'll try to do something quick and you can debug it to get it to work.

Here is whois.conf

Code
file whois modules/whois.php

type 318 module function
type 307 module function

318 whois whois_process
307 whois whois_process


Here is whois.php

Code
<?php
class whois_mod extends module {
    private $reggedList = array();
    //This is called by the parser class on 307 or 318, on 318 it calls the callback function provided by user with arguments
    //username, registered (boolean)
    public function whois_process($line, $args)
    {
        $params = explode(chr(34), $line['params']);
        $user = irc::myStrToLower($params[1]);
        switch ($line['cmd'])
        {
            case 307:
                if (isset($this->reggedList[$user]))
                {
                    $this->reggedList[$user]['regged'] = true;
                }
                break;
            case 318:
                if (isset($this->reggedList[$user]))
                {
                    $class = $this->reggedList[$user]['class'];
                    $func = $this->reggedList[$user]['func'];
                    $class->$func($this->reggedList[$user]['user'], $this->reggedList[$user]['regged']);
                    unset($this->reggedList($user));
                }
                break;
            default:
                return;
                break;
        }
    }
    //This function is run by other users, $this->getModules("whois")->whois($line['fromNick'], $this, "my_callback_func");
    public function whois($user,$class,$func)
    {
        $user = str_replace("\n", "", $user);
        $user = str_replace("\r", "", $user);
        $user = str_replace(" ", "", $user);
        $aUser = irc::myStrToLower($user);
        $this->reggedList[$aUser] = array(    'user'        =>    $user,
                                            'regged'    =>    false,
                                            'class'        =>    $class,
                                            'func'        =>    $func,
        );
        $this->ircClass->sendRaw("WHOIS " . $user);
    }
}
?>


Hopefully you can get something working with it.

--Manick
PHP-IRC Developer
Addramyr
Post #211
user avatar
Member
Date: 8:49 am, May 5 2006
Posts: 43


thanks mate... got what i wanted out of it :)

___________
Addramyr
CEO Skieweb Technologies
http://wwww.skieweb.com
empty
Post #686
Member
Date: 6:21 pm, Feb 28 2008
Posts: 9


The code you posted helped me alot with a module I coded, it became alot more efficent.

   

Back to PHP-IRC Feature Requests