IRC Bots, Java Game Query and Control Libraries, and More ...
Sign Up!
Welcome to
Monday, August 21 2017 @ 01:27 AM CDT

 Forum Index > > PircBot
 "Pause" Thread and wait for ServerResponse?
 |  Printable Version
By: libor (offline) on Tuesday, December 06 2011 @ 08:41 AM CST (Read 10354 times)  



i just started with the pircbot and at first i wanted to say: great project!


I try to write a bot so he can react on whether the message has been sent by a user that is authed [quakenet] or not. I tried this with the following functions:

So my problem is, that if the bot receives the message, i have to wait for the check if the user is authed.

I do this with the "onServerResponse" Method.

But if i got both methods in right now, the field "currentauth" is always null (as initialized).


Maybe i am just blind, but thanks in advance!




PHP Formatted Code

protected void onMessage(String channel, String sender, String login, String hostname, String message)
                List<String> participants = new ArrayList<>();
                                sendMessage(sender, "You wrote my name!");   
                        // do a whois to check whether the user is authed
                        sendRawLine("WHOIS "+ sender);
                        currentuser = sender;

                        // Thread.sleep or something?

                        // he is
                        if (message.startsWith(this.getNick() + " hello"))
                                // call another method that does something
protected void onServerResponse(int code, String response
                 if(code == 330)
                   String[] parts = response.split(" ");
                   System.out.println("User "+ parts[1] +" is authed as "+ parts[2]);
                   currentauth = parts[2];
                   currentuser = parts[1];


Forum Newbie

Status: offline

Registered: 12/06/11
Posts: 2

Profile Email    
By: DeadEd (offline) on Thursday, December 08 2011 @ 05:22 AM CST  



Pausing the PircBot thread, literally, isn't a great idea as the ping/pong with the server is dealt with here, so you run the risk of having the bot timeout if it is too busy to respond to the IRC server.

As a start, I'd like to point you at a a PircBot Demo ( ) named GetHostmaskBot.  This shows how to get that WHOIS info and store it.  You could make your own object to be stored there with any info you like in to help decided how to proceed when you get it.  Then it is also available next time the user asks for a command so no need to lookup again (although you should then pay attention to parts, nick changes, etc to keep the authed list updated).

See if that helps you out and ask if it's not clear.

Forum Moderator

Status: offline

Registered: 06/01/04
Posts: 602

Profile Email Website  
By: libor (offline) on Thursday, December 08 2011 @ 02:19 PM CST  



thanks for you're help - i handled the problem Wink



Forum Newbie

Status: offline

Registered: 12/06/11
Posts: 2

Profile Email    

 All times are CDT. The time is now 01:27 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

My Account

Sign up as a New User
Lost your password?

What's New


No new stories

Comments last 2 days

No new comments

Files last 14 days

No new files
No new comments

Links last 2 weeks

No new links