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 

Script Insert Help

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Ace2008
Voice


Joined: 28 Jun 2008
Posts: 1

PostPosted: Sat Jun 28, 2008 4:56 pm    Post subject: Script Insert Help Reply with quote

i want to insert some text to a db but i know this is half correct anyway lol
but i have a prob. this bit is wrong if {$info=="NEWS && position == 1"} and not sure how to fix it.

the bot announces like so,
#2: NEWS :: World News :: Today 1hr 4mins 22secs ago - BBCNews: UK the empty world ::

but my code will fail if where "the empty world" would change and become say 5 words

Code:

bind pubm - * news_insert

proc pre_insert {nick host handle channel text} {
    global db_handle

proc filter_mirc_codes {} {
  upvar text text
  regsub -all -- "(\002|\017|\026|\037|\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?)"  $text "" text
}

filter_mirc_codes


set position [lindex [string map {# {} : {}} $text] 0]
set info [lindex $text 1]

if {$info=="NEWS && position == 1"} { <--- [b] I KNOW THIS BIT IS WRONG [/b]

set 1 [lindex [split $text] 6] [lindex [split $text] 7]
set 2 [lindex $text 3]
set 3 [lindex $text 12]
set 4 [lindex [split $text] 13] [lindex [split $text] 14]

set sql "blah"
}
  mysqlendquery $db_handle
}
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Jun 28, 2008 10:43 pm    Post subject: Reply with quote

Code:

bind pubm - * news_insert

proc pre_insert {nick host handle channel text} {
   set text [split [stripcodes bcruag $text]]
   set position [string map {"#" "" ":" ""} [lindex $text 0]]
   set info [lindex $text 1]
   if {($info == "NEWS") && ($position == "1")} {
      set a [join [lrange $text 6 7]]
      set b [lindex $text 3]
      set c [lindex $text 12]
      set d [join [lrange $text 13 end]]
      set sql "blah"
   }
   mysqlendquery $::db_handle
}


You cannot set 1,2,3,4 to any other values.. because they are already numeric, variables begin with an alphabetic character a-z, also fixed your flawed evaluation the "I KNOW THIS BIT IS WRONG" part, also added the necessary split and the stripcodes, lrange sensibly substituted for multiple lindex as well. There are quite a few things that go wrong when you kludge together code you have no idea how works. Don'tcha think?

And now I've got to wonder, why you have the procedure titled pre_insert and the bind labeled news_insert?.. oops, was I not supposed to find this out.. but i bet.... this has something to do with piracy, not to mention databases, warez releases, pre times (all of which you failed to mention knowing it would get you zero support, your post junked, and similar consequences). This is something not really suited to discussion on this forum. It lends itself to discussion on piracy and hundreds of other things not related at all to eggdrop (where can i find 'xyz' warez release? similar to this). I would not be surprised at all to find this junked, not surprised at all... Rolling Eyes
_________________
speechles' eggdrop tcl archive
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 -> Scripting Help 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