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.

Invite Script - Multi Channel ?

Help for those learning Tcl or writing their own scripts.
Post Reply
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Invite Script - Multi Channel ?

Post by Elfriede »

Hi everybody :)

I've got the following of the tcl archive. No way to reach the author. Can someone help to make this script multichannel ?

Code: Select all

###########################################
#							
# Channel invite 0.1 BETA			
# Scripted by Dreamer				
# 							
###########################################
#	
# Type /msg <botnick> @add <nick> <pass> 
# to add someone to the database
# Type /msg <botnick> @invite <nick> <pass>
# to get invited in to channel
#
# History:
# 0.1: First version
#
###########################################
# EDIT FROM HERE

# Channel where the bot wil invite
set chan_1 "#chav"

# Name of the database
set db scripts/chan.invite

# STOP EDITING FROM HERE

set ver "0.1"

bind msg - @add add_1
bind msg - @invite inv_1

putlog "Channel invite $ver by Dreamer loaded"

# Script starts now

proc add_1 { nick uhost hand args } {
	global chan_1 db
	set args [split $args " "]
	set user [lindex $args 0]
	set user [string range $user 1 end]
	set pass [lindex $args 1]
	set pass [string range $pass 0 end-1]
	if { $user == "" || $pass == "" } { 
			putserv "PRIVMSG $nick :Please instert a Nickname and a password" 
			return 0
	}
	set up $user|$pass
	set wfile [open $db a+]
	puts $wfile $up
	close $wfile
	putserv "PRIVMSG $chan_1 :\[\00314DB UPDATE\003\] $user is added to Database by $nick"
}

proc inv_1 { nick uhost hand arg } {
	global chan_1 db
	set found 0
	set arg [split $arg " "]
	set user1 [lindex $arg 0]
	set user1 [string range $user1 0 end]
	set pass1 [lindex $arg 1]
	set pass1 [string range $pass1 0 end]
	set up1 $user1|$pass1
	set found 0 
	set fs [open $db r] 
	while {![eof $fs]} { 
	gets $fs line 
	if {$line == $up1} { set found 1 } 
	} 
	close $fs 
	if {$found} { 
	putserv "PRIVMSG $chan_1 :\[\00314INVITE\003\] $user1 invited him/herself as $nick"
 	putserv "invite $nick $chan_1"
	} else {
	putserv "PRIVMSG $nick :Wrong pass or username !!!!"
	putserv "PRIVMSG $chan_1 :\[\0034INTRUDER\003\] $nick tried to get in the channel"
	} 
}
Thx 4 help !
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

###########################################
#                     
# Channel invite 0.1 BETA         
# Scripted by Dreamer            
#                      
###########################################
#   
# Type /msg <botnick> @add <nick> <pass>
# to add someone to the database
# Type /msg <botnick> @invite <nick> <pass>
# to get invited in to channel
#
# History:
# 0.1: First version
#
###########################################
# EDIT FROM HERE

# Channel where the bot wil invite
set chan_1 "#chav #chan2 #chan3"

# Name of the database
set db scripts/chan.invite

# STOP EDITING FROM HERE

set ver "0.1"

bind msg - @add add_1
bind msg - @invite inv_1

putlog "Channel invite $ver by Dreamer loaded"

# Script starts now

proc add_1 { nick uhost hand args } {
   global chan_1 db
   set args [split $args " "]
   set user [lindex $args 0]
   set user [string range $user 1 end]
   set pass [lindex $args 1]
   set pass [string range $pass 0 end-1]
   if { $user == "" || $pass == "" } {
         putserv "PRIVMSG $nick :Please instert a Nickname and a password"
         return 0
   }
   set up $user|$pass
   set wfile [open $db a+]
   puts $wfile $up
   close $wfile
   putserv "PRIVMSG $chan_1 :\[\00314DB UPDATE\003\] $user is added to Database by $nick"
}

proc inv_1 { nick uhost hand arg } {
   global chan_1 db
   set arg [split $arg " "]
   set user1 [lindex $arg 0]
   set user1 [string range $user1 0 end]
   set pass1 [lindex $arg 1]
   set pass1 [string range $pass1 0 end]
   set up1 $user1|$pass1
   set found 0
   set fs [open $db r]
   while {![eof $fs]} {
   gets $fs line
   if {$line == $up1} { set found 1 }
   }
   close $fs
   if {$found} {
	foreach ch [split $chan_1 " "] {
		putserv "PRIVMSG $ch :\[\00314INVITE\003\] $user1 invited him/herself as $nick"
		putserv "invite $nick $ch"
	}
   } else {
   putserv "PRIVMSG $nick :Wrong pass or username !!!!"
   putserv "PRIVMSG $chan_1 :\[\0034INTRUDER\003\] $nick tried to get in the channel"
   }
} 
this should do the trick
Last edited by Papillon on Fri May 09, 2008 9:21 am, edited 1 time in total.
Elen sila lúmenn' omentielvo
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

Thx, but on doing the invite command, nothing happens :(

Hopefully you'll help me out
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

hmm.. made a small modification, try it now
Elen sila lúmenn' omentielvo
E
Elfriede
Halfop
Posts: 67
Joined: Tue Aug 07, 2007 4:21 am

Post by Elfriede »

Works perfect now ! Thank you very much !
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

proc add_1 { nick uhost hand args } {
   global chan_1 db
   set args [split $args " "]
   set user [lindex $args 0]
   set user [string range $user 1 end]
   set pass [lindex $args 1]
   set pass [string range $pass 0 end-1]

...snipped irrelevant sections...

proc inv_1 { nick uhost hand arg } {
   global chan_1 db
   set arg [split $arg " "]
   set user1 [lindex $arg 0]
   set user1 [string range $user1 0 end]
   set pass1 [lindex $arg 1]
   set pass1 [string range $pass1 0 end] 
HAW.. Do you see the problem here?
The top proc incorrectly uses the special variable $args (you aren't using multiple binds with different sets of parameters to trigger this proc meaning args is used for no reason) and needs to do string range tricks ('1' and 'end-1' rather than '0' and 'end') to keep curly bracings out of the output.. lmao

Notice the bottom proc needlessly uses string range for no apparent reason (using it with 0-end range is equivalent to not using it at all), this is because the scripter probably couldn't figure out why they had to use it in the top proc (they used args, they had to to keep curly bracings from leading and ending the output..HAW) and not in the bottom.. lmao
<scripter> why are curly braces showing up?
<scripter> oh well, some bitching string ranges will clean that up
LMAO! I'm sure all of us have used kludges such as this to fix issues that were out of our tcl scope (as you learn more, of course, you too can spot these things easily and fix them correctly).
Post Reply