mIRC Home    About    Download    Register    News    Help

Print Thread
#147658 22/04/06 03:32 AM
Joined: Aug 2003
Posts: 66
B
bynw Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Aug 2003
Posts: 66
I saw this on usent and think it might be interesting to dabble around abit with for a while.

Anyway the goal is to have a normal user (not a irc op or channel op) be able to take away their own ability to chat on a channel. So they dont accidently type in the wrong window and send chat to a channel they dont want to send it into.

I have may basic script of:
Code:
 
on 1:input:#channelname:{
  echo -a This is a read only channel
  halt
}
 


But I want to add some functionality to it. I want to be able to edit the channel or channels on the fly. Probably with typing something somewhere. Remember this is all being entered by the user running the script not by others so it could be tricky but I think there is a way, just not sure what it is.

Thanks!

#147659 22/04/06 12:42 PM
Joined: Aug 2003
Posts: 66
B
bynw Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Aug 2003
Posts: 66
/me looks around and is a bit amazed that no one yet has an answer and continues to look on his own as well as seeing if the message board will provide assistance

#147660 22/04/06 03:27 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
[code]
on ^*:INPUT:$(%readonly):{
if ((/* iswm $1) && ($ctrlenter)) return
echo 4 -at This channel is read only.
haltdef
}

alias readonly {
if (($1 == add) && (#* iswm $2) && (!$istok(%readonly,$2,44)) {
set %readonly $addtok(%readonly,$2,44)
echo 5 -at Added $2 to read-only list
}
elseif (($1 == del) && (#* iswm $2) && ($istok(%readonly,$2,44)) {
set %readonly $remtok(%readonly,$2,1,44)
echo 5 -at Removed $2 from the read-only list
}
elseif ($1 == list) {
echo 5 -at Read-only list: $replace(%readonly,$chr(44),$chr(44) $+ $chr(32))
}
else {
echo 5 -at Syntax: /readonly add #channel
echo 5 -at Syntax: /readonly del #channel
echo 5 -at Syntax: /readonly list
}
}
[code]
(untested)

-genius_at_work

#147661 22/04/06 07:55 PM
Joined: Aug 2003
Posts: 66
B
bynw Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Aug 2003
Posts: 66
Doesnt work;

If I enter the command:
/readonly

/readonly list

/readonly add #channelname

i get this back:

* /if: invalid format (line 15, script1.ini)
-
* /if: invalid format (line 15, script1.ini)
-
* /if: invalid format (line 15, script1.ini)

#147662 22/04/06 08:07 PM
Joined: Dec 2004
Posts: 66
B
Babel fish
Offline
Babel fish
B
Joined: Dec 2004
Posts: 66
This line:
if (($1 == add) && (#* iswm $2) && (!$istok(%readonly,$2,44)) {

needs a ")" added:
if (($1 == add) && (#* iswm $2) && (!$istok(%readonly,$2,44))) {

#147663 22/04/06 08:14 PM
Joined: Aug 2003
Posts: 66
B
bynw Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Aug 2003
Posts: 66
ok that fixed the errors:

[15:11:38] Read-only list:
[15:11:42] Syntax: /readonly add #channel
[15:11:42] Syntax: /readonly del #channel
[15:11:42] Syntax: /readonly list
[15:11:51] Added #fudge to read-only list

However it did make the channel a read-only channel ... I was still able to send text to the channel.

Code:
 

on ^*:INPUT:$(%readonly):{
  if ((/* iswm $1) && ($ctrlenter)) return
  echo 4 -at This channel is read only.
  haltdef
}

alias readonly {
  if (($1 == add) && (#* iswm $2) && (!$istok(%readonly,$2,44))) {
    set %readonly $addtok(%readonly,$2,44)
    echo 5 -at Added $2 to read-only list
  }
  elseif (($1 == del) && (#* iswm $2) && ($istok(%readonly,$2,44))) {
    set %readonly $remtok(%readonly,$2,1,44)
    echo 5 -at Removed $2 from the read-only list
  }
  elseif ($1 == list) {
    echo 5 -at Read-only list: $replace(%readonly,$chr(44),$chr(44) $+ $chr(32))
  }
  else {
    echo 5 -at Syntax: /readonly add #channel
    echo 5 -at Syntax: /readonly del #channel
    echo 5 -at Syntax: /readonly list
  }
}

#147664 22/04/06 08:53 PM
Joined: Dec 2004
Posts: 66
B
Babel fish
Offline
Babel fish
B
Joined: Dec 2004
Posts: 66
In the line:

on ^*:INPUT:$(%readonly):{

remove the "^" so it's:

on *:INPUT:$(%readonly):{

#147665 22/04/06 08:58 PM
Joined: Aug 2003
Posts: 66
B
bynw Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Aug 2003
Posts: 66
Ok that works.

Now the real tricky part ... I /readonly added another channel. This did not overwrite the original channel nor did it add a second channel. I think it would be good to have the ability to have multiple channels set as "read only"

Thanks again

#147666 22/04/06 09:05 PM
Joined: Dec 2004
Posts: 66
B
Babel fish
Offline
Babel fish
B
Joined: Dec 2004
Posts: 66
hmm, try a few more times and double check. looks to me as if that part should work. If it doesn't maybe show us your input/output.

#147667 22/04/06 10:00 PM
Joined: Aug 2003
Posts: 66
B
bynw Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Aug 2003
Posts: 66
dont know why it didnt work before when i tested it but it does now.

#147668 23/04/06 08:27 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
also change

if ((/* iswm $1) && ($ctrlenter)) return

to

if ((/* iswm $1) || ($ctrlenter)) return


This well mean if while in that channle you enter a command using / it well work OR if you hold CTRL down while pressing enter the line well go to channel, so u have a imediate overrider of the script.
I beleive it was ment to be a || (OR) and not a && (AND) to begin with.

#147669 15/08/06 01:32 AM
Joined: Aug 2003
Posts: 66
B
bynw Offline OP
Babel fish
OP Offline
Babel fish
B
Joined: Aug 2003
Posts: 66
Code:
 

on *:INPUT:$(%readonly):{
  if ((/* iswm $1) || ($ctrlenter)) return
  echo 4 -at This channel is read only.
  haltdef
}

alias readonly {
  if (($1 == add) && (#* iswm $2) && (!$istok(%readonly,$2,44))) {
    set %readonly $addtok(%readonly,$2,44)
    echo 5 -at Added $2 to read-only list
  }
  elseif (($1 == del) && (#* iswm $2) && ($istok(%readonly,$2,44))) {
    set %readonly $remtok(%readonly,$2,1,44)
    echo 5 -at Removed $2 from the read-only list
  }
  elseif ($1 == list) {
    echo 5 -at Read-only list: $replace(%readonly,$chr(44),$chr(44) $+ $chr(32))
  }
  else {
    echo 5 -at Syntax: /readonly add #channel
    echo 5 -at Syntax: /readonly del #channel
    echo 5 -at Syntax: /readonly list
    echo 5 -at Syntax: /readonly clear
  }
}

 


I just noticed something with this script. It works great execpt for the CLEAR command ... it doesnt exist :-)


Link Copied to Clipboard