mIRC Homepage

Topic Lock on Mirc

Posted By: Confuzzled

Topic Lock on Mirc - 31/10/05 08:58 AM

possible mirc based topic lock?
i got this from hawkee's site forgot by who

on *@:MODE:#: {
if ( !$istok($me ChanServ ,$nick,32) ) { {
mode $chan $replacex($1-,+,-,-,+)
}
}
}

just curious if there's script like this out there that has to do with changing topics only. for example if an op in my channel changes the topic my bot will automatically change the topic back to the previous topic
Posted By: Lpfix5

Re: Topic Lock on Mirc - 31/10/05 12:46 PM

Code:

on *:JOIN:#:{
if ($nick == $me) { 
%topic $+ chan = $chan(#).topic
}
}

on *:TOPIC:#:{
if ($nick == $me) { 
timer 1 3 /set %topic $+ chan $chan(#).topic | halt
}
else { topic # %topic $+ chan }
}



or just //mode # +t

and theres your topic lock
Posted By: FiberOPtics

Re: Topic Lock on Mirc - 31/10/05 01:24 PM

If you want an event to only trigger if you are the reason it triggers, then you can use this construct:

on me:*:<event>:...

That avoids the check for if ($nick == $me)

Examples:

on me:*:join:#:{
;code
}

Less code, faster, and enables you to have multiple on join events in an event.

Similarly, if you want the event to only trigger if you are not the person causing the even to trigger you can use this:

on !*:join:#:{
;code
}

In contrast with doing:

on *:join:#:{
if ($nick != $me) {
; code
}
}
Posted By: Lpfix5

Re: Topic Lock on Mirc - 31/10/05 02:20 PM

Meh old ways never die force of habbit lol

:P

here also i thought you might want to unload the vars on quit or part

FiberOptics im not sure if that syntax works with quit and part but here goes nothing

on me:*:quit:{
unset %topic*
}

on me:*:part:#:{
unset %topic*
}
Posted By: bwr30060

Re: Topic Lock on Mirc - 31/10/05 03:56 PM

Hey,

I didn't know about the on me.... events. I've noticed that my ON TEXT events don't respond to me. For future reference, can I do something like on me:*:TEXT...? Would this respond to my text too? Thanks.
Posted By: Lpfix5

Re: Topic Lock on Mirc - 31/10/05 04:11 PM

no.. your text = On INPUT

example:>

on *:INPUT:#:{
if ($1 == lol) { msg $chan Laughing Out Loud $2- | /halt }
if (badword isin $1-) { echo -a Sorry i cannot post that on the board it contains foul language }
elseif ($left($1,1) != /) || ($ctrlenter) {
echo -t $target < $+ $me $+ > $1-
.raw privmsg $active : $+ $1-
halt
}
}

so if the first word = lol then it outputs Laughing out Loud texthere
Posted By: Riamus2

Re: Topic Lock on Mirc - 31/10/05 04:14 PM

Lpfix5 and FiberOPtics, you mixed up your format for using "me". smile

bwr30060, use:

on me:quit: { }
on me:part:#: { }
on me:join:#: { }

etc.

If you want it to work only when you're opped, just put @ in front like normal:

on @me:part:#: { }

"me" is a special prefix referring to you. You can use it instead of using * or 1 (or some other number/name) in that part of the event. Saves needing to use "if ($nick == $me) { }" in your code.
Posted By: bwr30060

Re: Topic Lock on Mirc - 31/10/05 04:46 PM

Lpfix5,

I've used the on input events, but I have had a problem with them. When I halt the default text to do things, my commands don't work, like /whois Nick. Is there a way around this? Thanks.

PS-- if I do a statement like this, will it work?
Code:
if ($left($1-,1) == $chr(47)) { echo }


Thanks.
Posted By: Sat

Re: Topic Lock on Mirc - 31/10/05 04:47 PM

No, they got it right and you got it wrong. "me:" is a prefix, not a userlevel.
Posted By: Riamus2

Re: Topic Lock on Mirc - 31/10/05 04:53 PM

Yes, I know it's a prefix.

I've never put that extra * in there and it works fine. Right now, I can't test to see if this other method works as well.

Perhaps not using the * makes it assume a *. In either case, I can't see many reasons why you need it to check your own user level, but I can see a few cases like that.
Posted By: Sat

Re: Topic Lock on Mirc - 31/10/05 05:05 PM

Quote:
I've never put that extra * in there and it works fine.

No it doesn't, not unless you have added yourself with userlevel "me" at some point.
Posted By: Riamus2

Re: Topic Lock on Mirc - 31/10/05 05:33 PM

