mIRC Home    About    Download    Register    News    Help

Topic Options
#248983 - 09/11/14 12:49 AM Bot reading/identifying mods
Sparkz Offline
Ameglian cow

Registered: 01/08/14
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.

Top
#248984 - 09/11/14 01:01 AM Re: Bot reading/identifying mods [Re: Sparkz]
Nillen Offline
Hoopy frood

Registered: 24/12/13
Posts: 779
Loc: Sweden
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

Top
#248989 - 09/11/14 07:35 AM Re: Bot reading/identifying mods [Re: Nillen]
Bramzee Offline
Vogon poet

Registered: 22/04/14
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.

Top
#248990 - 09/11/14 09:57 AM Re: Bot reading/identifying mods [Re: Bramzee]
Nillen Offline
Hoopy frood

Registered: 24/12/13
Posts: 779
Loc: Sweden
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

Top
#248991 - 09/11/14 03:12 PM Re: Bot reading/identifying mods [Re: Nillen]
Bramzee Offline
Vogon poet

Registered: 22/04/14
Posts: 170
That worked smile Thanks Nillen.

Top
#248992 - 09/11/14 03:20 PM Re: Bot reading/identifying mods [Re: Bramzee]
Nillen Offline
Hoopy frood

Registered: 24/12/13
Posts: 779
Loc: Sweden
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

Top
#248993 - 09/11/14 05:11 PM Re: Bot reading/identifying mods [Re: Nillen]
Bramzee Offline
Vogon poet

Registered: 22/04/14
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.


Edited by Bramzee (09/11/14 05:13 PM)

Top
#248994 - 09/11/14 05:41 PM Re: Bot reading/identifying mods [Re: Bramzee]
Nillen Offline
Hoopy frood

Registered: 24/12/13
Posts: 779
Loc: Sweden
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

Top