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.

submit message!

Old posts that have not been replied to for several years.
Locked
i
inxs
Voice
Posts: 29
Joined: Fri Jun 10, 2005 5:33 am
Location: India

submit message!

Post by inxs »

i want a script that can save message to my eggdrop file when the type /msg botnick add text|text to eggdrop.submit, to submit the text|text. can anyone give me the code or scripts
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

Sorry, the Script is in German :)

Code: Select all

set post_benutzerdatei "scripts/post.benutzerdatei"
set post_nachrichten "scripts/post.nachrichten"
set post_botnick "XXXXXXX"

bind join - * bot_checkpost
proc bot_checkpost {nick host hand channel} {
    global post_nachrichten
    global post_botnick
    if {[get $nick $post_nachrichten]!=""} {
	putserv "NOTICE $nick :13Du hast neue Nachrichten!"
	putserv "NOTICE $nick :Tippe /msg $post_botnick !lese <Passwort> um sie abzurufen."
    }
}

bind msgm - "!neu*" botpost_neu
proc botpost_neu {nick host hand text} {
    global post_benutzerdatei
    set passwort [lindex $text 1]
    if {$passwort==""} {
	putserv "NOTICE $nick : Kein Passwort vergeben!";
    } else {
	if {[get $nick $post_benutzerdatei] == ""} {
	    add $nick $passwort $post_benutzerdatei
	} else {
	    putserv "NOTICE $nick : Deine Mail-Box besteht bereits!"
	}
    }
}

bind msgm - "!lese*" botpost_lese
proc botpost_lese {nick host hand text} {
    global post_nachrichten
    global post_benutzerdatei
    global post_botnick
    set passwort [lindex $text 2]
    set postnick [lindex $text 1]
    if {$passwort == ""} {
	set passwort [lindex $text 1]
	set postnick $nick
    }

    if {[get $postnick $post_benutzerdatei]==""} {
	putserv "NOTICE $nick :Du hast keine Mail-Box eingerichtet."
	putserv "NOTICE $nick :Tippe /msg $post_botnick !neu <passwort> um dir eine einzurichten!"
    }

    if {[get $postnick $post_benutzerdatei]!=$passwort} {
	putserv "NOTICE $nick : Falsches Passwort!"
    } else {
	set nachricht [get $postnick $post_nachrichten]
	if {$nachricht == "" } {
	    putserv "NOTICE $nick : Du hast keine Nachrichten!"
	} else {
	    putserv "NOTICE $nick : $nachricht"
	    remove $postnick $post_nachrichten
	    set nachricht [get $postnick $post_nachrichten]
	    while {$nachricht != ""} {
		putserv "NOTICE $nick : $nachricht"
		remove $postnick $post_nachrichten
	    }
	}
    }
}

bind msg - !botpost botpost_hilfe
proc botpost_hilfe {nick host hand text} {
    global post_botnick
    set abfragender $nick
    putserv "NOTICE $abfragender :/msg $post_botnick !neu <passwort> um eine Mail-Box unter deinem gegenwärtigen Nick zu erstellen."
    putserv "NOTICE $abfragender :/msg $post_botnick !sende <Nick> <Nachricht> um eine Nachricht zu senden."
    putserv "NOTICE $abfragender :/msg $post_botnick !lese <Nickname> <Passwort> um Nachrichten zu lesen."
}

bind msg - !sende botpost_sende
proc botpost_sende {nick host hand text} {
    global post_nachrichten
    global post_benutzerdatei
    set adressat [lindex $text 0]
    set nachricht "$nick sagt: [lrange $text 1 end]"
    putserv "NOTICE $nick :Nachricht gesendet!"
    putlog "Nachricht an $adressat: $nachricht"
    add $adressat $nachricht $post_nachrichten
}


proc add {key value file} {
    exec "touch" $file
    set fh [open $file a]
    puts $fh "$key => $value"
    close $fh
}

proc get {key file} {
    exec "touch" $file
    set fh [open $file r]
    set returnword {}
    while {![eof $fh]} {
	set stdin [string trim [gets $fh]]
	if {[eof $fh]} { break }
	set breaker [lsearch -exact $stdin "=>"]
	set getkey [lrange $stdin 0 [expr $breaker - 1]] 
	set getresult [lrange $stdin [expr $breaker + 1] end]
	if {[string tolower $getkey] == [string tolower $key]} { set returnword $getresult }
    }
    close $fh
    return $returnword
}

proc remove {word file} {
    exec "touch" $file
    set fh [open $file r]
    set return {}
    set del 0
    while {![eof $fh]} {
	set stdin [string trim [gets $fh]]
	if {[eof $fh]} { break }
	if {![regexp -nocase $word $stdin]} {
	    lappend return $stdin
	} {
	    incr del 1
	}
    }
    close $fh;
    set fh [open $file w]
    foreach a $return {
	puts $fh $a
    }
    close $fh
    return $del
}
i
inxs
Voice
Posts: 29
Joined: Fri Jun 10, 2005 5:33 am
Location: India

Post by inxs »

thanks :D but i down understand German lang
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

In english :)

Code: Select all

set post_userfile "scripts/post.userfile"
set post_messages "scripts/post.messages"

#here the name of your bot
set post_botnick "XXXXXXX"

bind join - * bot_checkpost
proc bot_checkpost {nick host hand channel} {
    global post_messages
    global post_botnick
    if {[get $nick $post_messages]!=""} {
	putserv "NOTICE $nick :13A new message is waiting for you!"
	putserv "NOTICE $nick :Type /msg $post_botnick !read <Passwort>."
    }
}

