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.

PLz help me with a mirc script

Help for those learning Tcl or writing their own scripts.
Post Reply
e
evilgenius
Voice
Posts: 2
Joined: Thu Dec 28, 2006 12:45 am

PLz help me with a mirc script

Post by evilgenius »

This is for an irc for a website i am setting up for peeps that share homebrew movies and such IT IS NOT AN ILLEGAL SITE!!!

this is error i get
[10:54] Tcl error [user_test]: wrong # args: should be "user_test nick host handle channel text site_add"

[10:55] Tcl error [user_search]: wrong # args: should be "user_search nick host handle channel text staffchan"

any ideas guys.....

here is the code

Code: Select all

package require mysqltcl

###### Set Site address ###########################

set site_add "http://www.bleh.com"

###### Setup Your database info here ##############

set dbuser "user"
set dbpassword "pass"
set name "dbname"
set portno "2222"

##### Set site channels ##########################

set staffchan "#staff"
set userchan "#user"
set uploaderchan "#uppers"
set uploaderclassno "7"

##################################################
# Connect to Database #
##################################################

set db_handle [mysqlconnect -host localhost -socket /tmp/mysql.sock -port $portno -user $dbuser -password $dbpassword -db $name]


##################################################
# Bind channel commands #
##################################################

bind pub "-|-" !user user_search
bind pub "-|-" !file user_file
bind pub "-|-" @file user_file
bind pubm - "% *request*" user_request

bind msg - pass invite_me

##################################################
# Set user defined flag for users #
##################################################

setudef flag UserSearch

##################################################
# /msg botname pass ircpass #
##################################################

proc invite_me { nick host handle text uploaderclassno uploaderchan userchan} {

global db_handle

set sql "SELECT irc, class FROM users WHERE username='%[mysqlescape $nick]%'"

set result [mysqlsel $db_handle $sql -list]

if {$result > 0} {

set record [lindex $result 0];
set pass [lindex $record 0];
set class [lindex $record 1];

if {$text == $pass} {

putserv "NOTICE $nick :Invite Successfull"
putserv "invite $nick $userchan"


if {$class > $uploaderclassno} {

putserv "invite $nick $uploaderchan"

}

} else {

puthelp "NOTICE $nick :The password you supplied does not match our records."

}

} else {

puthelp "NOTICE $nick :The username $nick was not found in our records. Ensure your nickname matches your site name."

}

mysqlendquery $result
}


##################################################
# Check file names #
##################################################


proc user_file { nick host handle channel text site_add} {

global db_handle


if {![channel get $channel UserSearch]} {
return 0
}

set sql "SELECT id, name, size, unix_timestamp(added), leechers, seeders FROM files WHERE search_text LIKE '%[mysqlescape $text]%' ORDER BY added DESC LIMIT 1"

set result [mysqlsel $db_handle $sql -list]

if {$result > 0} {

set record [lindex $result 0];
set id [lindex $record 0];
set name [lindex $record 1];
set size [lindex $record 2];
set added [lindex $record 3];
set added [duration [expr [clock seconds] - $added]];
set leechers [lindex $record 4];
set seeders [lindex $record 5];


if {[expr $size / 1024] >= 1} {
set sized "[string range "[expr $size / 1024.0]" 0 [expr [string length "[expr $size / 1024]"]+ 2] ] KB"};

if {[expr $size / 1048576] >= 1} {
set sized "[string range "[expr $size / 1048576.0]" 0 [expr [string length "[expr $size / 1048576]"]+ 2] ] MB"};

if {[expr $size / 1073741824] >= 1} {
set sized "[string range "[expr $size / 1073741824.0]" 0 [expr [string length "[expr $size / 1073741824]"]+ 2] ] GB"};


puthelp "NOTICE $nick :Name: $name"
puthelp "NOTICE $nick :Size: $sized"
puthelp "NOTICE $nick :Added: $added ago"
puthelp "NOTICE $nick :Seeders: $seeders"
puthelp "NOTICE $nick :Leechers: $leechers"
puthelp "NOTICE $nick :Link: $site_add/details.php?id=$id"

} else {
puthelp "NOTICE $nick :No matches : Please try again"
}


mysqlendquery $result
}



