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 

Searching from MySQL db and posting to chan?

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


Joined: 09 Mar 2006
Posts: 18

PostPosted: Sun Mar 26, 2006 4:41 pm    Post subject: Searching from MySQL db and posting to chan? Reply with quote

I'm using eggdrop with mysqltcl, i need a small code to search a mysql db and posting result to chan.

Mysql db is set up as;
id time info secondayinfo
example:
37 1143405316 Soundblaster-Creative Soundcard

So, how do search the info field (Soundblaster-Creative), and posting the info to channel as "Soundblaster-Creative (Soundcard) got updated xDxMxS (monts/days/hrs/etc) ago"..?

Its probably easy as heck, but i've tried for hours now and still havent been able to figure it out.. Neutral
Back to top
View user's profile Send private message
dwickie
Halfop


Joined: 21 Aug 2004
Posts: 76
Location: /pub/beer

PostPosted: Mon Mar 27, 2006 5:22 am    Post subject: Reply with quote

Code:
foreach result [mysqlsel $mysql(conn) "SELECT * FROM `releases` WHERE `rls` LIKE '%$arg%' LIMIT 10" -list] {
  set time [lindex $restul 1]
  set rls [lindex $result 2]
  set sect [lindex $result 3]
  putserv "PRIVMSG $chan :$rls ($sec) got updated [duration [expr [unixtime]-$time]] ago"
}


something like that? $arg is search string...
Back to top
View user's profile Send private message
Danko
Voice


Joined: 09 Mar 2006
Posts: 18

PostPosted: Mon Mar 27, 2006 6:35 am    Post subject: Reply with quote

Yes thanks a million, dwickie. Just what I needed. Smile

(except for the one typo in restul/result, heh)
Back to top
View user's profile Send private message
Danko
Voice


Joined: 09 Mar 2006
Posts: 18

PostPosted: Mon Mar 27, 2006 6:45 am    Post subject: Reply with quote

One more thing, is it possible to change the standard output "days, hours, minutes, etc" to d, h, m, s, w, mn, etc? Smile
Back to top
View user's profile Send private message
dwickie
Halfop


Joined: 21 Aug 2004
Posts: 76
Location: /pub/beer

PostPosted: Mon Mar 27, 2006 8:03 am    Post subject: Reply with quote

Danko wrote:
One more thing, is it possible to change the standard output "days, hours, minutes, etc" to d, h, m, s, w, mn, etc? Smile


Code:

string map {" years" y " year" y " weeks" w " week" w " days" d " day" d " hours" h " hour" h " minutes" m " minute" m " seconds" s " second" s} $time


will convert $time (for example 36 years 13 weeks 3 days 12 hours 3 minutes 13 seconds) to 36y 13w 3d 12h 2m 9s
Back to top
View user's profile Send private message
Danko
Voice


Joined: 09 Mar 2006
Posts: 18

PostPosted: Tue Mar 28, 2006 7:25 pm    Post subject: Reply with quote

Short question;
How do I add a "No info found" to channel if nothing is found? Confused
Back to top
View user's profile Send private message
dwickie
Halfop


Joined: 21 Aug 2004
Posts: 76
Location: /pub/beer

PostPosted: Mon Apr 03, 2006 4:11 am    Post subject: Reply with quote

Danko wrote:
Short question;
How do I add a "No info found" to channel if nothing is found? Confused


simple edit:

Code:

set query [mysqlsel $mysql(conn) "SELECT * FROM `releases` WHERE `rls` LIKE '%$arg%' LIMIT 10" -list]
if {$query==""} { putserv "PRIVMSG $chan :Nothing found" ; return }
foreach result $query {
  set time [lindex $restul 1]
  set rls [lindex $result 2]
  set sect [lindex $result 3]
  putserv "PRIVMSG $chan :$rls ($sec) got updated [duration [expr [unixtime]-$time]] ago"
}
Back to top
View user's profile Send private message
ayie
Voice


Joined: 20 Feb 2003
Posts: 38

PostPosted: Thu Jun 29, 2006 12:23 am    Post subject: Reply with quote

dwickie :
what about if i have some file like etc.db etc1.db etc2.db and when user use command fro example !db 1234 ... then the bot will search all the db file and return to user like this User 1234|data|from|db|file.
can it possible in tcl file ?
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