Well, I'll check when I'm home. Since I can't connect at work, I can't see if any events work since on input obviously isn't appropriate for the me prefix.
Posted By: Lpfix5

Re: Topic Lock on Mirc - 31/10/05 06:01 PM

bwr scroll up i included the / code in my on input code
Posted By: FiberOPtics

Re: Topic Lock on Mirc - 31/10/05 06:11 PM

You're wrong, which is ok, it's not a crime to make a mistake, though I don't like it when people say I'm wrong without investigating the matter thoroughly. I wouldn't put it like that if it weren't for a reason.

Try this code in your script files:

on me:join:#: echo -a i've joined

Now do a /hop or join a channel --> nothing happens.

Put it as:

on me:*:join:#: echo -a i've joined

Now do a /hop and it will say you've joined.

The me as I've used it, and as Sat has explained is an event prefix just like +, @, ! etc., it's not a user level.
Posted By: Lpfix5

Re: Topic Lock on Mirc - 31/10/05 06:17 PM

Tus why I never question FiberOptics crazy
Posted By: hixxy

Re: Topic Lock on Mirc - 31/10/05 06:34 PM

Sorry if this seems pedantic and you already know, but I just thought I'd point it out...

'me' is the prefix, not 'me:', the : isn't necessary:

Code:
on me*:join:#: echo -a Works.


Is the same as:

Code:
on me:*:join:#: echo -a Works.
Posted By: FiberOPtics

Re: Topic Lock on Mirc - 31/10/05 06:34 PM

Well, I'm only a normal person, who makes mistakes as anyone, so you may always question me smile

Just ask if you're wondering why I do something that you think is weird or wrong in your opinion.
Posted By: FiberOPtics

Re: Topic Lock on Mirc - 31/10/05 06:41 PM

That's incorrect.

on me*:join:#: echo -a $nick has joined

triggers on everyone, not just yourself.
Posted By: Lpfix5

Re: Topic Lock on Mirc - 31/10/05 07:10 PM

Sure of course everyone makes mistakes but im sure before we get to see your post your on it ASAP to fix it if error after over looking which i do often i dont realize till its posted and i look over it
Posted By: Confuzzled

Re: Topic Lock on Mirc - 01/11/05 08:20 AM

ok so which one works?
Posted By: Confuzzled

Re: Topic Lock on Mirc - 01/11/05 08:39 AM

your code don't work i used same one you post

on *:JOIN:#:{
if ($nick == $me) {
%topic $+ chan = $chan(#).topic
}
}

on *:TOPIC:#:{
if ($nick == $me) {
timer 1 3 /set %topic $+ chan $chan(#).topic | halt
}
else { topic # %topic $+ chan }
}

and it gave me this,

MyBotNick changes topic to "4!'!7!'!8!'!9!'!12!'!13!'! what goes around comes around 13!'!12!'!9!'!8!'!7!'!4!"
MeTheOwner changes topic to "welcome to my channel"
MyBotNick changes topic to "chan"

is the "%topic $+ chan" really necessary or you forgot to put the "$" before the "chan" ?
Posted By: Confuzzled

Re: Topic Lock on Mirc - 02/11/05 09:52 AM

still not helped....and confused like always

i asked help on topic lock on mirc but then you guys went on user level or prefixes etc...
Posted By: SladeKraven

Re: Topic Lock on Mirc - 02/11/05 10:49 AM

Here's one way...

Code:
On *:Start: {
  hmake topiclock 10
  if ($exists(topiclock.hsh)) hload -i topiclock topiclock.hsh
}

alias ut {
  if ($hfind(topiclock,$active)) hadd topiclock $active $iif($active ischan,$chan($chan).topic)
}

dialog topiclock {
  title "Topic Lock"
  size -1 -1 109 143
  option dbu
  combo 1, 4 4 102 107, size
  button "Add", 2, 24 113 27 9
  button "Rem", 3, 56 113 27 9
  button "Close", 4, 37 127 37 12, ok
}

On *:Dialog:topiclock:init:*: {
  var %x = 1
  while (%x &lt;= $hget($dname,0).item) {
    did -a $dname 1 $hget($dname,%x).item
    inc %x
  }
}

On *:Dialog:topiclock:sclick:*: {
  if ($did($dname,1)) {
    if (!$hget(topiclock)) hmake topiclock 10
    if ($did == 2) {
      if (!$hfind($dname,$did($dname,1))) {
        hadd $dname $did(1)
        did -a $dname 1 $did(1)
      }
    }
    elseif ($did == 3) {
      if ($hfind($dname,$did($dname,1).seltext)) {
        hdel $dname $did($dname,1).seltext
        did -d $dname 1 $did($dname,1).sel
      }
    }
  }
}

Raw 332:*: { 
  echo -s $2
  if ($hfind(topiclock,$2)) hadd topiclock $2 $3-
  hsave -i topiclock topiclock.hsh
}

On @*:Topic:#: {
  if (($nick != $me) &amp;&amp; ($hfind(topiclock,$chan))) {
    topic $chan $hfind(topiclock,$chan)
  }
}


