mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
help with queue/line system for twitch #261792 25/11/17 10:48 AM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
hey there, i just need a little bit of help with this script that i found and am borrowing because it works really well with what i'm trying to do on twitch.

i modified it a little bit to fit how i would want it, here's the script:


Quote:
on *:text:!join:#: {
if ($read(list.txt,nw,$nick)) { msg $chan $nick is already on the list. | return }
else write list.txt $nick
msg $chan Added $nick to the list
}

on *:text:!del *:#: {
if ($nick isop #) {
if (!$read(list.txt,nw,$2)) { msg $chan $2 is not in the list. | return }
elseif ($read(list.txt,nw,$2)) { msg $chan deleted $2 from the list.
write -dl $+ $readn list.txt }
}
}

on *:text:!list7:#: {
if ($nick isop #) {
var %t1 $read(list.txt,1)
var %t2 $read(list.txt,2)
var %t3 $read(list.txt,3)
var %t4 $read(list.txt,4)
var %t5 $read(list.txt,5)
var %t6 $read(list.txt,6)
var %t7 $read(list.txt,7)


msg $chan %t1 %t2 %t3 %t4 %t5 %t6 %t7 }
}


on *:text:!list3:#: {
if ($nick isop #) {
var %t1 $read(list.txt,1)
var %t2 $read(list.txt,2)
var %t3 $read(list.txt,3)

msg $chan %t1 %t2 %t3 }
}


on *:text:!clear:#: {
if ($nick isop #) { write -c list.txt
msg $chan list reset. }
}



is there a way to add onto this script-- where i can type "!next3" or "!next7" to advance the list and show the names for the people who are up next? simultaneously clearing their names out of the list as well? hopefully that makes sense, sorry i'm not very good with words..! oh and also, a script/command for people in the chat to be able to delete themselves from the list instead of mods having to do it for them? any help would be greatly appreciated

edit: i feel like i'm asking for so much omg, but also a command for people in the chat to be able to know where they are in the list? thank you..!

oh and while i'm at it.. a command for mods to open and close the list? would be wonderful.

Last edited by kouyachi; 25/11/17 10:59 AM.
Re: help with queue/line system for twitch [Re: kouyachi] #261794 25/11/17 08:04 PM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
I don't use twitch, but nothing here seems specific only to twitch, as long as I'm correct with my guess that "mods" means the same thing as when the script has "if ($nick isop #) {".

My priorities in writing this code is not to make it efficient, but to keep it easily read and to keep it similar to the existing code.

1. I assume 'open' and 'close' a list means disabling the ability for anyone to type !join or other !commands to change the lists. You can easily do this by setting a variable to close the list, or unsetting the variable to open again. You would choose a variable name which is not likely used by any other script. You would insert as the first command of every event (except the event which turns the list on/off), a line which checks whether the list is open:

Code:
if (%list.status == closed) { Msg $chan Sorry $nick the list is closed | return }


This means your !join event now looks like:

Code:
on *:text:!join:#: { 
  if (%list.status == closed) { msg $chan Sorry $nick the list is closed | return }
  if ($read(list.txt,nw,$nick)) { msg $chan $nick is already on the list. | return }
  else write list.txt $nick 
  msg $chan Added $nick to the list
}


You can then open and close the list like:

Code:
on @*:text:!open *:#: {
if (%list.status != closed) { msg $chan The list is already open | return }
unset %list.status
msg $chan OK $chan the list is now open!
}


Code:
on @*:text:!close *:#: {
if (%list.status == closed) { msg $chan The list is already closed! | return }
set %list.status closed
msg $chan Sorry $chan the list is now closed!
}


The @ prefix means the above event does not trigger if not typed by an OP/Mod, so there is no need to check if $nick is an Op.

Since you already are using the code you pasted, you already know that the TEXT event cannot see any !commands typed into channel by the nick running the script. They can open and close and clear the list typing in the editbox of that channel /listopen or /listclose or /listclear after the script contains these lines:

Code:
alias listopen  { unset %list.status        | msg $chan List is now open! }
alias listclose { set   %list.status closed | msg $chan List is now closed! }
alias listclear { write -c list.txt | msg $chan list reset. }


2. Someone finding their own position will be similar to the !join event except telling them where they are on the list instead of deleting them. You can change the !word and messages in my examples to something you prefer:

