mIRC Homepage
Posted By: darthclide Whisper with mirc bot - 07/06/17 04:09 AM
I don't know what I am doing wrong, but I can't get my bot to whisper a user when the enter the channel. I thought msg would work just fine? Can anyone tell me what is wrong?
Code:
 
on *:join:#:{
  if ($nick !isin $read(UserList.txt, 1)) {
    msg $chan $nick If a person you do not know slanders a streamer or his viewers, go to your settings -> security https://www.twitch.tv/settings/security and at the bottom of the page block messages, whispers, and invites from people you do not follow. Hit "Save Changes" after you finish.
    write UserList.txt $nick
    }
Posted By: maroon Re: Whisper with mirc bot - 07/06/17 06:41 AM
msg $chan is the same as typing into the channel window
msg $nick opens a query window, which is probably not what you mean by "whisper".

I'm guessing by whisper that you mean
notice $nick
Posted By: darthclide Re: Whisper with mirc bot - 07/06/17 07:42 AM
When I try that command, it says "unknown command".

Also, I found out that 'write' does not detect duplicates. Any suggestions on an easy way to just compile a list of users that join the stream? And an easy way to compare that list to a user joining the stream?

The only other way I can think of is using writeini, and giving each user a value of "1". (I don't think you can use writeini without a value?)
Posted By: darthclide Re: Whisper with mirc bot - 08/06/17 12:17 AM
Anyone have an idea on why I can't whisper with my bot? I can type .w darthclide message into the window and it works, but I can't get it to work in the code?
Posted By: maroon Re: Whisper with mirc bot - 08/06/17 01:33 AM
NOTICE is a command, as you can see with:

/help /notice

So you shouldn't see that error unless you have a badly written alias to replace it, or you typed it badly. Type this in any window:

//notice $me test

This should send a message to yourself. If you still get "unknown command" check to see if you've somehow created an alias of the same name:

//echo -a $isalias(notice) $isalias(notice).fname

If it says $false then you haven't replaced /notice with an alias, but if it says $true, it also shows you which file contains that alias. It's possible for the right combination of lines following a missing/extra curly-bracket in aliases.ini to confuse mIRC into thinking you've created an alias for something.

---

If your list is short enough, an easy way to detect duplicates is a %variable that can have max length of around 4000 before getting an error, so probably around 300-400 users. It's simplest to have the tokens separated by the space character, ASCII 32.

set %userslist $addtok(%userslist,$nick,32)

if someone changes their nick while in channel and you want the list to contain the new nick:

set %userslist $reptok(%userslist,$nick,$newnick,1,32)

You can't writeini without writing something, regardless whether the 'item' already exists in the .ini, so you could either write 0 or $false to it. or use remini to delete a section or item.
Posted By: maroon Re: Whisper with mirc bot - 08/06/17 01:36 AM
whisper isn't an mirc command. If you want help with a human-created alias, you'll have to show the code.
Posted By: darthclide Re: Whisper with mirc bot - 08/06/17 07:28 AM
All I want is to send a whisper from my bot, to a viewer. As I said before ".w username message" works just fine if I type it into the window.
Posted By: darthclide Re: Whisper with mirc bot - 08/06/17 07:37 AM
If I try the notice command in the window it says
-> -darthclide- hello

in the chat window, but in the status window it says
NOTICE Unknown command

No message is sent. Not a private message (which I do not want) or a whisper (which I do want)

It says $false when I do your command, which I already knew the answer to. All of my aliases are unique, I make sure of that.




My list will grow indefinitely as I will be logging every person who comes into the stream. It looks like I will have to just set each username with a value of 1, and cycle through the list everytime a user enters the channel. To ensure that a person does not receive the whisper every time they join.
Posted By: KubosKube Re: Whisper with mirc bot - 08/06/17 01:48 PM
Have you tried sending a normal chat message prefaced with /w? I've had a lot of luck with the following:
Code:
msg $chan /w username message
Posted By: maroon Re: Whisper with mirc bot - 08/06/17 09:45 PM
Your answer seems a contradiction. Your mIRC is recognizing and not-recognizing the /notice command at the same time.

If I did
//asdfg $me test

There would be nothing in the way of a "->" message on screen, so the fact that you're getting that arrow message tells me that your mirc knows that /notice is a communications command. But on the other hand, you're visually seeing the message in status window that NOTICE is an unknown command.

The only way I can see both being true is if you have something that intercepts the ON NOTICE command and mutes it so you can't see the notice being received by you. I suspect that if you have another person willing to test with you, that if you did /notice that-nick message, that they would see it.

For NOTICE to be at the same time an unknown command - one way this could happen is if you have an alias trying to send a notice, except it has an alt-160 touching the /notice, so it looks like NOTICE is an unknown command, but what's really unknown is NOTICE $+ $chr(160)

As for your trouble with /w or /whisper, these are not mirc commands, they have to be an alias you created, and without letting us know what it is, we can't help with it.
Posted By: darthclide Re: Whisper with mirc bot - 08/06/17 11:10 PM
I have no aliases using the word "notice" anywhere in my script, but I will post it here for you to look through. For the record, the exemptions to usernames are for persistent trolls who stick around more than a few months after being banned.

I also know it is a mess, but until my stream gets bigger, I can't be bothered to optimize it.

https://pastebin.com/Mn5X2YGS
Posted By: maroon Re: Whisper with mirc bot - 09/06/17 12:02 AM
thanks. I see this is 'a' script. I see it doesn't mention 'notice'. However it also doesn't contain the /w alias either. It does mention it once, but is used improperly. When you do:

/msg $chan /w message

It's the same as someone chatting into channel: /w message or typing in channel window:

/say /w message

So it's showing everyone "/w" instead of doing the mysterious whisper - which must be a handmade alias because it's not part of mIRC. You've got some other script messing around with the notice command, but that's a separate item.
Posted By: darthclide Re: Whisper with mirc bot - 09/06/17 12:02 AM
You can look at my code getUser setUser and I have no idea why
1. No file is created, or written to
2. Why the bot shows this in the window?
<@darth_bot> /w the_mighty_salad I am darthclide's bot, let me know if you received this whisper

But if I manually create a command that uses:
msg $chan /w username message

It does not show anything in my window (indicating it actually sent?)
Posted By: darthclide Re: Whisper with mirc bot - 09/06/17 12:53 AM
There is only 1 script file. Everything you see there is all that exists.

So how do I modify /w in the aliases section to do what I want?
Posted By: maroon Re: Whisper with mirc bot - 09/06/17 01:38 AM
1. You're using the identifier format for getuser but the dollar is missing, so the code is setting %here_before to the literal string "getUser($chan,$nick)" without the channel and nick being evaluated.

Since that variable is never going to be the numeral 1, it always branches here, where it tries to execute the literal alias "setUser($chan,$nick,1)" which doesn't exist.

2. As for your manual command, without 2 forward-slashes it types into channel that literal text.

It also types the text beginning with /w into channel instead of executing the /w alias, which you've never shown us whether it's a /notice or what it does. If you precede with 2 forward slashes but type that in status window, $chan is $null, and it tries to send a message to a nick named /w.
Posted By: maroon Re: Whisper with mirc bot - 09/06/17 01:44 AM
so /w is in aliases tab of remotes window? show us what it looks like.

Reminder that in aliases tab everything is like

/aliasname {
stuff
}

instead of
alias aliasname {
stuff
}
Posted By: darthclide Re: Whisper with mirc bot - 09/06/17 02:23 AM
/w /whois $$1

That is how it appears in the aliases tab.

And all my aliases are fine as you can see. I have no idea why my writeini will not do anything? smirk
Posted By: maroon Re: Whisper with mirc bot - 09/06/17 02:52 AM
so now i finally see what you're calling a whisper.

a WHOIS is a message sent to the server to get the ip address and 'name' of a user. The person you do a /whois on - does not see the results of this, nor does not even know you're doing a /whois on them. The exception is that a small handful of server admins running the irc server are able to see when someone does a /whois on them.

Normally, the reply to "/whois nick" appears in status window, with the exception that if mirc-options/irc/show-in-active has a checkmark next to "whois", then the reply would show in your active channel.

As for your problem with notice being an invalid command, I noticed your answer showed you didn't paste my example, because my example used "test", but your answer used "hello" instead. Can you see if you still get the unknown command error if you use notice like this:

Code:
//notice $me TEST

Posted By: darthclide Re: Whisper with mirc bot - 09/06/17 03:37 AM
I did exactly what you typed and it still says unknown command.

And still nobody has told me how to whisper someone with my bot? I have pasted my code. I have pointed to the relevant pieces of code: getUser setUser

This is very simple I thought?
Posted By: KubosKube Re: Whisper with mirc bot - 09/06/17 04:11 AM
Quote:
And still nobody has told me how to whisper someone with my bot?

If the goal is to send a Whisper over the Twitch Messaging Interface(TMI), then just send a normal chat message using the 'msg' command in mIRC.
Code:
msg #darthclide /w darthclide I whisper sweet nothings in your ear... er uh, beep boop, I'm a robot?
Posted By: maroon Re: Whisper with mirc bot - 09/06/17 06:20 AM
There's a difference between the getUser($chan,$nick) you used and

$getUser($chan,$nick)

Without the dollar, mIRC thinks you're trying to execute an alias name getUser($chan,$nick) without passing any parameters to it.


Unless there's something that twitch servers handle differently than mIRC, I can't see why an IRC server doesn't recognize NOTICE as a 'real' command that lets irc clients send non-query communications to each other, or why asking the server to do a /whois on someone would be related to whispering something to them.

I've been explaining things as if twitch were just an interest-group happening to also be using mirc. But from looking at a website describing the twitch interface, it appears that any advice you need related to your mirc's interaction with a twitch server might need to come from another twitch user. However, the reason why getUser($chan,$nick) without the dollar is a syntax error is an internal mirc issue that has nothing to do with using a twitch server or a standard server.

If you go somewhere like irc.freenode.net you'll see that "//notice $me test" is a real command. Whether it's also real at a twitch server is something else.
Posted By: darthclide Re: Whisper with mirc bot - 09/06/17 08:30 AM
I took it most people used mirc with twitch (which is why I bought it originally), but I guess you just wrote a lot that just means "I have no idea why the notice command is doing that".

Here is the relevant code that should be working, but viewers report receiving no whispers. What could possibly be going wrong?

Code:
on *:join:#:{
  if ($nick != ignorednick) {
    var %here_before = $getUser($chan,$nick)
    var %setone = 1
    if (%here_before != 1 || %here_before == $null) {
      .msg /w $nick I am darthclide's bot, let me know if you received this whisper
      var %receive_return = $setUser($chan,$nick,%setone)
    }
  }
}

