View previous topic :: View next topic |
Author |
Message |
COBRa Halfop
Joined: 04 Jan 2013 Posts: 49
|
Posted: Fri Dec 29, 2017 6:16 am Post subject: Data Output |
|
|
Hi guys just scripted a small proc to display bots and owners from a database it outputs like this atm
Code: | [9:48am] <~TurQ> !owners
[9:48am] <+ClonE> [OWNERS] TurQ owns AddFeeD
[9:48am] <+ClonE> [OWNERS] TurQ owns KaNE
[9:48am] <+ClonE> [OWNERS] alterego owns PREvision
[9:48am] <+ClonE> [OWNERS] alterego owns dapre
[9:48am] <+ClonE> [OWNERS] MaTr1X owns MaTr1X
[9:48am] <+ClonE> [OWNERS] DarkSide owns DarkSide
[9:48am] <+ClonE> [OWNERS] TurQ owns PR3
[9:48am] <+ClonE> [OWNERS] TurQ owns |PR3|
[9:48am] <+ClonE> [OWNERS] TurQ owns TRiAD |
if possible i would to output it like this
Code: | [OWNERS] TurQ owns AddFeeD, KaNE, PR3, |PR3|, TRiAD
[OWNERS] alterego owns PREvision, dapre |
so it would be one owner per line instead of multiple lines
here is my proc so far
Code: | ###################################
## !owners ###################
###################################
proc dupe:owners { nick uhost hand chan arg } {
global mysql_ otable_ chan_ db_handle bopen bdiv bclose
if {![mysqlsel $db_handle "SELECT `id` , `owner` , `botname` FROM `bots`"]} {putnow "PRIVMSG $chan_(addbot) :No results found\."; return 0}
mysqlmap $db_handle {id owner botname} {
putnow "PRIVMSG $chan :${bopen}\00303OWNERS\003${bclose} \00314$owner owns $botname\003"
}
} |
many thx in advance |
|
Back to top |
|
 |
caesar Ass Kicker

Joined: 14 Oct 2001 Posts: 3450 Location: Area 51
|
Posted: Mon Jan 29, 2018 6:57 am Post subject: |
|
|
Sorry for the late answer. You can achieve this directly from the select with:
Code: |
SELECT owner, group_concat(botname) AS bots FROM bots GROUP BY owner
|
and the result is:
Code: |
owner / bots
alterego / PREvision,dapre
DarkSide / DarkSide
MaTr1X / MaTr1X
TurQ / AddFeeD,KaNE,PR3,|PR3|,TRiAD
|
Your code becomes:
Code: |
proc dupe:owners {nick uhost hand chan text} {
global mysql_ otable_ chan_ db_handle bopen bdiv bclose
if {![mysqlsel $db_handle "SELECT owner, group_concat(botname) AS bots FROM bots GROUP BY owner"]} {
putnow "PRIVMSG $chan_(addbot) :No results found\."
return
}
mysqlmap $db_handle {owner bots} {
putnow "PRIVMSG $chan :${bopen}\00303OWNERS\003${bclose} \00314$owner owns [join [split $bots ","] ", "]\003"
}
}
|
_________________ You may say anything about me, but at least don't misspell my name. xD |
|
Back to top |
|
 |
|
|
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
|
|