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 

Data Output

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


Joined: 04 Jan 2013
Posts: 49

PostPosted: Fri Dec 29, 2017 6:16 am    Post subject: Data Output Reply with quote

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] *** owns *******
[9:48am] <+ClonE> [OWNERS] *** owns ****
[9:48am] <+ClonE> [OWNERS] *** owns ****
[9:48am] <+ClonE> [OWNERS] **** owns ****
[9:48am] <+ClonE> [OWNERS] *** owns ***


if possible i would to output it like this

Code:
[OWNERS] owner1 owns bot1, bot2, bot3
[OWNERS] owner2 owns bot1, bot2


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


Last edited by COBRa on Thu May 17, 2018 11:40 am; edited 1 time in total
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3459
Location: Area 51

PostPosted: Mon Jan 29, 2018 6:57 am    Post subject: Reply with quote

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
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