Sending a message with custom trigger

40 views
Skip to first unread message

Riley Shumway

unread,
Jul 26, 2018, 9:24:06 PM7/26/18
to pircbotx
Is there a method in pircbotX to send a message without using the event.respond() method? I was looking at this: https://github.com/pircbotx/pircbotx/wiki/Documentation#simple-eventrespond and it shows a bot.sendMessage(channel, "Some Message"); method but that method is undefined for the type PircBotX so I assume that documentation is showing how to migrate from PircBot to PircBotX.

What I need to be able to do is send a message on a different trigger. For example, if I hit a button in my program it will send a message in the connected irc channel. I have managed to make a workaround to this limitation but it's quite inefficient and if there is something in the documentation that I overlooked that will allow this behavior it would be much better.

Rob Porter

unread,
Jul 27, 2018, 9:31:44 AM7/27/18
to pirc...@googlegroups.com
I use this to send directly

this.pircBotX.sendIRC().message("#channel", "message");

On Thu, Jul 26, 2018 at 9:24 PM, Riley Shumway <dragonhe...@gmail.com> wrote:
Is there a method in pircbotX to send a message without using the event.respond() method? I was looking at this: https://github.com/pircbotx/pircbotx/wiki/Documentation#simple-eventrespond and it shows a bot.sendMessage(channel, "Some Message"); method but that method is undefined for the type PircBotX so I assume that documentation is showing how to migrate from PircBot to PircBotX.

What I need to be able to do is send a message on a different trigger. For example, if I hit a button in my program it will send a message in the connected irc channel. I have managed to make a workaround to this limitation but it's quite inefficient and if there is something in the documentation that I overlooked that will allow this behavior it would be much better.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Riley

unread,
Jul 28, 2018, 9:28:48 AM7/28/18
to pircbotx
I feel I have totally missed an important aspect of PircBotX. The way I have been using the bot is creating a configuration then starting the bot with that configuration and using the listener I put in the configuration to handle all the logic of the bot. Doing it that way I can not put something like what you put into the listener.

I tried putting what you said after starting the bot but it never gets to it since I did pircbot.startBot(); right before it.

What am I missing, my code looks a lot like this one with how it makes a configuration and a listener: https://gist.github.com/tombowditch/a3f704ae5bcc7fac872b4c2b6e0e7766
To unsubscribe from this group and stop receiving emails from it, send an email to pircbotx+u...@googlegroups.com.

Riley

unread,
Jul 28, 2018, 9:48:28 AM7/28/18
to pircbotx
Looking more into that method in the documentation and examples I found that I can do event.getBot().sendIRC().message(Channel, Message); but this still does not solve my issue. This is still only able to be done on one of the triggers such as onGenericMessage and onConnect. I need to be able to do it whenever with my own trigger.


On Friday, July 27, 2018 at 8:31:44 AM UTC-5, Jenga wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to pircbotx+u...@googlegroups.com.

Robert Porter

unread,
Jul 28, 2018, 11:35:30 AM7/28/18
to pirc...@googlegroups.com
Could you define what your own trigger looks like?
Either a timed task, some internal state being met, or something external possibly from IRC.

The PircBotX object reference can be passed into any other object or thread to send messages directly.


To unsubscribe from this group and stop receiving emails from it, send an email to pircbotx+unsubscribe@googlegroups.com.

Riley

unread,
Jul 28, 2018, 8:39:13 PM7/28/18
to pircbotx
Oh my gosh, why did I not think of that? I had the dumbest work around with a while loop that would last till the program was told to shut down and putting that inside of the on connect event then check the trigger there. That was so bad. I didn't realize that I could pass the event to another object then use what Jenga said with event.getBot().sendIRC().message(channel, message); to be able to make my custom trigger there.

It should be working in a much better way now. Thanks.
Reply all
Reply to author
Forward
0 new messages