This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

script i made

Old posts that have not been replied to for several years.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

script i made

Post by metroid »

Hey all, I made a small script, it looks like crap but it works to a level, the problem i have is thats its supposed to send a ban to a services bot called Q on quakenet but it doesnt..

bind pub o !qban pub:qban

proc pub:qban {nick uhost hand chan text} {
if {[botisop $chan]} {
if {[string length $text] > 0} {
set tnick [lindex $text 0]
if {[onchan "Q" $chan]} { putserv "PRIVMSG Q :chanlev $chan $tnick +b" }
putserv "KICK $chan $tnick :You have been Qbanned by $nick"
putserv "NOTICE $nick :Done."
} elseif {[onchan "L" $chan]} { puthelp "NOTICE $nick :There is no Q on this channel." }
putserv "MODE $chan +b $tnick"
putserv "KICK $chan $tnick :Due to no Q being in this channel you are being kicked."
} else { puthelp "NOTICE $nick :usage !qban <nick>" }
}

Now what this script is supposed to do is put the +b flag on that person's account but if it detects there is no Q in the channel but an L it should add it but just kickban the user instead, But it doesnt seem to notice if a Q or L is in the channel as the script does kick that person and say Done. but then it will also set the ban on the users nick and if he has returned by then it will kick with the message "Due to no Q being in this channel you are being kicked."

If someone could fix it for me i would be gratefull :)

Now if i didnt make sense tell me and ill try to rephrase it :P
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You are having problems with the if, else structure what my guess is.

It should be something like this, if I am correct:

Code: Select all

bind pub o !qban pub:qban

proc pub:qban {nick uhost hand chan text} { 
 if {[string length $text] > 0} { set tnick [lindex $text 0] }
 if {[botisop $chan]} { 
  if {[onchan "Q" $chan]} { 
   putserv "PRIVMSG Q :chanlev $chan $tnick +b"
   putserv "KICK $chan $tnick :You have been Qbanned by $nick" 
   putserv "NOTICE $nick :Done." 
   }
   elseif {[onchan "L" $chan]} { 
    putserv "NOTICE $nick :There is no Q on this channel."
    putserv "MODE $chan +b $tnick" 
    putserv "KICK $chan $tnick :Due to no Q being in this channel you are being kicked."
    }
  else { putserv "NOTICE $nick :usage !qban <nick>" } 
 }
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Ill try it out
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Works like a charm, Thanks :D

Here is the result :)

Channel with Q :

[11:37:32] <MeTroiD> !qban sheepbot
[11:37:34] * sheepbot was kicked by |A| (You have been Qbanned by MeTroiD)
[11:37:36] -|A|- Done.
[11:37:56] * sheepbot (v1per@sh33pb0tt0r.users.quakenet.org) has joined #sheep.go.meh
[11:37:56] * Q sets mode: +b *!*@sh33pb0tt0r.users.quakenet.org
[11:37:56] * Info: This *!*@sh33pb0tt0r.users.quakenet.org ban affects sheepbot
[11:37:56] * sheepbot was kicked by Q (You are BANNED from this channel.)

Channel with L :

[11:36:23] <MeTroiD> !qban sheepbot
[11:36:24] -|A|- There is no Q on this channel.
[11:36:25] * |A| sets mode: +b sheepbot!*@*
[11:36:27] * sheepbot was kicked by |A| (Due to no Q being in this channel you are being kicked.)

Now need to know how to change the ban on his nick to a ban on his host
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Hey awyeah, I was wondering if you could convert this for me

bind pub o settopic q:topic

proc q:topic {nick uhost hand chan text} {
putserv "PRIVMSG Q :settopic $chan $text"
}

This script is a public script where when u say settopic *topic* the bot makes Q set it, I was wondering if you guys could make it a msg, for example:

/msg <bot> settopic <channel> <text>

I've tried myself but it failed :(

bind msg o settopic msg:q:topic