##################################################
# Perform User Search #
##################################################


proc user_search { nick host handle channel text staffchan} {
global db_handle


if {![channel get $channel UserSearch]} {
return 0
}

set sql "SELECT id, username, class, unix_timestamp(added), uploaded, downloaded, gender FROM users WHERE username='%[mysqlescape $text]%'"

set result [mysqlsel $db_handle $sql -list]

if {$result > 0} {

set record [lindex $result 0];
set id [lindex $record 0];
set username [lindex $record 1];
set class [lindex $record 2];
set added [lindex $record 3];
set added [duration [expr [clock seconds] - $added]];
set upload [lindex $record 4];
set download [lindex $record 5];
set gender [lindex $record 6]


if {[expr $upload / 1024] >= 1} {
set uploaded "[string range "[expr $upload / 1024.0]" 0 [expr [string length "[expr $upload / 1024]"]+ 2] ] KB"};

if {[expr $upload / 1048576] >= 1} {
set uploaded "[string range "[expr $upload / 1048576.0]" 0 [expr [string length "[expr $upload / 1048576]"]+ 2] ] MB"};

if {[expr $upload / 1073741824] >= 1} {
set uploaded "[string range "[expr $upload / 1073741824.0]" 0 [expr [string length "[expr $upload / 1073741824]"]+ 2] ] GB"};

if {[expr $upload / 1099511627776] >= 1} {
set uploaded "[string range "[expr $upload / 1099511627776.0]" 0 [expr [string length "[expr $upload / 1099511627776]"]+ 2] ] TB"};

if {[expr $download / 1024] >= 1} {
set downloaded "[string range "[expr $download / 1024.0]" 0 [expr [string length "[expr $download / 1024]"]+ 2] ] KB"};

if {[expr $download / 1048576] >= 1} {
set downloaded "[string range "[expr $download / 1048576.0]" 0 [expr [string length "[expr $download / 1048576]"]+ 2] ] MB"};

if {[expr $download / 1073741824] >= 1} {
set downloaded "[string range "[expr $download / 1073741824.0]" 0 [expr [string length "[expr $download / 1073741824]"]+ 2] ] GB"};

if {[expr $download / 1099511627776] >= 1} {
set downloaded "[string range "[expr $download / 1099511627776.0]" 0 [expr [string length "[expr $download / 1099511627776]"]+ 2] ] TB"};


switch $class {

"0" {set class "Leecher" }
"1" {set class "User" }
"2" {set class "Power User" }
"3" {set class "Donor" }
"4" {set class "Supreme User" }
"5" {set class "Power Seeder" }
"6" {set class "Ultimate Seeder" }
"7" {set class "VIP" }
"8" {set class "Light Uploader" }
"9" {set class "Maxi Uploader" }
"10" {set class "Support" }
"11" {set class "Moderator" }
"12" {set class "Supervisor" }
"13" {set class "Administrator" }
"14" {set class "Sysop" }
"default" {set class "Not Found" }
}


puthelp "PRIVMSG $staffchan User: $username"
puthelp "PRIVMSG $staffchan Gender: $gender"
puthelp "PRIVMSG $staffchan Class: $class"
puthelp "PRIVMSG $staffchan Joined: $added ago"
puthelp "PRIVMSG $staffchan Upload: $uploaded Download: $downloaded"
puthelp "PRIVMSG $staffchan Link: $site_add/userdetails.php?id=$id"

} else {

puthelp "PRIVMSG $channel :No matches"

}


mysqlendquery $result

}
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Procedure user_search should take 5 arguments only: nick uhost hand chan arg. user_test does not exist in your given code.

Also read: Help us to help you and Posts with poor subject lines may be deleted to learn how to post the right way so you can get proper help.
Post Reply