Function Problem! Please help me!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
XenonTW
Forum Newbie
Posts: 1
Joined: Mon Jan 13, 2003 11:43 am
Contact:

Function Problem! Please help me!

Post by XenonTW »

Hi @ll

I'm a newbi in php and I want to register a nickname to the nickserv of my IRC-Serv.
I'm using an "IRC client module for PHP IRC clients" and it's working ok.
But on my register page I have got a little problem:

I want show the User only something like "Your nick is registered" or "Sorry, but this nick is already registered" and not the whole Server-Message.
The Server Message I got with a callback function:

irc_add_callback(IRCCB_ONNOTICE, "privmsg_callback");
function privmsg_callback($code, $nick, $identd, $host, $destination, $text)
{

if ($text{2} == "e") {
print "Dein Nick wurde erfolgreich registriert!";
} else {
print "Dieser Nick ist leider schon vergeben, bitte wähle einen anderen";
}

}

(the Server message begins with "The" if the nick is registered)

I thought I could use an easy "if else" but I get this output on my register page:

Dein Nick wurde erfolgreich registriert!Dein Nick wurde erfolgreich registriert!Dein Nick wurde erfolgreich registriert!Dein Nick wurde erfolgreich registriert!

It seems that the function loops or so but why? And how I can make it that the function stops after it done his job?

Please help me and excuse me for my terrible english :oops:

Thanks!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

hopefully I found the module you're using ;)
http://cad.ntu-kpi.kiev.ua/chat9/documentation.html ?

why do you register a function called privmsg_callback for the event ONNOTICE? Did you register this callback elsewhere in your code?

In the code-snippet is no loop and there for no reason for that behaviour.
How fast does it repeat the message( e.g. "once every 10 sec." or "the screen is filled immediately with this message" or ... )

Maybe you have to narrow the trigger

Code: Select all

function privmsg_callback($code, $nick, $identd, $host, $destination, $text)
{
	if ($code==IRCCB_ONNOTICE AND $nick=='NickServ')
	{
		if ($text{2} == 'e')
			print 'Dein Nick wurde erfolgreich registriert! ';
		else
			print 'Dieser Nick ist leider schon vergeben, bitte wähle einen anderen ';
	}
}
what happens if you invoke another command from within the callback, e.g. irc_ison('NickServ');

You see: only guessing but since no one else answered....... ;)
Post Reply