rdavydov / Twitch-Channel-Points-Miner-v2

[NEW] A simple script that will watch a stream for you and earn the channel points. A successor of Tkd-Alex's original repo.
GNU General Public License v3.0
1.25k stars 358 forks source link

CHAT_MENTION does not work for Bots #246

Open Cryptic-Soldier opened 1 year ago

Cryptic-Soldier commented 1 year ago

EDIT

The below information is accurate and happens regardless of how the install is done, but I just want to make note that I have since deleted my Replit installs and moved to a RaspberryPi 4 due to security concerns as stated in #245 . I STRONGLY suggest any Replit users read that and be aware.

Describe the bug

So CHAT_MENTION works and shows up in console on Replit or however you have it installed if a USER @'s you.

If a BOT @'s you, there is no notification pushed and it is not picked up in console or any output.

Steps to reproduce

  1. Go to any channel that has a bot that will respond to a ! command
  2. Activate the ! command
  3. See the above problem

Expected behavior

If a BOT in a channel types a message that @'s you then it should be picked up by CHAT_MENTION, and a notification should be pushed. This would be the case in which a BOT announces you as a giveaway winner or literally any reason a BOT would have the need to typed a message @'ing you.

Operating system

Replit

Python version

Replit

Miner version

1.8.0

Other relevant software versions

No response

Logs

https://gist.github.com/Cryptic-Soldier/88f1d4e63b942479c57ed0ebc175c8a6 -- DEBUG Log

https://gist.github.com/Cryptic-Soldier/fcef3d7d5e100edeca32594ae708b6e3 -- CONSOLE OUTPUT

Additional context

Here is an example of where a BOT @ me and nothing was caught in console nor was a notification pushed - https://i.imgur.com/xkjTmGX.png

While I was capturing the above DEBUG and CONSOLE information, I made sure to wait until it collected some points in case the mention in the above screenshot was too fast for the miner to collect. At which point when I saw that the miner had claimed some points, I sent a ! command in the chat to make the bot respond back with an @. This was not caught in console, and is hopefully in the DEBUG.

Cryptic-Soldier commented 1 year ago

Also, I just noticed.. DROP_STATUS does not push to Discord. It DOES push to Telegram though and displays as it does on the console.

DROP_CLAIM does not push to Discord or Telegram, nor does it appear in console unless I'm not reading it right.

rdavydov commented 1 year ago

I see. Bot's messages on your screenshot don't have the colon symbol ":". Looks like they have a different representation than normal public messages. Currently there is nothing in DEBUG logs because the miner simply doesn't log every message in chat. I'll be adding an option to store them and this way we can figure out what format those bot messages use so we can catch them too. Stay tuned.

Cryptic-Soldier commented 1 year ago

@rdavydov If it helps any, that particular bot was coded specifically for that channel by a team of developers for that channel that helps make TwitchPlaysPokemon possible, so that is not surprising that it's not like normal twitch bots. I have not checked other bots in other channels simply because I don't know of any that does this same function as the bot in TwitchPlaysPokemon does.

If I come across some I'll be more than happy to share logs and whatever info I can obtain on it.

EDIT

OH I know why it doesn't have the : It's because when THAT particular bot @'s people it does it through the /me function. I just noticed that because I have FrankerZ, 7TV and BTTV to do things to /me messages.

The lack of a : is a dead giveaway for a /me message. So it seems the script can't see @'s if the user is @'d from a /me chat. Otherwise if it's a normal @ where the : is included then the script works as intended and notifications are properly pushed.

Explains why I could see when users @ me but not this particular bot.

I hope this information helps you.

rdavydov commented 1 year ago

Oh, I see now. /me is the action command, like /me did something. Interesting, need to test those.

Cryptic-Soldier commented 1 year ago

Oh, I see now. /me is the action command, like /me did something. Interesting, need to test those.

So here is another screenshot https://i.imgur.com/XXTxC1s.png These bots did their message normally so the : is included, but no notification was sent to Telegram/Discord and it was not caught by the script.

If a normal user @'s then it is caught by the script and notification pushes as normal. If it is a BOT doing it in any way it's not caught by the script.

I also tested the following.

I can @ myself, and the script catches it and pushes notification.