proc msg:q:topic {nick uhost hand text} {

I don't know what to do further :(
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

For changing the banmask to a users host use this.
This would ban and IP Address in the following format:

Code: Select all

*!*@127.0.0.1

Code: Select all

proc pub:qban {nick uhost hand chan text} { 
 if {[string length $text] > 0} { set tnick [lindex $text 0] }
 set userhost [getchanhost $tnick $chan]
 set banmask "*!*@[lindex [split $userhost @] 1]"
 ...................................
 .......................................
 ............................................
 putserv "MODE $chan +b $banmask"
 ............................................
 ........................................
 ....................................

 }
}
The topic thingy is quite easy as well.
Use this in the following format:

Code: Select all

/msg <botnick> settopic <#channel> <topic>
Try using this code, this should work:

Code: Select all

bind msg o settopic msg:q:topic 

proc msg:q:topic {nick host hand text} {
 global botnick
  set chan [lindex $text 0]
  if {[botisop $chan]} { 
   set topic [lrange $text 1]
   putserv "PRIVMSG Q :settopic $chan $topic"
 }
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

I get a tcl error when doing the settopic command

[17:39] Tcl error [msg:q:topic]: wrong # args: should be "lrange list first last"

and the Qban cmd works perfectly :)
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

change this line

Code: Select all

set topic [lrange $text 1]
into

Code: Select all

set topic [lrange $text 1 end]
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

That fixed it, thnx
Last edited by metroid on Fri Jun 25, 2004 12:05 pm, edited 1 time in total.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

I was wondering, If i wanted this script to respond to msg's would i just have to alter the proc etc or everything?

Code: Select all

bind pub  n|m "autolimit" autolimit:pub
bind join -|- * autolimit:join

setudef str "autolimit"

proc autolimit:start {} {
  foreach channel [channels] {
    if {[channel get $channel "autolimit"] == ""} {
      channel set $channel "autolimit" "0"
    }
  }
  utimer 60 autolimit
}

proc autolimit:join {nickname hostname handle channel} {
  if {![isbotnick $nickname]} {
    return 0
  }
  if {[channel get $channel "autolimit"] == ""} {
    channel set $channel "autolimit" "0"
  }
}

