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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
theplop
Voice
Posts: 7 Joined: Fri Jan 27, 2006 5:46 pm
Location: Idaho
Post
by theplop » Thu Jun 08, 2006 3:01 pm
I am looking for a script that will give the message as soon as the person speaks. So if i left a message for bob, it would be delivered as soon as bob spoke. It also lets you know who left the message.
If possible, make it so that if you saved a note to "slack" it would deliver it to anyone whos nick starts with slack, eg: slackware and slacker.
This make sense?
Thanks!
syntax
!note <nick> <message>
<@i2tb>!note bob hi bob, how are you?
<@Fat-X>*note has been saved*
<@i2tb> dude
<@DanMan> wassup?
<bob>Hi guys
<@Fat-X>bob: hi bob, how are you? -- i2tb (2h4m ago)
whittinghamj
Op
Posts: 103 Joined: Sun May 21, 2006 4:50 pm
Post
by whittinghamj » Thu Jun 08, 2006 10:26 pm
this is a message script I have been using on my bot for a long time now. It does exactly what you need. This is NOT my own code but from the TCL dump.
Code: Select all
bind pub -|- "!msg" mess_do
bind pub -|- "!messages" mess_lista
bind pubm - * mess_join
bind time - "20 * * * *" mess_sort
bind pub v|o "!messaging" mess_info
bind msg -|- "!msg" mess_do_inmsg
set message_db "scripts/fserv/msg.dat"
set message_whodid ""
proc mess_info {nick host hand chan arg} {
puthelp "NOTICE $nick :Recepients list: !messages"
puthelp "NOTICE $nick :Leaving message: !msg <nick> <message>"
}
proc mess_sort {a c d e f} {
global message_db
set t_count [clock clicks -milliseconds]
set filemuvelet [open $message_db r]
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]
set filemuvelet [open $message_db w]
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 mess_do_inmsg {nick uhost hand rest} {
global botnick
putlog "mess_do_inmsg: $rest"
set rest [split $rest " "]
set cimzett [lindex $rest 0]
if {$cimzett == ""} {
puthelp "NOTICE $nick :The right format: !msg <nick> <message>"
} else {
mess_write $nick $cimzett [lrange $rest 1 end] "MSG"
puthelp "NOTICE $nick :Message for $cimzett accepted"
}
}
proc mess_do {nick host hand chan args} {
set args [lindex $args 0]
set args [split $args " "]
set cimzett [lindex $args 0]
if {$cimzett == ""} {
puthelp "NOTICE $nick :The right format: !msg <nick> <message>"
} 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 "NOTICE $nick :Message for $cimzett accepted"
}
}
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]
set filemuvelet [open $message_db w+]
puts $filemuvelet "Hadace !messaging database file created"
} else {
set filemuvelet [open $message_db a]
}
set systemTime [clock seconds]
set ido [clock format $systemTime -format {%d.%m.%Y. %H.%M:}]
puts $filemuvelet "$nick $cimzett $csatorna $ido [join $uzenet] "
close $filemuvelet
}
#####################
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
if {![info exists message_whodid]} {
set message_whodid ""
}
set nick [string tolower $nick]
set filemuvelet [open $message_db r]
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 $nick :[lindex $uzente 0] says at [join [lrange [split [lindex $osszesuzenet 0] " "] 2 end]]"
incr count
} else {
foreach konkretuzenet $osszesuzenet {
incr count
puthelp "PRIVMSG $nick :[lindex $konkretuzenet 0]\[${count}] says at [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
}
}
###############################################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]
set filemuvelet [open $message_db r]
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
set filemuvelet [open $message_db w]
foreach konkretuzenet $osszesuzenet {
puts $filemuvelet $konkretuzenet
}
close $filemuvelet
}
proc mess_lista {nick host hand chan args} {
global message_db
putserv "NOTICE $nick :\[ Recepients list \]"
set lista ""
set filemuvelet [open $message_db r]
while {![eof $filemuvelet]} {
lappend lista [lindex [split [gets $filemuvelet] " "] 1]
}
close $filemuvelet
foreach {a b c d e f g} [lsort -unique $lista] {
putserv "NOTICE $nick :Recepients: $a $b $c $d $e $f $g"
}
putserv "NOTICE $nick :\[ end of the list \]"
}
I hope this helps you. I have modded this script a little from its original state and it works perfectly. Any questions drop me a line.
DragnLord
Owner
Posts: 711 Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA
Post
by DragnLord » Thu Jun 08, 2006 11:26 pm
uzeno.tcl
theplop
Voice
Posts: 7 Joined: Fri Jan 27, 2006 5:46 pm
Location: Idaho
Post
by theplop » Fri Jun 09, 2006 1:06 pm
Thanks for the replies.
It looks as though the two scripts are very similar.
whittinghamj, i will be sticking with yours.
ok, now i was wondering if you could give me a hand tweeking it a bit.
1. i would like it to display thier note in the channel and not in a private message.
2. i would like to re-arrange how the note is formatted. instead of " ex_ex says at #teamvatican 09.06.2006. 11.12: stupid notes" something more like (in the channel) "<to nick:> <message> <from nick> <how long ago>"
I don't expect you guys to do if for me, so i will be trying to do it myself, though I'm not very good at TCL, and help is very much appreciated.
Thanks
theplop
Voice
Posts: 7 Joined: Fri Jan 27, 2006 5:46 pm
Location: Idaho
Post
by theplop » Fri Jun 09, 2006 2:22 pm
ok the part i'm having trouble with is understanding what each part of the note delivery does.
Code: Select all
puthelp "PRIVMSG #channel :[lindex $uzente 0] says at [join [lrange [split [lindex $osszesuzenet 0] " "] 2 end]]"
I got it to display to the channel by replacing $nick with #channel
Now, i'm trying to figure out what each part is.
<@Fat-S> ex_ex[3] says at #teamvatican 09.06.2006. 12.07: hi, this is my note
I noticed that the channel name, and timestamp are dropped into the database when the note is stored.
Code: Select all
puts $filemuvelet "$nick $cimzett $csatorna $ido [join $uzenet] "
i changed that to read
Code: Select all
puts $filemuvelet "$cimzett : [join $uzenet] -- $nick $ido "
which looks like this:
kilroy : did you get any messages? -- ex_ex @ 09. 13.40
Now i seem to have broken the trigger that catches when the person speaks. I am still looking for it, and will post my finding when i get them.