It's channel specific so it should work in the channels you join.

1. Add a channel.
2. Join that channel (wont work if no topic is set).
3. Allow someone to change topic.
4. Topic is set back to the topic when you first joined.

Notes:

/tl - opens control panel
/ut - stores the current topic in the table (updates)

You will only change topic back if you are an op on the channel.

**Untested**

-Andy
Posted By: Confuzzled

Re: Topic Lock on Mirc - 02/11/05 12:53 PM

there's no alias for "tl" i tried typing /topiclock too but don't work it kept on saying error unknown command

and when ever i join a channel that i have op status in it echos this everytime i joined a channel #lobby if ($hfind(topiclock,$2)) hadd topiclock "#lobby welcome to myroom" exclude the channel name and "#lobby welcoem to myroom"
Posted By: SladeKraven

Re: Topic Lock on Mirc - 02/11/05 07:00 PM

Ya, my apologies dude sorry it was about 4 am when I wrote that code and I was extremely tuckered out..

The /echo is my way of working with Raw's so I know before hand what is being sent to me.

It seems I didn't post the updated code to allow "/tl"..

Code:
On *:Start: {
  hmake topiclock 10
  if ($exists(topiclock.hsh)) hload -i topiclock topiclock.hsh
}

alias ut {
  if ($hfind(topiclock,$active)) hadd topiclock $active $iif($active ischan,$chan($chan).topic)
}

alias tl {
  if (!$dialog(topiclock)) dialog -mo topiclock topiclock
}

dialog topiclock {
  title "Topic Lock"
  size -1 -1 109 143
  option dbu
  combo 1, 4 4 102 107, size
  button "Add", 2, 24 113 27 9
  button "Rem", 3, 56 113 27 9
  button "Close", 4, 37 127 37 12, ok
}

On *:Dialog:topiclock:init:*: {
  var %x = 1
  while (%x &lt;= $hget($dname,0).item) {
    did -a $dname 1 $hget($dname,%x).item
    inc %x
  }
}

On *:Dialog:topiclock:sclick:*: {
  if ($did($dname,1)) {
    if (!$hget(topiclock)) hmake topiclock 10
    if ($did == 2) {
      if (!$hfind($dname,$did($dname,1))) {
        hadd $dname $did(1)
        did -a $dname 1 $did(1)
      }
    }
    elseif ($did == 3) {
      if ($hfind($dname,$did($dname,1).seltext)) {
        hdel $dname $did($dname,1).seltext
        did -d $dname 1 $did($dname,1).sel
      }
    }
  }
  hsave -i topiclock topiclock.hsh
}

Raw 332:*: { 
  if ($hfind(topiclock,$2)) hadd topiclock $2 $3-
  hsave -i topiclock topiclock.hsh
}

On @*:Topic:#: {
  if (($nick != $me) &amp;&amp; ($hfind(topiclock,$chan))) {
    topic $chan $hfind(topiclock,$chan)
    hsave -i topiclock topiclock.hsh
  }
}


-Andy
Posted By: Confuzzled

Re: Topic Lock on Mirc - 03/11/05 09:38 AM

ok now it looks like it's working but,

it's not doing what it suppose to do, i did what you stated in your instructions add channel and allow other op to change topic well this is how it came out when i put the code in my bot and i tried to change the topic myself. this is what it did.

[01:16a] * MyNick changes topic to 'welcome to my channel'
[01:16a] * MyBot changes topic to '#lobby' <<-- my channel name i put in dialog where it says add and remove
[01:16a] * MyNick changes topic to 'welcome to my channel'
[01:16a] * MyBot changes topic to '#testing' <<-- did the same thing again

it kept on changing the topic back to the name of the channel i added instead of changing the topic back to previous topic i even close mirc and reopen and tried again but still the same
Posted By: SladeKraven

Re: Topic Lock on Mirc - 04/11/05 09:04 PM

Another mistake...

Change topic $chan $hfind(topiclock,$chan) to topic $chan $hget(topiclock,$chan)

-Andy
Posted By: Confuzzled