Code:
on *:text:!findme:#: { 
  if (%list.status == closed) { Msg $chan Sorry $nick the list is closed | return }
  if ($read(list.txt,nw,$nick)) { msg $chan $nick you are on the list in position $readn $+ . | return }
  else msg $chan Sorry $nick you're not on the list. You can add yourself by typing: !join $nick
}


3. If I understand you, !next7 would be the same as !list7, except it also deletes the first 7 nicks from the list after showing the list of 7 nicks to the channel. I will make the event to allow 1 event to perform for both 3 and 7, or any other number from 1-10. For example, if you used "!next 7" to display and delete 7 names, but 1 of the 7 was in the channel but not responding, if the mod wants to grab 1 more name from the list, they can use "!next 1". Also, if one of the nicks on the first 3 lines have left the channel, you would want to skip them and grab the 4th person instead without listing the missing nick. The trigger will be "!next 3" or !next 7" or any number from 1-10. And again, the @ prefix avoids the need for coding to check if someone is an OP:

Code:
on @*:text:!next *:#: {
  if (%list.status == closed) { msg $chan Sorry $nick the list is closed | return }
  var %namecount = 0 , %line 1 , %max $int($2) , %names
  if (%max !isnum 1-10) { msg $chan must give number 1-10, like !next 7 | return }
  while (%namecount < %max) {
    var %t $read(list.txt,ntw,%line) 
    if ((%t != $null) && (%t ison $chan)) { var %names %names %t | inc %namecount }
    if (%t == $null) { break }
    else write -dl $+ %line list.txt
    ;else inc %line
  }
  msg $chan $calc($line(list.txt,0)) still on the list. Next $numtok(%names,32) names: %names
}


The above code can list+remove the next 7 names with: !next 7
or list+remove the next 3 names with: !next 3 (There must be a space between '!next' and the following number.) The only reason I used $calc() in this script is to force a blank value to become 0.

The above code can also be used to replace your !list7 and !list3 keywords. You would copy the entire event so you have 2 duplicate events in your script, and you only need to make 2 changes to make the 2nd duplicate become your !list event: You must alter the first line changing !next into !list. You must also delete the line beginning with "else write" and remove the semi-colon from the following line beginning with ";else". (Semi-colon at the beginning of an entire script line changes the entire line into a comment which does not execute.) The first change makes this event to respond to !list instead of !next. The second change makes it skip to the next line of list.txt instead of deleting the first line. Your syntax for list names at the top of the queue would change from "!list7" to "!list 7", and you would not need your old 2 events for the large and small groups. (A space must be between '!list' and the number.)

4. To remove yourself from the list will be similar to the way someone uses !join to add themselves:

Code:
on *:text:!listdel *:#: {
  if (%list.status == closed) { msg $chan Sorry $nick the list is closed | return }
  var %name $nick
  if (($nick isop $chan) && ($2)) { if ($2 ison $chan) { var %name $2 } | else { msg $chan $2 is not on channel | return } }
  elseif (($2) && ($2 != $nick)) msg chan sorry $nick you may not remove anyone else
  if ($read(list.txt,nw,%name)) { write -dl $+ $readn list.txt | msg $chan $nick has removed $iif($nick == %name,themself,%name) from the %list.status list now containing $calc($line(list.txt,0)) lines. | return }
  else msg $chan Sorry $nick you were not on the %list.status list
}



The above code has a section that lets an OP remove anyone by putting the nick after !listdel, duplicating the function of !del. They can remove the nick Fred with: !listdel Fred

If you remove the line beginning with "elseif", a non-OP who tries to remove someone else will find the nick is ignored, and they will be deleting themselves. smile

Note that if an OP types !listdel without a nick following it, they will delete themselves from the list.

Re: help with queue/line system for twitch [Re: maroon] #261795 25/11/17 08:16 PM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
thank you so so very much, you're a life saver! will definitely be testing this out and if i come across any troubles i'll reply here :^)

Re: help with queue/line system for twitch [Re: maroon] #261796 25/11/17 08:55 PM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
so far i got the !join, !findme, and !listdel commands and script to work, but the !next 3 or !next 7 commands aren't working. when i type either of those commands, it shows "0 still on the list. next 0 names:" when there are names in the list currently. did i make a mistake somewhere? :0

Re: help with queue/line system for twitch [Re: kouyachi] #261797 25/11/17 10:02 PM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
Sorry, I made 2 errors:

