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 

Again doubts a braces in nick

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


Joined: 15 Mar 2015
Posts: 317

PostPosted: Wed May 13, 2015 12:48 am    Post subject: Again doubts a braces in nick Reply with quote

I wish the nick containing braces in file storage.

Something explained me SpiKe^^ in another post, but it was referred to a list, which added nicks.
Now is another case, I store every nick on a separate line of a file.

I don't know fix it for this particular case a file. Embarassed

example:
Quote:
!notiadd {juan}
Returns first line of file (prohibidos.txt) {juan}
!notiadd pedro
Returns second line of file (prohibidos.txt) pedro

Code:
bind pub at|n !notiadd notiadd
proc notiadd {nick uhost handle chan text} {
  set nickpro [lindex $text 0]
  if {![file exist prohibidos.txt]} {
  set fs [open prohibidos.txt "w"]
  puts $fs ""
  close $fs
}  else {
set fname "prohibidos.txt"
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
set first [lindex $lines 0]
if {$first == ""} {
set lines [lreplace $lines 0 0]
set fp [open $fname "w"]
puts $fp [join $lines "\n"]
close $fp
}
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines1 [split $data "\n"]
if {([lsearch -exact [string tolower $lines1] [string tolower $nickpro]] == -1)} {
set fp [open $fname "a"]
puts $fp $nickpro
close $fp
  putmsg $canal_admin [encoding convertfrom utf-8 "\002$nickpro\002 has been added to the list of banned nicks."]
   } else {
  putmsg $canal_admin [encoding convertfrom utf-8 "$nickpro was already added!"]
   return
  }
}}

_________________
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks Smile
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Wed May 13, 2015 8:28 am    Post subject: Re: Again doubts a braces in nick Reply with quote

juanamores wrote:
I wish the nick containing braces in file storage.
...
example:
Quote:
!notiadd {juan}
Returns first line of file (prohibidos.txt) {juan}
!notiadd pedro
Returns second line of file (prohibidos.txt) pedro

Code:
bind pub at|n !notiadd notiadd
proc notiadd {nick uhost handle chan text} {
  set nickpro [lindex $text 0]
...
 




1.) It would help a LOT if when you post code here, it was indented.
Indents and line spaces make code easier to read.

2.) Go here:
http://web.archive.org/web/20070205113405/http://www.peterre.info/characters.html

and read. Especially this section, "The first golden rule of Tcl for eggdrop".

Bookmark that page, and refer back to it, until you master it.


3.) Here is the problem: set nickpro [lindex $text 0]

lindex works on lists, not on strings. $text is a string.
You can "get away with it" sometimes. Then you acquire a bad habit, and one day it comes back to bite you.
Here we are. Smile

Try this: set nickpro [lindex [split $text] 0]



p.s
The code you posted is missing :

set canal_admin $chan

too.
_________________
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Back to top
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Wed May 13, 2015 4:09 pm    Post subject: Re: Again doubts a braces in nick Reply with quote

willyw wrote:

Try this: set nickpro [lindex [split $text] 0]
p.s
The code you posted is missing :
set canal_admin $chan
too.

I tried what you advised me, but it NOT worked.
Quote:
<oper> !notiadd {test}
<bot> test has been added to the list of banned nicks.


The code continues regardless nick braces. Confused

EDIT: I fixed!
Code:
set nickpro [lindex [split $arg { }] 0]


Thanks willyw Very Happy
_________________
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks Smile
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