mIRC Home    About    Download    Register    News    Help

Print Thread
Bot reading/identifying mods #248983 09/11/14 12:49 AM
Joined: Aug 2014
Posts: 32
S
Sparkz Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Aug 2014
Posts: 32
I am currently trying to make a twitch chat bot but there are some issues. There is a problem with [if ($nick isop #)] For that to work, mirc needs to refresh (only does it every minute or so) So if a mod join and tries something straight away, it wont work. Is there a script I can use that reads a file and if a mods name is in the file, it allows them to use it. Thank you.

Re: Bot reading/identifying mods [Re: Sparkz] #248984 09/11/14 01:01 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
alias -l mod {
var %file mods.ini, %nick $iif($1 == add,$2,$1)
if ($1 == add) if (!$readini(%file,#,%nick)) writeini %file # %nick 1
else return $iif(($readini(%file,#,%nick) || (%nick isop #)),1)
}
on *:op:#: mod add $nick
on *:text:*:#: mod add $nick

In your scripts you can now use
Code:
on *:text:!test:#: { 
;if ($mod($nick)) { do stuff }
;else { don't do stuff }
}


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Bot reading/identifying mods [Re: Nillen] #248989 09/11/14 07:35 AM
Joined: Apr 2014
Posts: 170
Bramzee Offline
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
This isn't working for me.

I put the alias into a new remote then did

on *:text:!test:#: {
if ($mod($nick)) { msg # yes }
else { msg # no }
}

It keeps returning no. And anything I put "if ($mod($nick))" on doesn't work.

Re: Bot reading/identifying mods [Re: Bramzee] #248990 09/11/14 09:57 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Try removing the "-l" from the alias. What I can think of is that your events aren't being called from the same scriptfile.
Sorry, that was my miss.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Bot reading/identifying mods [Re: Nillen] #248991 09/11/14 03:12 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
That worked smile Thanks Nillen.

Re: Bot reading/identifying mods [Re: Bramzee] #248992 09/11/14 03:20 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Btw, I just realized when I checked this that there was no check at all for if nick was op to add him to the ini originally in the text event.
Replace what you have with this, and you should probably delete the ini file you have right now, considering that it has everyone who's written in the channel added to it currently.
You can simply type: /remove mods.ini
Code:
alias mod {
var %file mods.ini, %nick $iif($1 == add,$2,$1)
if ($1 == add) if (!$readini(%file,#,%nick)) writeini %file # %nick 1
else return $iif(($readini(%file,#,%nick) || (%nick isop #)),1)
}
on *:op:#: mod add $nick
on *:text:*:#: if ($nick isop #) mod add $nick


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Bot reading/identifying mods [Re: Nillen] #248993 09/11/14 05:11 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Done. Thanks again smile

Quick question though, is my username supposed to be the only one in the ini file?

[#myname]
myname=1


^^that's how it looks.

It's still saying other's are mods when I check them using a quick !ismod* command after they join/type but they're not showing up in the file itself. Guess it's not a big deal since either way it's working. Just curious as to why that would be.

Last edited by Bramzee; 09/11/14 05:13 PM.
Re: Bot reading/identifying mods [Re: Bramzee] #248994 09/11/14 05:41 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
They should get added to the ini file as soon as their either say something in the channel or if they get opped in the channel. Until either of those happen, they won't be in the list. But they will still be counted in in the $mod($nick) since it checks for either in the inifile or as an op in the channel for just this kind of situation.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net