proc autolimit:pub {nickname hostname handle channel arguments} {
 global lastbind
  set argumentc [llength [split $arguments { }]]
  set option [lindex $arguments 0]
  set users [llength [chanlist $channel]]
  if {$argumentc < 1} {
    set currentlimit [channel get $channel "autolimit"]
    if {$currentlimit > 0} {
      putserv "NOTICE $nickname :Current auto-limit is: [channel get $channel "autolimit"]"
    } else {
      putserv "NOTICE $nickname :Argument should start with a '#' and a digit. (eg. #10 or on|off)"
    }
    return
  }
  if {([regexp -nocase -- {(#[0-9]+|off|on)} $option tmp result]) && (![regexp -nocase -- {\S#} $option])} {
    switch $result {
      on {
        channel set $channel "autolimit" "10"
        putserv "MODE $channel +l [expr $users + 10]"
        puthelp "NOTICE $nickname :Auto-limit is changed to: +10"
      }
      off {
        channel set $channel "autolimit" "0"
        putserv "MODE $channel -l *"
        puthelp "NOTICE $nickname :Done. Auto-limit disabled successfully."
      }
      default {
        if {([regexp {#[0-9]} $result]) && ([string index $result 0] == "#")} {
          regexp {#([0-9]+)} $result tmp result
          if {($result < 2)} {
            set result 2
          } elseif {($result > 500)} {
            set result 500
          }
          channel set $channel "autolimit" "$result"
          putserv "MODE $channel +l [expr $users + $result]"
          puthelp "NOTICE $nickname :Auto-limit is changed to: $result"
        }
      }
    }
  } else {
    puthelp "NOTICE $nickname :Argument should start with a '#' and a digit. (eg. #10 or on|off)"
  }
}

proc autolimit {} {
  if {![string match *autolimit* [utimers]]} {
    utimer 60 autolimit
  }
  foreach channel [channels] {
    set autolimit [channel get $channel "autolimit"]
    if {(![botisop $channel]) || ($autolimit == "0")} {
      continue
    }
    set users [llength [chanlist $channel]]
    set newlimit [expr $users + $autolimit]
    set chanmodes [getchanmode $channel]
    if {[string match *l* [lindex $chanmodes 0]]} {
      regexp {\S[\s]([0-9]+)} $chanmodes tmp currentlimit
    } else {
      set currentlimit 0
    }
    if {$newlimit == $currentlimit} {continue}
    if {$newlimit > $currentlimit} {
      set difference [expr $newlimit - $currentlimit]
    } elseif {$newlimit < $currentlimit} {
      set difference [expr $currentlimit - $newlimit]
    }
    if {($difference <= [expr round($autolimit * 0.5)]) && ($autolimit > 5)} {
      continue
    } elseif {($difference < [expr round($autolimit * 0.38)]) && ($autolimit <= 5)} {
      continue
    }
    putserv "mode $channel +l $newlimit"
  }
}

autolimit:start

Would i have to change:
[code]proc autolimit:pub {nickname hostname handle channel arguments} {
or?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Umm... yeah sorry for that lrange thing, I forgot to add the 'end' in a hurry... as everything has a starting range, it has an ending range :D

As for the script you have posted?
Why would you want it to respond to msgs?

It has nothing todo with public commands.
The bind is set for join, and the bot would automatically
change the limits when people part or join a channel depending
upon the ranges you will have set in the script.

If you want to enable and disable the script at times, well for that
you can add a procedure to kill the timers or utimers of that autolimit
script and maybe unbind the auto limit setting procedure, that should do it and vice versa.

If you want to make a script to respond to private messages
and change a limit of a channel, that is almost the same as
the code as for the settopic which I had made.

Use this as:

Code: Select all

/msg <botnick> !limit <#channel> <+/-> <limit>

Code: Select all

bind msg o !limit msg:limit 

proc msg:limit {nick host hand text} { 
 global botnick 
  set chan [lindex $text 0] 
  if {[botisop $chan]} { 
   set range "[lindex $text 1]l"; set limit [lindex $text 2]
   putserv "MODE $chan :$range $topic" 
 } 
} 

If you want it in this way

Code: Select all

/msg <botnick> !limit <#channel> <+/- limit>
Then you will need to split them up and process them seperately.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
d
dollar
Op
Posts: 178
Joined: Tue Oct 28, 2003 3:47 pm
Location: Netherlands

Post by dollar »

Awyeah, take a look at http://peterre.com/characters.html. SPLIT $text before using LIST commands on it (like lindex, lrange, or lset). $text is a string, using list commands on it b0rks the [censored]. Read the page. :]
dollar (or something similar) at:
#eggdrop / #tcl - undernet
#egghelp / #tcl / #eggtcl - efnet
#eggdrop.support / #tcl - quakenet
#eggdrop - ircnet
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Hmm yeah.. I took a look at it.

Anyway I tested my scripts with channels and nicks
containing characters [ ] \ { } " and they seemed to
work fine and didnt choke on these characters.

I've tested this thing with most of my scripts and other
scripts as well, this was an error/bug in the older versions
of eggdrop I think, now they filter it.

I think the newer versions of eggdrops filters out
these words in the procedure parameters of the binds.

So I think even if you are running the latest tcl version
and latest eggdrop version your scripts even if you use
special tcl characters in it on variables such as nicks and
channels they will not choke on those special characters.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

It's not filtered in newer eggdrop versions or Tcl, because this is intended behaviour, when used correctly...

For example, using the last code segment you posted...
Do: /msg <botnick> !limit [die] + 5
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Nono, the thing is, If you say autolimit #how many on/off it will set the autolimit, but i wanted it to respond on msg, fx: /msg <bot> autolimit #number on/off instead of in public
Locked