PircBotX with Custom Bot Manager Program - Errors as explained in OP

32 views
Skip to first unread message

Xyspade

unread,
Feb 17, 2015, 11:50:37 PM2/17/15
to pirc...@googlegroups.com
I am using the PircBotX framework for my IRC bot, and since my completed bot will be hosted on a different PC that is not mine, I decided to create a custom bot manager program with a GUI for my private use and management of the bot without coming onto the IRC.  I used VB.NET for the manager because I am most familiar with that language in this point in time.

I set up a ServerSocket on the bot and a client socket on the manager.  The way the two programs will communicate is by sending strings of code through these socket streams.  Right now I don't have any real features set up because I'm still in the testing phase of the functionality of these sockets.  Attached to this post you can find my current code for the bot and the manager.

What currently happens is, if I click the connect button in the bot manager, it will connect successfully.  If I click the test button, it's supposed to send "a" through the socket stream, but doesn't.  When I click the disconnect button, it then sends "a" through but it doesn't do anything (it's supposed to change the value of String "things" to "a") and sometimes, immediately after, i get a NullPointerException.

So I hope to fix this and ask, what is the simplest way I would be able to fix this and get messages sent through the socket correctly, and then get the bot to interpret them correctly?  Thank you for your assistance.
manager.txt
bot.txt

Leon Blakey

unread,
Feb 18, 2015, 12:31:33 AM2/18/15
to pirc...@googlegroups.com
I think your a little confused on the Java side
  1. while (br.readLine() == null) does not do what you think it does. First, readLine() will only return null when the socket is closed so that whole loop was never being executed. Second, the text that was on the network was fetched in that one readLine() call, it doesn't exist anymore when you call it again in the if statement below or a 3rd time for the commandInput variable below that. You probably want String line; while((line = br.readLine()) != null) { //do stuff }
  2. You're creating multiple botri instances for some reason in onConnect() and Input.run() and are just going to confuse yourself even more. Use only one instance and pass that around if you need to share information.
  3. someThread.join() will block the current thread until someThread finishes executing. You probably want to remove that as well.
  4. e.printStackTrace() gives significantly more detail than System.err.print(e)

Test that it works with telnet first before bringing in VB.NET. There's too many things that can go wrong otherwise

This mailing list isn't really for teaching Java though. If you still have questions the Java tutorials, StackOverflow, the ##java channel on freenode, reddit, or a friend would be better resources.

If you fix all that and it still doesn't work my only guess is on the VB.NET site your not sending the newline and/or not flushing the socket buffer. It's been a very long time since I've used VB so I can't help you there

Hope this helps
-Leon


--
You received this message because you are subscribed to the Google Groups "pircbotx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pircbotx+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xyspade

unread,
Feb 18, 2015, 11:32:09 PM2/18/15
to pirc...@googlegroups.com
Thank you so much for your assistance, and I apologize about asking here rather than somewhere else like Stack Overflow.  I've used Stack Overflow before but I thought since this involved PircBotX that might be the wrong place to ask.  I will be sure to consider what I am asking about more carefully next time.

I invoked all of your suggestions and now everything works properly and there are no exceptions reported.  The only thing is, if I issue the command `things in the IRC channel now, the bot still says that things is equal to nope.  I know that line of code that is supposed to manipulate things is being executed because it prints "things equals a" to the console.  Is there anything else I can do?

Xyspade

unread,
Feb 19, 2015, 8:31:52 PM2/19/15
to pirc...@googlegroups.com
Never mind, it works perfectly now.  Thank you again!
Reply all
Reply to author
Forward
0 new messages