1. I was using syntax to count lines in a @window instead of lines in a text file. The $calc($line(list.txt,0)) should be edited to instead be

$calc($lines(list.txt))


2. In the !next event I should not have used the 'w' switch, causing it to look for the number 1 instead of looking for line 1. Remove the w from $read(list.txt,ntw,%line) to change it to $read(list.txt,nt,%line)

Re: help with queue/line system for twitch [Re: maroon] #261798 25/11/17 10:25 PM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
thank you so much, this fixed the issues with both smile

i have 2 more questions regarding the open/close list commands and the listdel commands.

1. the !open/!close commands don't seem to be working on the twitch channel itself. i'm wondering if i made a mistake somewhere, but when i type !open or !close, there's no response on the twitch channel for those commands. however, typing just "/listopen" and "/listclose" into the mIRC channel does work and it opens/closes the list, so it's not too big a deal if i can't get the commands working on the twitch channel alone, i'll just have to remember to open and close it from mIRC.

2. for the !listdel command, could there be a simpler way for people to remove themselves from the list? for example, typing just "!leave" and they wouldn't have to add their usernames to it?

Last edited by kouyachi; 25/11/17 10:26 PM.
Re: help with queue/line system for twitch [Re: kouyachi] #261799 26/11/17 01:34 AM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
1. I wrote the !open and !close commands to expect another word, the ":!close *:" and ":!close *:" should elminate the space and asterisk, to be like :!close: and :!open: (no space)

2. Same story with ":!listdel *:" not working without the following word. However to make the event work with and without the word, change the trigger section to remove the space but keep the asterisk like ":!listdel*:" (no space)

This will make it respond to any word beginning with !listdel and look at the following word as the optional nick to remove in place of the person typing it. If you want it to work the same way with !leave you can change the trigger from ":!listdel *:" to ":!leave*:" (no space)

Re: help with queue/line system for twitch [Re: maroon] #261805 26/11/17 04:54 AM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
this covered everything ah! i cannot thank you enough for helping me with this, i appreciate it so so much!

Re: help with queue/line system for twitch [Re: maroon] #261806 26/11/17 07:22 AM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
hm, i like everything that's working but now i might not want my mods to be able to do the commands that i'm able to do too bc it might cause a little confusion, lol. (example: i want to be the only one that can do the "!open!" or "!close" commands to open the list and not my mods), would it be difficult to change the code so that only i can do it?

Last edited by kouyachi; 26/11/17 07:27 AM.
Re: help with queue/line system for twitch [Re: kouyachi] #261807 26/11/17 08:33 AM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
The TEXT event cannot see things typed by the person where the script is loaded, so if you are using the same mirc as where the script is running, then the !open and !close are just duplicates. You could either delete them completely or change the event name from TEXT to something not valid like QTEXT to make it easy to enable them in the future.

Only if you have loaded the script onto a different mirc than the mirc you are using does the rest of this message matter to you.

You can alter the script by inserting a line to the TEXT event that responds to !open, so that it acts only if the message is from the correct nick. So if you want that even to respond only to nick kouyachi the first command of that event would be a line like:

if ($nick != kouyachi) return

If you want it to respond to the person using your host address regardless of your nick, you would first need to create the wildcard needed.

If you paste this in the edit box of the mirc where you will be typing, which is not the same mirc where the script is located:

//echo -a $address($me,2)

... this gives an address mask like *!*@your-exact-hostname
Instead of the above line checking if the nick is kouyachi, you would instead use the address you displayed above:

if (*!*@your-exact-hostname != $address($nick,2)) return

The nick portion of the address mask is where the asterisk is left of the "!", so it will match even if your nick is kouyachi_away or anything else.

If your address mask changes when you identify to network services, this will not work if you become un-identified.

If your hostname address changes because your ip-address changes sometimes, either because you are traveling or because your ISP changes your address sometimes, the line would need to be edited, but if you are always going to be the same nick, and nobody else is permitted to use that nick, you won't need to worry about making the script respond to the correct address instead of the correct nick.

Re: help with queue/line system for twitch [Re: maroon] #261809 26/11/17 09:39 AM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
i was just testing the commands on my twitch channel with one of my mods (koualah) and she was able to open the list herself, which is what i donít want (sorry for the confusion)

[img]https://ibb.co/e1Kk56[/img]

