| View previous topic :: View next topic |
| Author |
Message |
Danko Voice
Joined: 09 Mar 2006 Posts: 18
|
Posted: Sun Mar 26, 2006 4:41 pm Post subject: Searching from MySQL db and posting to chan? |
|
|
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..  |
|
| Back to top |
|
 |
dwickie Halfop
Joined: 21 Aug 2004 Posts: 76 Location: /pub/beer
|
Posted: Mon Mar 27, 2006 5:22 am Post subject: |
|
|
| 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 |
|
 |
Danko Voice
Joined: 09 Mar 2006 Posts: 18
|
Posted: Mon Mar 27, 2006 6:35 am Post subject: |
|
|
Yes thanks a million, dwickie. Just what I needed.
(except for the one typo in restul/result, heh) |
|
| Back to top |
|
 |
Danko Voice
Joined: 09 Mar 2006 Posts: 18
|
Posted: Mon Mar 27, 2006 6:45 am Post subject: |
|
|
One more thing, is it possible to change the standard output "days, hours, minutes, etc" to d, h, m, s, w, mn, etc?  |
|
| Back to top |
|
 |
dwickie Halfop
Joined: 21 Aug 2004 Posts: 76 Location: /pub/beer
|
Posted: Mon Mar 27, 2006 8:03 am Post subject: |
|
|
| 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?  |
| 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 |
|
 |
Danko Voice
Joined: 09 Mar 2006 Posts: 18
|
Posted: Tue Mar 28, 2006 7:25 pm Post subject: |
|
|
Short question;
How do I add a "No info found" to channel if nothing is found?  |
|
| Back to top |
|
 |
dwickie Halfop
Joined: 21 Aug 2004 Posts: 76 Location: /pub/beer
|
Posted: Mon Apr 03, 2006 4:11 am Post subject: |
|
|
| Danko wrote: | Short question;
How do I add a "No info found" to channel if nothing is found?  |
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 |
|
 |
ayie Voice

Joined: 20 Feb 2003 Posts: 38
|
Posted: Thu Jun 29, 2006 12:23 am Post subject: |
|
|
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 |
|
 |
|