alias -l getUser {
  var %chan = $$1
  var %user = $$2
  var %boolvalue = $readini(UserList.ini,n,%chan,%user)

  if (%boolvalue == 1) {
    return %boolvalue
  }
  else {
    return 0
  }
}
alias -l setUser {
  var %chan = $1
  var %user = $2
  var %settrue = $3
  var %checkvalue = $readini(UserList.ini,n,%chan,%user)

  if (%checkvalue != 1 || %checkvalue == $null) {
    writeini -n UserList.ini %chan %user %settrue
    return %settrue
  }
}
Posted By: Blas Re: Whisper with mirc bot - 09/06/17 12:03 PM
I never bothered to learn how to script whispers with mIRC. SReject already did it and made his script available publicly. Simply install mTwitch.Core.mrc. You're done. You can now send and receive whispers using the standard IRC format of /msg. https://github.com/SReject/mTwitch
Posted By: KubosKube Re: Whisper with mirc bot - 09/06/17 12:49 PM
Quote:
What could possibly be going wrong?

I think the problem is the "on Join" bit.

I've never seen anyone else's name but that of my bot in the users list.
Try a small test code to at least make sure the whispers work, such as
Code:
on *:TEXT:!test:#: {
  msg $chan /w $nick This is an automated bounceback. Thanks for checking with me!
}

