IRC Bot using PircBotx reddit / irc ---------------------------------------------------------------------- xTheAnti · 2013-09-24 21:46 Hello all, I have written a bot that parses a reddit json to get new posts. Only problem I can't figure out is if there is a way for it to check for a new post every one minute. Right now, it only checks every message event. In short, is there some way to always have something looping within pircbotx, that doesn't hinder other processes. Thanks for the help, all. ---------------------------------------------------------------------- I_am_Minthe · 2013-09-24 23:55 This isn't really my domain, but there isn't a /timer 60 option? ala something like mirc scripting has? ---------------------------------------------------------------------- rOOb85 · 2013-09-24 23:58 I've not used pircbotx but I have written many bots with pircbot, so assuming pircbotx is also java (at work on cellphone so cannot research it) you can easily create a timer of sorts in java. Just google around for creating timers or tasks in java. Keep in mind if your timer is part of the main bots thread it *could* lock your bot up. If you still cannot figure it out I can see about digging up some of my old code. ---------------------------------------------------------------------- xTheAnti · 2013-09-25 00:16 See, that is the problem I am running into. I know how to use the timers in java, but the bot is getting locked up at that spot, thus being hindered from its other uses. ---------------------------------------------------------------------- xTheAnti · 2013-09-25 00:18 I am not sure, but I would think that it would get the bot locked up at the one point. I know how to use timers, but I don't want to be hindering the other functionality of the bot by locking it up. ---------------------------------------------------------------------- rOOb85 · 2013-09-25 00:26 You can use what I called "ghetto threads" where you basically just wrap the code that locks it up inside a new thread {code here}. Which I'm sure is horrible and coukd lead to un noticed bugs and stuff. When I get home later ill see about digging up my old code ---------------------------------------------------------------------- xTheAnti · 2013-09-25 00:56 Ah, I see what you are saying to do, and it sounds quite bad, but may be the only solution. ---------------------------------------------------------------------- xTheAnti · 2013-09-25 01:54 Hey man, with what I am doing, ghetto threads just don't seem to be working without instantiating many new bots. Any other help would truly be appreciated. ---------------------------------------------------------------------- rOOb85 · 2013-09-25 04:11 So sorry I forgot to post when I got home! Heres the [code](http://pastebin.com/gPkparXv). Dont blame me if that causes your cat to catch on fire....but that *should* work. Everything in the run(){} is where you want to put your code, also notice the final variables...to use a variable in the thread they need to be final. *edit* all that code is from my bots onMessage(String channel, String sender, String login, String hostname, String message) method. I'd assume pircbotx has something similar. ---------------------------------------------------------------------- xTheAnti · 2013-09-25 11:44 Thank you so much, kind sir. You have just made my day. ---------------------------------------------------------------------- mossman · 2013-09-25 13:53 I have a pretty extensive bot that I've written in Python. This is basically what I do. Before the main loop I fork a new process, that new process handles external events while the main process processes channel events and ping/pongs, etc. ---------------------------------------------------------------------- rOOb85 · 2013-09-25 19:11 Glad it worked for you. :)