Last edited by kouyachi; 26/11/17 09:40 AM.
Re: help with queue/line system for twitch [Re: kouyachi] #261810 26/11/17 10:10 AM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
As I mentioned in previous post, you can restrict an event to only 1 nick by adding a line checking if $nick was the approved nick. This example lets you list more than 1 approved nick, and ignores anyone who is not an exact match:

Code:
on @*:text:!open:#: {
  if ($istok(aribun21 aribun21 aribun21,$nick,32)) return
  if (%list.status != closed) { msg $chan The list is already open | return }
  unset %list.status
  msg $chan OK $chan the list is now open!
}


You can change any of the duplicate aribun21 to another approved nick, as well as adding another nick within that list, as long as each nick is separated from each other by a space character. This is exactly the same as the current !open trigger except for the extra line, which you can also copy to the !close event too.

Re: help with queue/line system for twitch [Re: maroon] #261811 26/11/17 04:05 PM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
ohh i see, alright iíll try this right now!

Re: help with queue/line system for twitch [Re: maroon] #261812 26/11/17 04:21 PM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
okay, just tried but now there's no response from it/not working, hm

Re: help with queue/line system for twitch [Re: kouyachi] #261814 26/11/17 07:11 PM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
this is where a temporary debug message can help. It can verify whether the event is triggered or not, or whether it's triggered but not doing the correct thing. Try adding 2 echo lines to make it look like this:
Code:
on @*:text:!open:#: {
  echo -s $scriptline nick $nick (1-) $1-
  if ($istok(aribun21 aribun21 aribun21,$nick,32)) return
  echo -s $scriptline nick $nick (1-) $1-
  if (%list.status != closed) { msg $chan The list is already open | return }
  unset %list.status
  msg $chan OK $chan the list is now open!
}


If you see the 1st echo but not the 2nd, that tells you that the $istok line did it's job of ignoring the !open attempt. If you see neither, then something prevents the event from triggering. 1 reasons could be that you're typing it from the same mirc where the script is running, and the TEXT event sees everyone else's channel messages except your own. A 2nd reason is that the @ prefix makes this event only see things typed by an @op, so if you're not showing the channel the @op status then it won't see you. Another reason for an event not being seen, is the fact that each text message can only trigger 1 TEXT event in channel. So if there's an event earlier in the same script which has :*: instead of :!open: the first event is triggered by 100% of messages, and the lower TEXT event cannot be triggered by anything unless one of them is moved to a different script.

Another reason for a script not being triggered are color codes not visible as text. So if someone uses a color code to display !open as red, it doesn't trigger because the message is actually InvisibleColorCodes!open

Re: help with queue/line system for twitch [Re: maroon] #261816 27/11/17 12:32 AM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
okay, just tried this one and it's still not working but i don't think there's anything else in the script that's making it not work >_< ah, sorry for all the trouble

Re: help with queue/line system for twitch [Re: maroon] #261817 27/11/17 01:03 AM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
the original "!open" code you gave me is now having this problem where non-mods, meaning anyone, can open it:



>_<

in fact, now every code is able to be used by anyone, i'm so confused. i didn't change anything for those codes.

Last edited by kouyachi; 27/11/17 01:13 AM.
Re: help with queue/line system for twitch [Re: kouyachi] #261818 27/11/17 01:29 AM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
Sorry, it looks like the @ prefix works for the JOIN event but not the TEXT event. So to get the TEXT to not react to non-ops, the event will need to have added back the line at the top of that event:

Code:
on @*:text:!open:#: {
  if ($nick !isop $chan) return
  if (!$istok(aribun21 aribun21 aribun21,$nick,32)) return
  if (%list.status != closed) { msg $chan The list is already open | return }
  unset %list.status
  msg $chan OK $chan the list is now open!
}


The first line ignores someone if they're not an OP. The 2nd line ignores them if their nick isn't on the approved list.

Re: help with queue/line system for twitch [Re: maroon] #261819 27/11/17 01:34 AM
Joined: Sep 2017
Posts: 28
K
kouyachi Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Sep 2017
Posts: 28
okay, that fixed the problem :^) so should i add that line to all the commands i don't want other people to use?

Re: help with queue/line system for twitch [Re: kouyachi] #261820 27/11/17 01:43 AM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
that line blocks all ops. but you had said you wanted only certain ops to have permissions, so the one with the !$istok blocks any nick not on that list even if they're an op.

Page 1 of 2 1 2