I think this is what you might be having trouble with, but as you can see, I'm not even one year old in mIRC. I'm just relaying the troubles I've had as a Twitch streamer.
Posted By: KubosKube Re: Whisper with mirc bot - 09/06/17 01:21 PM
I believe that what you are trying to do is somewhat similar to what I tried to do when I first started coding. When I realized that the "on Join" wasn't working for me, then I made this script to serve my purpose.
When I have something new I want to say, then I just type "!update 0.5 I added some stuff.", and the next time someone chats in my channel, it whispers them "Welcome to StreamBot v0.5! Changelog: I added some stuff."
Code:
on *:TEXT:!update*:#: {
  if ($nick == kuboskube) {
    set %Version $$2
    set %Changelog $$3-
  }
}

on *:TEXT:*:#: {
  if (%Version. [ $+ [ $nick ] ] != $null && %Version. [ $+ [ $nick ] ] == %Version) {
    goto VersionChecked
  }
  set %Version. [ $+ [ $nick ] ] %Version
  msg $chan /w $nick Welcome to StreamBot v [ $+ [ %Version ] $+ [ ! ] ] Changelog: %ChangeLog
  :VersionChecked
}
Posted By: darthclide Re: Whisper with mirc bot - 09/06/17 11:27 PM
So you guys know, the code is activating just fine now. My UserList is updating correctly. So thankfully it is not an "on join" issue (but depending on what twitch does I might have to change it to "on text")
Posted By: darthclide Re: Whisper with mirc bot - 09/06/17 11:32 PM
However, the whispers are still not working. But about SReject's code: You say that I can use /msg to send whispers, but that is the command I use to send messages globally for everyone to see in chat? And looking at the mTwitch.Core.mrc code, I do not see any alias anywhere called /msg What exactly does that code do? And how do I send whispers with it?
Posted By: Blas Re: Whisper with mirc bot - 11/06/17 12:53 AM
Originally Posted By: darthclide
However, the whispers are still not working. But about SReject's code: You say that I can use /msg to send whispers, but that is the command I use to send messages globally for everyone to see in chat? And looking at the mTwitch.Core.mrc code, I do not see any alias anywhere called /msg What exactly does that code do? And how do I send whispers with it?

