egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Notes script.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
theplop
Voice


Joined: 27 Jan 2006
Posts: 7
Location: Idaho

PostPosted: Thu Jun 08, 2006 3:01 pm    Post subject: Notes script. Reply with quote

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)
Back to top
View user's profile Send private message
whittinghamj
Op


Joined: 21 May 2006
Posts: 103

PostPosted: Thu Jun 08, 2006 10:26 pm    Post subject: Reply with quote

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:

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.
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Thu Jun 08, 2006 11:26 pm    Post subject: Reply with quote

uzeno.tcl
Back to top
View user's profile Send private message
theplop
Voice


Joined: 27 Jan 2006
Posts: 7
Location: Idaho

PostPosted: Fri Jun 09, 2006 1:06 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
theplop
Voice


Joined: 27 Jan 2006
Posts: 7
Location: Idaho

PostPosted: Fri Jun 09, 2006 2:22 pm    Post subject: Reply with quote

ok the part i'm having trouble with is understanding what each part of the note delivery does.

Code:
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:
 puts $filemuvelet "$nick $cimzett $csatorna $ido [join $uzenet] "


i changed that to read

Code:
 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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber