Creating an IRC Bot

I’ve created myself an irc bot based off this: http://www.jibble.org/pircbot.php - basically, everytime I try to check myself as an operator this is my code:

 boolean op=false;
        for (User user : getUsers(channel)) {
            if (sender.equals(user.getNick())) {
                if (user.isOp()) op=true;
            }
        }

When I try to run one of my commands like !restrict test - or !addcommand test 123 test. It doesn’t work, but I check if they are operator before hand. Is there anyway to check if they are operator or something wrong with my code?

Are you seeing a +o mode set before the user attempts to execute the command? Example from Pircbot with verbose logging on:

1372110427250 :jtv MODE #channelname +o username

The Twitch chat server is “slow” when setting the op mode when a moderator joins a channel or you join into a channel with the user already there so it might take 30 seconds or more before you receive the +o.

As you can see here, i’m an operator, red is blanked out for usernames.

But yeah, this is basically it.

Are any users being detected as ops? Maybe try iterating through the user list after the bot has been in the channel for a few minutes and display their isOp() status. That would rule out any issues with the framework supporting Twitch’s IRC implementation.

I use Pircbot as well but I’ve had to modify it considerably over the past couple of years to support legacy JTVIRC and now TMI.

Do you think if I personal message you my code, you can check it out?

Am I allowed to private message you it or not?

Try the test I suggested in my last post first.

My friend helped me fix this, thanks!

Hey nice to see that you could solve the problem. Would you mind sharing us your solution?
I have the same problem and cant get it to work :frowning:

Ah i figured it out now too. Pircbot will not update the isOp for me so i overwrote the onUserMode(String, String, String, String mode) method (standard implementation does nothing) and made it add/remove the user to/from a Set. This solution worked for me finally.
Btw: the String mode of onUserMode(…) contains following: “#Channel +o user” (or -o if moderator status was removed)

I use a mIRC bot for twitch and the command i use there to make a vieuwer moderator = .Moderator: say /mod $$1 | say Hello $$1 you have now added to the Moderators.
Natuurlijk als je op twitch life stream wil komen met je bot als moet je die bot moderator maken via the live feed host /mod (username)
If your in your bot channel then you have to register a bot name on twitch it self.

Do you think if I personal message you my code, you can check it out?