Re: Topic Lock on Mirc - 05/11/05 09:55 AM

thank you much slade,

now it works perfect just the way it should work

one more question on your topic lock,

if i want to let others change topic without my bot changing it back to original topic, say a list of friends or certain people with a certain level for them to change the topic without my bot changing it back on the topic locker how do i do it on your topic locker?
Posted By: SladeKraven

Re: Topic Lock on Mirc - 05/11/05 11:51 AM

Code:
On *:Start: {
  hmake topiclock 10 | hmake topiclock_friends 10
  if ($exists(topiclock.hsh)) hload -i topiclock topiclock.hsh
  if ($exists(topiclock_friends.hsh)) hload -i topiclock_friends topiclock_friends.hsh
}

alias ut { if ($hfind(topiclock,$active)) hadd topiclock $active $iif($active ischan,$chan($chan).topic) }
alias tl { if (!$dialog(topiclock)) dialog -mo topiclock topiclock }

dialog topiclock_friends {
  title "Topic Lock - Friends List"
  size -1 -1 109 143
  option dbu
  combo 1, 4 4 102 107, size
  button "Add", 2, 24 113 27 9
  button "Rem", 3, 56 113 27 9
  button "Close", 4, 37 127 37 12, ok
}

On *:Dialog:topiclock_friends:init:*: {
  var %x = 1
  while (%x &lt;= $hget($dname,0).item) {
    did -a $dname 1 $hget($dname,%x).item
    inc %x
  }
}

On *:Dialog:topiclock_friends:sclick:*: {
  if ($did($dname,1)) {
    if (!$hget($dname)) hmake $dname 10
    if ($did == 2) {
      if (!$hfind($dname,$did($dname,1))) {
        hadd $dname $did(1) $did(1)
        did -a $dname 1 $did(1)
      }
    }
    elseif ($did == 3) {
      if ($hfind($dname,$did($dname,1).seltext)) {
        hdel $dname $did($dname,1).seltext
        did -d $dname 1 $did($dname,1).sel
      }
    }
  }
  hsave -i $dname $+($dname,.hsh)
}

dialog topiclock {
  title "Topic Lock"
  size -1 -1 109 143
  option dbu
  combo 1, 4 4 102 107, size
  button "Add", 2, 24 113 27 9
  button "Rem", 3, 56 113 27 9
  button "Friends",4, 80 129 27 9
  button "Close", 5, 37 127 37 12, ok
}

On *:Dialog:topiclock:init:*: {
  var %x = 1
  while (%x &lt;= $hget($dname,0).item) {
    did -a $dname 1 $hget($dname,%x).item
    inc %x
  }
}

On *:Dialog:topiclock:sclick:*: {
  if ($did($dname,1)) {
    if (!$hget(topiclock)) hmake topiclock 10
    if ($did == 2) {
      if (!$hfind($dname,$did($dname,1))) {
        hadd $dname $did(1)
        did -a $dname 1 $did(1)
      }
    }
    elseif ($did == 3) {
      if ($hfind($dname,$did($dname,1).seltext)) {
        hdel $dname $did($dname,1).seltext
        did -d $dname 1 $did($dname,1).sel
      }
    }
    else {
      dialog -dm topiclock_friends topiclock_friends
    }
  }
  if ($did == 4) dialog -mo topiclock_friends topiclock_friends
  hsave -i topiclock topiclock.hsh
}

Raw 332:*: { 
  if ($hfind(topiclock,$2)) hadd topiclock $2 $3-
  hsave -i topiclock topiclock.hsh
}

On @*:Topic:#: {
  if (($nick != $me) &amp;&amp; (!$hfind(topiclock_friends,$nick))) {
    topic $chan $hget(topiclock,$chan)
    hsave -i topiclock topiclock.hsh
  }
}


If you type /tl you'll see there's an extra button for Friends list.

-Andy
Posted By: Confuzzled

Re: Topic Lock on Mirc - 05/11/05 02:15 PM

once again thank you greatly slade it just keep on getting better and better thank you so much for your huge help
Posted By: SladeKraven

Re: Topic Lock on Mirc - 05/11/05 05:27 PM

It seems I forgot to add a check to see if the item existed in the hash table..

Code:
On @*:Topic:#: {
  if (($nick != $me) &amp;&amp; (!$hfind(topiclock_friends,$nick))) {
    if ($hfind(topiclock,$chan)) {
    topic $chan $hget(topiclock,$chan)
    hsave -i topiclock topiclock.hsh
    }
  }
}


And you're welcome. smile
© 2022 mIRC Discussion Forums