egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mass slap+say script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Atako
Voice


Joined: 18 Aug 2012
Posts: 1

PostPosted: Sat Aug 18, 2012 2:54 pm    Post subject: mass slap+say script Reply with quote

Hey! Could you help me?

I need a script mass slap+say

I will write on one channel: .say blebleble

and bot will slap all users on #channel and say blebleble Can someone help me?

I've say and mass slap script but i can't
Code:

bind msg - .say msg_say

proc msg_say {nick uhost hand args} {
    global botnick
    if {[llength [lindex $args 0]]<2} {
        putserv "NOTICE $nick :/msg $botnick .say #chan_name <text>"
    } else {
        set chan [lindex [lindex $args 0] 0]
        if { ![validchan $chan]} {
            putserv "NOTICE $nick :\"$chan\": invalid chan."
            return 0
        }
        ## FIX ME this condition is never reached
        if { ![onchan $botnick $chan] } {
            putserv "NOTICE $nick :je ne suis pas sur le chan \"$chan\"."
            return 0
        }
        ## END FIX ME
        # comment this next 4 lines if you want to be able to talk in a chan you're not in
        if { ![onchan $nick $chan] } {
            putserv "NOTICE $nick :tu n'es pas sur le chan \"$chan\"."
            return 0
        }
        set msg [lrange [lindex $args 0] 1 end]
    }
    proc massslap {nick uhost hand chan text args} {
   # dump only 25 nicks per line
   set chanList [chanlist $chan]
   while {[llength $chanList] != 0} {
      puthelp "PRIVMSG $chan :[join [lrange $chanList 0 25]]"
      set chanList [lrange $chanList 25 end]
   }
}
    putchan $chan $msg
}
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Aug 18, 2012 9:24 pm    Post subject: Re: mass slap+say script Reply with quote

Code:
 if {[llength [lindex $args 0]]<2} {
# becomes to the eggdrop every single time
if {1 < 2 } {


Here is your problem. "[llength [lindex $args 0]]" will always be 1. It has no choice but to be because of how you've used it in your procedure declaration.

Stop using "[lindex $args 0]" all over the place. Everywhere you have that change it to "[split $arg]".

Also, change this part:
proc msg_say {nick uhost hand args} {

to this:
proc msg_say {nick uhost hand arg} {

There are more errors than this in your script concerning list to string errors. But I will let you figure those out. Only in certain conditions with certain characters should you notice the bugs.

http://www.peterre.info/characters.html wrote:
A point worthy of note about args
Putting args as the last argument of a Tcl procedure allows the use of a variable number of input arguments. But there is a potential source of confusion if the procedure is one that is called by an eggdrop bind command.

In a script that I downloaded I saw code similar to the following:

bind dcc - m2f dcc_calc_m2f
proc dcc_calc_m2f {hand idx args} {
if {[llength $args] == "1"} {

The author was no doubt thinking that if a user typed
.m2f aaa bbb ccc
then the value of args would be a list of three elements, aaa, bbb and ccc, and that therefore the value of [llength $args] would be 3.

In fact, the value of args would be a list of one element, that element being the string aaa bbb ccc. Whatever string the user types, the value of [llength $args] will always be 1.

Similarly, the value of [lindex $args 0] will not be the string aaa, but the string aaa bbb ccc.

The eggdrop pub and msg binds behave in the same way.

The above properties of eggdrop's bind command have been confirmed by testing with eggdrop version 1.6.6.

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber