Hi Fahad, here's the script I'm using on my egg:Fahad wrote:I want "Message" TCL it's like MemoServ - Like if i leave a message for someone if he joins back in channel he will get notice you have a message to read.
For Example:-
MESSAGE System:
!msg <nick> <message> (With this feature, you can leave a message for your friends. Bot will convey your message, as and when the respective user gets online/active)
Code: Select all
# Hadace messaging (uzeno-eng-win-beta v.1.5 WINDOWS ENGLISH BETA 2005.nov.08) #mfc.cs @ quakenet
# NOTE!!
# you must manualy create an empty file named: h_message.dat into your bot's main directory.
# __ ___ ____ _ ___ __
# \ \ / (_)_ __ / ___|| | | \ \/ /
# \ \ /\ / /| | '_ \\___ \| | | |\ /
# \ V V / | | | | |___) | |_| |/ \
# \_/\_/ |_|_| |_|____/ \___//_/\_\
# my TCL scripts are avaiable here:
# http://mazsola.linuxteam.hu/tcl/
# WARNING !
# in this version user rights are not correct!
# it must be corrected!
foreach bind [binds msg] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds messages] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds mess_alert] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds messalert] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds mess_join] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
bind pub - "!msg" msg
bind pub - "!messages" messages
bind join - * mess_alert
bind rejn - * mess_alert
bind nick - * messalert
bind pubm - * mess_join
#bind pub v|o "!msg" msg
#bind pub o|o "!messages" messages
#bind pubm - * mess_join
#bind time - "0 * * * *" mess_sort
#bind pub v|o "!messaging" mess_info
#bind msg v|o "!msg" mess_do_inmsg
foreach bind [binds pubmsg] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
# bind pubm - "% <*> !msg" pubmsg
# bind pubm - "% <*> !msg *" pubmsg
proc pubmsg {nick uhost hand chan rest} {
set myrest [split $rest];
set newnick [string range [lindex $myrest 0] 1 end-1];
set newrest [lrange $myrest 2 end];
msg $newnick $uhost $hand $chan $newrest
return 0
}
foreach bind [binds pubmessages] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
# bind pubm - "% <*> !messages" pubmessages
# bind pubm - "% <*> !messages *" pubmessages
proc pubmessages {nick uhost hand chan rest} {
set myrest [split $rest];
set newnick [string range [lindex $myrest 0] 1 end-1];
set newrest [lrange $myrest 2 end];
messages $newnick $uhost $hand $chan $newrest
return 0
}
foreach bind [binds pubmess_join] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
# bind pubm - "% <*> *" pubmess_join
proc pubmess_join {nick uhost hand chan rest} {
set myrest [split $rest];
set newnick [string range [lindex $myrest 0] 1 end-1];
set newrest [lrange $myrest 1 end];
mess_join $newnick $uhost $hand $chan $newrest
return 0
}
set message_db "messages.txt"
set message_whodid ""
if {![file exists $message_db]} {
fconfigure [set File [open $message_db w]] -encoding binary
close $File
}
proc mess_sort {type} {
global message_db
set t_count [clock clicks -milliseconds]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
while {![eof $filemuvelet]} {
set konkretuzenet [gets $filemuvelet]
if {[info exists konkretuzenet]&&$konkretuzenet!=""} {
lappend osszesuzenet [split $konkretuzenet " "]
}
}
close $filemuvelet
set osszesuzenet [lsort -index 1 $osszesuzenet]
fconfigure [set filemuvelet [open $message_db w]] -encoding binary
foreach konkretuzenet $osszesuzenet {
puts $filemuvelet [join $konkretuzenet " "]
}
close $filemuvelet
putlog "!message Done with sorting of data on the database ($message_db)->[expr double([clock clicks -milliseconds]-$t_count)/1000]s"
}
proc msg {nick host hand chan args} {
putlog "mess_do indul"
set args [lindex $args 0]
set args [split $args " "]
set cimzett [lindex $args 0]
if {($cimzett == "") || ($cimzett == "help") || ($cimzett == "ayuda")} {
puthelp "PRIVMSG $chan :Usage: !msg <nick> <message> - Leave <message> to <nick>"
} else {
if {[onchan $cimzett $chan]} {
set mwhom $cimzett
set mmoo [finduser "*![getchanhost $mwhom $chan]"]
if {[validuser $mmoo]} {
set cimzett $mmoo
#putlog "uj uzenet $cimzett botuser szamara"
} else {
#putlog "uj uzenet $cimzett nick szamara"
}
}
mess_write $nick $cimzett [lrange $args 1 end] $chan
puthelp "PRIVMSG $chan :Message to $cimzett accepted"
}
return 1
}
proc mess_write { nick cimzett uzenet csatorna } {
global message_db
set cimzett [string tolower $cimzett]
if {![file exists $message_db]} {
file mkdir [lindex [split $message_db /] 0]
fconfigure [set filemuvelet [open $message_db w+]] -encoding binary
puts $filemuvelet "Hadace !messaging database file created"
} else {
fconfigure [set filemuvelet [open $message_db a]] -encoding binary
}
set systemTime [clock seconds]
set ido [clock format $systemTime -format {%d/%m/%Y %H:%M:}]
puts $filemuvelet "$nick $cimzett $ido [join $uzenet] "
close $filemuvelet
mess_sort 1
}
proc messalert { nick uhost hand chan args } {
mess_alert $args $uhost $hand $chan $nick
}
proc mess_alert { nick uhost hand chan args } {
#puthelp "NOTICE HeyBaby : $nick $uhost $hand $chan $args"
if {$hand != "*"} {
set explain [string tolower $hand]
} else {
set explain [string tolower $nick]
}
global message_db message_whodid botnick
if {![info exists message_whodid]} {
set message_whodid ""
}
if {($nick == $botnick)} { return }
set nick [string tolower $nick]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
set count 0
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
set konkretuzenet [split $konkretuzenet " "]
if {[string equal -nocase [lindex $konkretuzenet 1] $explain]} {
incr count
}
}
close $filemuvelet
if {$count > 0} {
puthelp "PRIVMSG $chan :$nick: You have $count message(s) pending. Say anything to receive it"
}
return 0
}
#####################
proc mess_join { nick uhost hand chan args } {
#puthelp "NOTICE HeyBaby : $nick $uhost $hand $chan $args"
if {$hand != "*"} {
set explain [string tolower $hand]
} else {
set explain [string tolower $nick]
}
global message_db message_whodid botnick
if {![info exists message_whodid]} {
set message_whodid ""
}
if {($nick == $botnick)} { return }
if {[string match -nocase "<*>*" $args]} { return }
set nick [string tolower $nick]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
set konkretuzenet [split $konkretuzenet " "]
if {[string equal -nocase [lindex $konkretuzenet 1] $explain]} {
lappend osszesuzenet [join $konkretuzenet " "]
}
}
close $filemuvelet
set count 0
if {[llength $osszesuzenet]==1} {
set uzente [split [lindex $osszesuzenet 0] " "]
puthelp "PRIVMSG $chan :$nick: [lindex $uzente 0]: [join [lrange [split [lindex $osszesuzenet 0] " "] 2 end]]"
incr count
} else {
foreach konkretuzenet $osszesuzenet {
incr count
puthelp "PRIVMSG $chan :$nick: [lindex $konkretuzenet 0]\[${count}]: [join [lrange [split $konkretuzenet " "] 2 end]]"
}
}
if {$count == 0} {
} else {
lappend message_whodid [list $explain [string tolower $chan]]
set explain [message_filterstr $explain] ;# Don't allow code to be executed
set chan [message_filterstr $chan] ;# ensure []s are properly handled...
mess_delete $explain
}
return 0
}
###############################################x
proc message_filterstr { data } {
regsub -all -- \\\\ $data \\\\\\\\ data
regsub -all -- \\\[ $data \\\\\[ data
regsub -all -- \\\] $data \\\\\] data
regsub -all -- \\\} $data \\\\\} data
regsub -all -- \\\{ $data \\\\\{ data
regsub -all -- \\" $data \\\\" data
return $data
}
proc mess_delete { cimzett {remnum "all"}} {
global message_db
set cimzett [string tolower $cimzett]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
set count 1
if {$remnum == "all"} {
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
if {![string equal -nocase [lindex [split $konkretuzenet] 1] $cimzett]} {
lappend osszesuzenet $konkretuzenet
}
}
} else {
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
if {![string equal -nocase [lindex [split $konkretuzenet] 1] $cimzett] || ($count != $remnum && $remnum != -2)} {
if {[info exists konkretuzenet]&&$konkretuzenet!=""} {
lappend osszesuzenet $konkretuzenet
}
if {[string equal -nocase [lindex [split $konkretuzenet] 1] $cimzett]} {
incr count
}
} else {
incr count
}
}
}
close $filemuvelet
fconfigure [set filemuvelet [open $message_db w]] -encoding binary
foreach konkretuzenet $osszesuzenet {
puts $filemuvelet $konkretuzenet
}
close $filemuvelet
mess_sort 1
}
proc messages {nick host hand chan args} {
global message_db
puthelp "PRIVMSG $chan :\[ List of message recipients \]"
set lista ""
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
while {![eof $filemuvelet]} {
lappend lista [lindex [split [gets $filemuvelet] " "] 1]
}
close $filemuvelet
foreach {a b c d e f g} [lsort -unique $lista] {
puthelp "PRIVMSG $chan :Recipients: $a $b $c $d $e $f $g"
}
puthelp "PRIVMSG $chan :\[ End of list \]"
return 1
}
putlog "Hadace messaging (uzeno.tcl v.1.5 ENG 2005.nov.08) #mfc.cs @ quakenet loaded"
<Hobbit_> [13:22:58] Tcl error [mess_alert]: invalid command name " "
<Hobbit_> [13:23:58] Tcl error [mess_alert]: invalid command name " "
<Hobbit_> [13:24:12] Tcl error [mess_join]: invalid command name " "
<Hobbit_> [13:24:12] Tcl error [msg]: can't read "relaybot": no such variable
Code: Select all
[00:40] <lalalla> .msg kdoe kofr
[00:40] <@BOT> Message to kdoe accepted
[00:40] == lalalla has changed nick to kdoe
[00:40] <@BOT> kdoe: You have 1 message(s) pending. Say anything to receive it
[00:40] <kdoe> ddd
[00:40] <@BOT kdoe: lalalla: 28/04/2017 00:40: kofr
I Serious don't understand this ERROR... It's Loaded already and I have create a empty folder "h_message.dat" in my bot main directory. What channel and Network your bot is? I create this folder in /home/eggy/eggdrop.CP1832 wrote:I double tested the script I gave you on my channel and it worked flawlessly:Code: Select all
[00:40] <lalalla> .msg kdoe kofr [00:40] <@BOT> Message to kdoe accepted [00:40] == lalalla has changed nick to kdoe [00:40] <@BOT> kdoe: You have 1 message(s) pending. Say anything to receive it [00:40] <kdoe> ddd [00:40] <@BOT kdoe: lalalla: 28/04/2017 00:40: kofr
Code: Select all
# Hadace messaging (uzeno-eng-win-beta v.1.5 WINDOWS ENGLISH BETA 2005.nov.08) #mfc.cs @ quakenet
# NOTE!!
# you must manualy create an empty file named: h_message.dat into your bot's main directory.
# __ ___ ____ _ ___ __
# \ \ / (_)_ __ / ___|| | | \ \/ /
# \ \ /\ / /| | '_ \\___ \| | | |\ /
# \ V V / | | | | |___) | |_| |/ \
# \_/\_/ |_|_| |_|____/ \___//_/\_\
# my TCL scripts are avaiable here:
# http://mazsola.linuxteam.hu/tcl/
# WARNING !
# in this version user rights are not correct!
# it must be corrected!
foreach bind [binds msg] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds messages] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds mess_alert] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds messalert] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds mess_join] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
bind pub - "!msg" msg
bind pub - "!messages" messages
bind join - * mess_alert
bind rejn - * mess_alert
bind nick - * messalert
bind pubm - * mess_join
#bind pub v|o "!msg" msg
#bind pub o|o "!messages" messages
#bind pubm - * mess_join
#bind time - "0 * * * *" mess_sort
#bind pub v|o "!messaging" mess_info
#bind msg v|o "!msg" mess_do_inmsg
foreach bind [binds pubmsg] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
# bind pubm - "% <*> !msg" pubmsg
# bind pubm - "% <*> !msg *" pubmsg
proc pubmsg {nick uhost hand chan rest} {
set myrest [split $rest];
set newnick [string range [lindex $myrest 0] 1 end-1];
set newrest [lrange $myrest 2 end];
msg $newnick $uhost $hand $chan $newrest
return 0
}
foreach bind [binds pubmessages] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
# bind pubm - "% <*> !messages" pubmessages
# bind pubm - "% <*> !messages *" pubmessages
proc pubmessages {nick uhost hand chan rest} {
set myrest [split $rest];
set newnick [string range [lindex $myrest 0] 1 end-1];
set newrest [lrange $myrest 2 end];
messages $newnick $uhost $hand $chan $newrest
return 0
}
foreach bind [binds pubmess_join] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
# bind pubm - "% <*> *" pubmess_join
proc pubmess_join {nick uhost hand chan rest} {
set myrest [split $rest];
set newnick [string range [lindex $myrest 0] 1 end-1];
set newrest [lrange $myrest 1 end];
mess_join $newnick $uhost $hand $chan $newrest
return 0
}
set message_db "messages.txt"
set message_whodid ""
if {![file exists $message_db]} {
fconfigure [set File [open $message_db w]] -encoding binary
close $File
}
proc mess_sort {type} {
global message_db
set t_count [clock clicks -milliseconds]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
while {![eof $filemuvelet]} {
set konkretuzenet [gets $filemuvelet]
if {[info exists konkretuzenet]&&$konkretuzenet!=""} {
lappend osszesuzenet [split $konkretuzenet " "]
}
}
close $filemuvelet
set osszesuzenet [lsort -index 1 $osszesuzenet]
fconfigure [set filemuvelet [open $message_db w]] -encoding binary
foreach konkretuzenet $osszesuzenet {
puts $filemuvelet [join $konkretuzenet " "]
}
close $filemuvelet
putlog "!message Done with sorting of data on the database ($message_db)->[expr double([clock clicks -milliseconds]-$t_count)/1000]s"
}
proc msg {nick host hand chan args} {
putlog "mess_do indul"
set args [lindex $args 0]
set args [split $args " "]
set cimzett [lindex $args 0]
if {($cimzett == "") || ($cimzett == "help") || ($cimzett == "ayuda")} {
puthelp "PRIVMSG $chan :Usage: !msg <nick> <message> - Leave <message> to <nick>"
} else {
if {[onchan $cimzett $chan]} {
set mwhom $cimzett
set mmoo [finduser "*![getchanhost $mwhom $chan]"]
if {[validuser $mmoo]} {
set cimzett $mmoo
#putlog "uj uzenet $cimzett botuser szamara"
} else {
#putlog "uj uzenet $cimzett nick szamara"
}
}
mess_write $nick $cimzett [lrange $args 1 end] $chan
puthelp "PRIVMSG $chan :Message to $cimzett accepted"
}
return 1
}
proc mess_write { nick cimzett uzenet csatorna } {
global message_db
set cimzett [string tolower $cimzett]
if {![file exists $message_db]} {
file mkdir [lindex [split $message_db /] 0]
fconfigure [set filemuvelet [open $message_db w+]] -encoding binary
puts $filemuvelet "Hadace !messaging database file created"
} else {
fconfigure [set filemuvelet [open $message_db a]] -encoding binary
}
set systemTime [clock seconds]
set ido [clock format $systemTime -format {%d/%m/%Y %H:%M:}]
puts $filemuvelet "$nick $cimzett $ido [join $uzenet] "
close $filemuvelet
mess_sort 1
}
proc messalert { nick uhost hand chan args } {
mess_alert $args $uhost $hand $chan $nick
}
proc mess_alert { nick uhost hand chan args } {
#puthelp "NOTICE HeyBaby : $nick $uhost $hand $chan $args"
if {$hand != "*"} {
set explain [string tolower $hand]
} else {
set explain [string tolower $nick]
}
global message_db message_whodid botnick
if {![info exists message_whodid]} {
set message_whodid ""
}
if {($nick == $botnick)} { return }
set nick [string tolower $nick]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
set count 0
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
set konkretuzenet [split $konkretuzenet " "]
if {[string equal -nocase [lindex $konkretuzenet 1] $explain]} {
incr count
}
}
close $filemuvelet
if {$count > 0} {
puthelp "PRIVMSG $chan :$nick: You have $count message(s) pending. Say anything to receive it"
}
return 0
}
#####################
proc mess_join { nick uhost hand chan args } {
#puthelp "NOTICE HeyBaby : $nick $uhost $hand $chan $args"
if {$hand != "*"} {
set explain [string tolower $hand]
} else {
set explain [string tolower $nick]
}
global message_db message_whodid botnick
if {![info exists message_whodid]} {
set message_whodid ""
}
if {($nick == $botnick)} { return }
if {[string match -nocase "<*>*" $args]} { return }
set nick [string tolower $nick]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
set konkretuzenet [split $konkretuzenet " "]
if {[string equal -nocase [lindex $konkretuzenet 1] $explain]} {
lappend osszesuzenet [join $konkretuzenet " "]
}
}
close $filemuvelet
set count 0
if {[llength $osszesuzenet]==1} {
set uzente [split [lindex $osszesuzenet 0] " "]
puthelp "PRIVMSG $chan :$nick: [lindex $uzente 0]: [join [lrange [split [lindex $osszesuzenet 0] " "] 2 end]]"
incr count
} else {
foreach konkretuzenet $osszesuzenet {
incr count
puthelp "PRIVMSG $chan :$nick: [lindex $konkretuzenet 0]\[${count}]: [join [lrange [split $konkretuzenet " "] 2 end]]"
}
}
if {$count == 0} {
} else {
lappend message_whodid [list $explain [string tolower $chan]]
set explain [message_filterstr $explain] ;# Don't allow code to be executed
set chan [message_filterstr $chan] ;# ensure []s are properly handled...
mess_delete $explain
}
return 0
}
###############################################x
proc message_filterstr { data } {
regsub -all -- \\\\ $data \\\\\\\\ data
regsub -all -- \\\[ $data \\\\\[ data
regsub -all -- \\\] $data \\\\\] data
regsub -all -- \\\} $data \\\\\} data
regsub -all -- \\\{ $data \\\\\{ data
regsub -all -- \\\" $data \\\\\" data
return $data
}
proc mess_delete { cimzett {remnum "all"}} {
global message_db
set cimzett [string tolower $cimzett]
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
set osszesuzenet ""
set count 1
if {$remnum == "all"} {
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
if {![string equal -nocase [lindex [split $konkretuzenet] 1] $cimzett]} {
lappend osszesuzenet $konkretuzenet
}
}
} else {
while {![eof $filemuvelet]} {
gets $filemuvelet konkretuzenet
if {![string equal -nocase [lindex [split $konkretuzenet] 1] $cimzett] || ($count != $remnum && $remnum != -2)} {
if {[info exists konkretuzenet]&&$konkretuzenet!=""} {
lappend osszesuzenet $konkretuzenet
}
if {[string equal -nocase [lindex [split $konkretuzenet] 1] $cimzett]} {
incr count
}
} else {
incr count
}
}
}
close $filemuvelet
fconfigure [set filemuvelet [open $message_db w]] -encoding binary
foreach konkretuzenet $osszesuzenet {
puts $filemuvelet $konkretuzenet
}
close $filemuvelet
mess_sort 1
}
proc messages {nick host hand chan args} {
global message_db
puthelp "PRIVMSG $chan :\[ List of message recipients \]"
set lista ""
fconfigure [set filemuvelet [open $message_db r]] -encoding binary
while {![eof $filemuvelet]} {
lappend lista [lindex [split [gets $filemuvelet] " "] 1]
}
close $filemuvelet
foreach {a b c d e f g} [lsort -unique $lista] {
puthelp "PRIVMSG $chan :Recipients: $a $b $c $d $e $f $g"
}
puthelp "PRIVMSG $chan :\[ End of list \]"
return 1
}
putlog "Hadace messaging (uzeno.tcl v.1.5 ENG 2005.nov.08) #mfc.cs @ quakenet loaded"
Maybe there's some TCL issues with your eggdrop (or maybe it's too old). Actually, the file where the messages are stored in is defined by message_db and if the file doesn't exist, the script should be creating it.Fahad wrote:I Serious don't understand this ERROR... It's Loaded already and I have create a empty folder "h_message.dat" in my bot main directory. What channel and Network your bot is? I create this folder in /home/eggy/eggdrop.
Tcl error [mess_alert]: invalid command name " "
Tcl error [mess_join]: invalid command name " "
Tcl error [msg]: invalid command name " "
I am pasting code again. please check the code.
Code: Select all
set message_db "messages.txt"
set message_whodid ""
if {![file exists $message_db]} {
fconfigure [set File [open $message_db w]] -encoding binary
close $File
}