bind msgm - "!new*" botpost_new
proc botpost_new {nick host hand text} {
    global post_userfile
    set passwort [lindex $text 1]
    if {$passwort==""} {
	putserv "NOTICE $nick : No password allocated!";
    } else {
	if {[get $nick $post_userfile] == ""} {
	    add $nick $passwort $post_userfile
	} else {
	    putserv "NOTICE $nick : Your Mail-Box currently exists!"
	}
    }
}

bind msgm - "!read*" botpost_lese
proc botpost_lese {nick host hand text} {
    global post_messages
    global post_userfile
    global post_botnick
    set passwort [lindex $text 2]
    set postnick [lindex $text 1]
    if {$passwort == ""} {
	set passwort [lindex $text 1]
	set postnick $nick
    }

    if {[get $postnick $post_userfile]==""} {
	putserv "NOTICE $nick :You have no Mail-Box."
	putserv "NOTICE $nick :Type /msg $post_botnick !new <password> to order a Mail-Box!"
    }

    if {[get $postnick $post_userfile]!=$passwort} {
	putserv "NOTICE $nick : Wrong Password!"
    } else {
	set nachricht [get $postnick $post_messages]
	if {$nachricht == "" } {
	    putserv "NOTICE $nick : You have no messages!"
	} else {
	    putserv "NOTICE $nick : $nachricht"
	    remove $postnick $post_messages
	    set nachricht [get $postnick $post_messages]
	    while {$nachricht != ""} {
		putserv "NOTICE $nick : $nachricht"
		remove $postnick $post_messages
	    }
	}
    }
}

#HELP WITH SYNTAX !botpost
bind msg - !botpost botpost_help
proc botpost_help {nick host hand text} {
    global post_botnick
    set abfragender $nick
    putserv "NOTICE $abfragender :/msg $post_botnick !new <password> to order a Mail-Box."
    putserv "NOTICE $abfragender :/msg $post_botnick !send <nick> <message> to send a message."
    putserv "NOTICE $abfragender :/msg $post_botnick !read <nickname> <password> to read the messages."
}

bind msg - !send botpost_sende
proc botpost_sende {nick host hand text} {
    global post_messages
    global post_userfile
    set adressat [lindex $text 0]
    set nachricht "$nick sagt: [lrange $text 1 end]"
    putserv "NOTICE $nick :message was sent!"
    putlog "Message to $adressat: $nachricht"
    add $adressat $nachricht $post_messages
}


proc add {key value file} {
    exec "touch" $file
    set fh [open $file a]
    puts $fh "$key => $value"
    close $fh
}

proc get {key file} {
    exec "touch" $file
    set fh [open $file r]
    set returnword {}
    while {![eof $fh]} {
	set stdin [string trim [gets $fh]]
	if {[eof $fh]} { break }
	set breaker [lsearch -exact $stdin "=>"]
	set getkey [lrange $stdin 0 [expr $breaker - 1]] 
	set getresult [lrange $stdin [expr $breaker + 1] end]
	if {[string tolower $getkey] == [string tolower $key]} { set returnword $getresult }
    }
    close $fh
    return $returnword
}

proc remove {word file} {
    exec "touch" $file
    set fh [open $file r]
    set return {}
    set del 0
    while {![eof $fh]} {
	set stdin [string trim [gets $fh]]
	if {[eof $fh]} { break }
	if {![regexp -nocase $word $stdin]} {
	    lappend return $stdin
	} {
	    incr del 1
	}
    }
    close $fh;
    set fh [open $file w]
    foreach a $return {
	puts $fh $a
    }
    close $fh
    return $del
}
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

instead of using all that

Code: Select all

#here the name of your bot 
set post_botnick "XXXXXXX"
and
$post_botnick
use

Code: Select all

global botnick
and $::botnick
Otherwise when the botnick changes, the $post_botnick var does not change!
r0t3n @ #r0t3n @ Quakenet
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Also

Code: Select all

bind msgm - "!read*" botpost_lese 
proc botpost_lese {nick host hand text} { 
    global post_messages 
    global post_userfile 
    global post_botnick 
could be changed to

Code: Select all

bind msgm - "!read*" botpost_lese 
proc botpost_lese {nick host hand text} { 
    global post 
i think ;p
r0t3n @ #r0t3n @ Quakenet
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Tosser^^ wrote:

Code: Select all

global botnick
and $::botnick
If you globalize botnick then you don't have to use $::botnick, you globalize it so you can use $botnick. $::botnick can be used when it's not globalized.
Tosser^^ wrote:

Code: Select all

 
bind msgm - "!read*" botpost_lese 
proc botpost_lese {nick host hand text} { 
    global post_messages 
    global post_userfile 
    global post_botnick
could be changed to

Code: Select all

bind msgm - "!read*" botpost_lese 
proc botpost_lese {nick host hand text} { 
    global post 
i think ;p
You thought wrong again, 'post' is not an array (which would look like this btw post(element) and not post_element)
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Arrh, i see, i was thinking is was a array, oh well ;p
i sometimes get them the wrong way around
r0t3n @ #r0t3n @ Quakenet
i
inxs
Voice
Posts: 29
Joined: Fri Jun 10, 2005 5:33 am
Location: India

Post by inxs »

thanks all :D , can u tell me the command to add text for this.
is this a public command, i want this script for my eggdrop trivia.tcl to add a Q&A , as /msg botnick add answer*question only that no other things needed to save it to trivia.something(anything :D )
Locked