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 

lsort help

 
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: Sat Jan 09, 2016 8:59 am    Post subject: lsort help Reply with quote

Hi guys i have a script that writes and reads a .txt file and im trying to list the file alphabetically

here is the code

Code:
# set the location of the banned.txt file
set banned_(txt) "/home/eggbots/eggdrop/scripts/banned.txt"

#set the sitename
set site_(name) "FtN"

#set the trigger
bind pub - !banned get:banned
bind pub - !addban get:addban
bind pub - !delban get:delban

proc get:banned {nick uhost handle chan arg} {
  global banned_ site_

   set fp [open $banned_(txt) "r"]
   set data [read -nonewline $fp]
   close $fp

   set lines [split $data "\n"]
   set line_sort [lsort -dictionary $lines]
   set lines1 [split $line_sort "\n"]
   
   putserv "privmsg $chan :\00314$site_(name)\003 - \0034(BaNNeD LiST)\003 - $lines1"

}

proc get:addban {nick uhost handle chan text} {
  global banned_
   if {$text == ""} {
   putserv "PRIVMSG $chan :Usage: !addban <grpname>"
   return 0
   }
   set line_to_add $text
   set fname $banned_(txt)
   set fp [open $fname "a"]
   puts $fp $line_to_add
   close $fp
     
   putquick "PRIVMSG $chan : \0034Ban Added Sucessfully\003"
}

proc get:delban {nick uhost handle chan text} {
   global banned_

   set fp [open $banned_(txt) "r"]
   set data [read -nonewline $fp]
   close $fp

   set lines [split $data "\n"]

   set el_num [lsearch $lines $text]

   if {$el_num != -1} {

      set lines [lreplace $lines $el_num $el_num]
   }

    putquick "PRIVMSG $chan : \0034Ban Removed Sucessfully\003"

   set fp [open $banned_(txt) "w"]

   foreach element $lines {
      puts $fp $element
   }
   close $fp


}


but it outputs with these braces

Code:
FtN - (BaNNeD LiST) - {aBD AlternativePorn ANiURL CoWRY D3Si EiNFACHNORMAL GAYGAY JustDifferent Ltu MANLOVE N3WS NAMi ONEPiECE PMCG PR0N0Z ZHONGGUO}


is it possible to output without the {} plz

many thx in advance
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Jan 09, 2016 9:16 am    Post subject: Reply with quote

A quick read-through of the code suggests there are some flaws in the get:banned proc, mainly related to how lists are handled...

Depending on how you'd like the output, you might try replacing the following line:
Code:
set lines1 [split $line_sort "\n"]

into
Code:
set lines1 [join $line_sort ", "]

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
COBRa
Halfop


Joined: 04 Jan 2013
Posts: 49

PostPosted: Mon Jan 11, 2016 8:02 am    Post subject: Reply with quote

Many thx it works a treat
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