You would just do:
Code:
/msg username message
Posted By: darthclide Re: Whisper with mirc bot - 11/06/17 04:11 AM
So... Due to testing with KubosKube, we discovered we can only send whispers between our bots and ourselves. For example:
KubosKube <-> KubosKubot
darthclide <-> Darth_Bot

But whispers do not work for anyone else. Can you or anyone please tell me what hidden piece of mirc is causing this to happen?
Posted By: FroggieDaFrog Re: Whisper with mirc bot - 11/06/17 08:41 AM
As part of twitch's spam protection, by default, a user has to be following the user/bot for them to receive whispers that from that user/bot. That is: For UserA to receive whispers from UserB, UserA must be following UserB.

Users can toggle this in their setting: https://www.twitch.tv/settings/security
Posted By: KubosKube Re: Whisper with mirc bot - 11/06/17 02:34 PM
Hey Darthclide,
I signed my bot(KubosKubot) up for 2-Factor Auth, and some folks say that whispers can't be sent from a bot unless the bot is whispered first. Maybe that's our issue? Next time you're online, I'll whisper your bot and we'll see if that works. I only mention this because perhaps in our efforts to ensure our bots work(like a responsible coder should), perhaps we opened the figurative window on accident for our bots to send us whispers, and since we only need open the window once, we haven't noticed the "pattern".

I know this is a janky workaround, but any workaround is better than no workaround.
Posted By: darthclide Re: Whisper with mirc bot - 12/06/17 09:51 PM
Hmmm, this is definitely not what I wanted. There has to be some mirc wizard who figured this out. If on twitch.tv I can send a whisper to a user I never wrote to before (as I proved true with Kubos), then there is absolutely no reason why a bot can't do the same.

If anyone wants to continue using my channel as a guinea pig, please do so. I want this experience to help others too.
Posted By: KubosKube Re: Whisper with mirc bot - 12/06/17 10:02 PM
The pattern other users devised was that Twitch does not allow IRC connections to open the figurative two-way door of whispers.

I feel as if the solution to our problem(making the bot speak first through a whisper), as much as we joked about it, may ironically be with sockets. sick

If a socket wizard could make a script to send a whisper in a more human way than IRC, then I'll bet Twitch would let it open a new whisper-chat as if by human.
Posted By: darthclide Re: Whisper with mirc bot - 12/06/17 10:13 PM
It does indeed Kubos. If we can somehow fake twitch into thinking the bot is a human, then I think our problem is solved.

On a related note, I am sending 3 unique whispers one after another with my script. As long as I am not being raided, twitch won't ban me for sending 3 whispers at once will they? Or would it be a better idea to add a 1 second delay between each one?
Posted By: darthclide Re: Whisper with mirc bot - 14/06/17 05:51 AM
So anybody out there who is a master with mirc want to help us out? I am sure somebody has the skills to help us get our whispers working properly.

Kubos is content with getting his bot to receive whispers, but I need my bot to send whispers. Both of us are curious about how to do this.
Posted By: darthclide Re: Whisper with mirc bot - 20/06/17 02:36 AM
Still no takers for the challenge? I would be willing to pay a little money for someone who can figure this out.
Posted By: zapdos26 Re: Whisper with mirc bot - 02/07/17 03:12 PM
Is this for Twitch? Because if it is for Twitch, please read the following https://discuss.dev.twitch.tv/t/have-a-chat-whisper-bot-let-us-know/10651
© mIRC Discussion Forums