If I do /me and @ myself, the script doesn't catch it and doesn't push notification.

So that leaves these two problems:

silentguy256 commented 1 year ago

So here is another screenshot https://i.imgur.com/XXTxC1s.png These bots did their message normally so the : is included, but no notification was sent to Telegram/Discord and it was not caught by the script.

I just noticed someone else using Nightbot and not triggering my notifications and was confused, but then I noticed that that bot doesn't actually use @yourname and instead just put in yourname. As you can see you can't click the names of other users mentioned etc and it's just that twitch ALSO highlights messages that just contain your name. My nick is pretty unique so I would like the script to do the same but that might get annoying for people with common names?

EDIT: And now the same bot explicitly said @silentguy256 instead of silentguy256 and it popped up. Guess someone SHOULD make the bots consistent but dropping the check for @ might be easier

Cryptic-Soldier commented 1 year ago

So here is another screenshot https://i.imgur.com/XXTxC1s.png These bots did their message normally so the : is included, but no notification was sent to Telegram/Discord and it was not caught by the script.

I just noticed someone else using Nightbot and not triggering my notifications and was confused, but then I noticed that that bot doesn't actually use @yourname and instead just put in yourname. As you can see you can't click the names of other users mentioned etc and it's just that twitch ALSO highlights messages that just contain your name. My nick is pretty unique so I would like the script to do the same but that might get annoying for people with common names?

Oh yeah I just noticed that these bots don't actually @ the user they just put the name, and mine's highlighting because of how I have FrankerZ and 7TV configured. I think the dev already said in the instance where you are not @ is not possible with the script but I could be wrong.

Obviously each channel will be different depending on how the streamer has the bot outputting the reply in regards to if it's using @user or just the username.

So I tested this again. One where the bot does a /me to @ the user, and the results are interesting...

This was the result of each.

Bot that does it with /me - https://i.imgur.com/bciXTqt.gif

Bot's that @ normally as if they were a normal user - https://i.imgur.com/bxbYZX6.gif

Results from my console output during testing on the channel that the bots do it normally (no need for the one where it does /me we know it doesn't work) - https://i.imgur.com/AP6flVb.png

So as we can see, it appears if the bot @'s normally as a normal user would, the script DOES infact pick it up and push notification.

If the bot just types your username with no @ prefixing it, and/or it does it through the /me function the script cannot see it and doesn't push notification.

silentguy256 commented 1 year ago

I did some research as well. It seems that one can stick this in there to treat "/me" the same as a message. I THINK... The bot api is not that well documented...

    def on_pubnotice(self, _, e) -> None:
        self._pubmsg(e, True)

and the @ SEEMS like it could be solved with changing

if f"@{self._nickname.lower()}" in msg.lower(): to if self._nickname.lower() in msg.lower():

but both are things I can't test right now cause I'm not at a good place to run the code right now

rdavydov commented 1 year ago

if self._nickname.lower() in msg.lower():

Suppose somebody have a nickname like a common word, for example "good". This code will trigger every time somebody writes "good" in their msg. I think @ should stay.

rdavydov commented 1 year ago

Or this can be made as an option in cfg. So much stuff to do already just for the mention. :)

rdavydov commented 1 year ago

Reference: https://github.com/errbotio/errbot/blob/master/errbot/backends/irc.py#L417-L451

MrChuw commented 1 year ago

if self._nickname.lower() in msg.lower():

Suppose somebody have a nickname like a common word, for example "good". This code will trigger every time somebody writes "good" in their msg. I think @ should stay.

Nowadays, it's very rare for people to have usernames with words because basically all of them have been used by users. I don't think this is going to be a big problem.

In my case, where my nickname is mr_chuw and I set to receive notifications for 'mrchuw' in Chatterino, if I'm mentioned somewhere it's probably because someone is talking about trains.

The same goes for "chuw" (which sometimes someone uses to make the train sound).

rdavydov commented 1 year ago

disable_at_in_nickname setting: set to True if you want to check for your nickname mentions in the chat even without @ sign (see README or example.py)

rdavydov commented 1 year ago

For some reason on_pubnotice does not work. 🤔 So we can't catch /me messages (notices) without it.