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
}
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
}
Code: Select all
#here the name of your bot
set post_botnick "XXXXXXX"
and
$post_botnick
Code: Select all
global botnick
and $::botnick
Code: Select all
bind msgm - "!read*" botpost_lese
proc botpost_lese {nick host hand text} {
global post_messages
global post_userfile
global post_botnick
Code: Select all
bind msgm - "!read*" botpost_lese
proc botpost_lese {nick host hand text} {
global post
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
global botnick and $::botnick
You thought wrong again, 'post' is not an array (which would look like this btw post(element) and not post_element)Tosser^^ wrote:could be changed toCode: Select all
bind msgm - "!read*" botpost_lese proc botpost_lese {nick host hand text} { global post_messages global post_userfile global post_botnick
i think ;pCode: Select all
bind msgm - "!read*" botpost_lese proc botpost_lese {nick host hand text} { global post