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 

Writing to a TXT
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 7:24 am    Post subject: Writing to a TXT Reply with quote

Hi,

Can somone help me with this script:

If people join the channel #blaat the bot must write the nickname to a .txt , if the people leaves #blaat he must he delete the people's name from the .txt.


Thanks.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 07, 2006 8:12 am    Post subject: Reply with quote

Search the forum for 'write txt', you'll get a lot of usefull topics.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 8:28 am    Post subject: Reply with quote

Ok, i find the write section but not the remove (For removing the line's)
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 07, 2006 8:54 am    Post subject: Reply with quote

Paste what you've written so far and we will help you finish it.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 9:19 am    Post subject: Reply with quote

Code:
bind join - * join_onjoin

proc join_onjoin {nick uhost hand chan} {
set txt [open "online.txt"]
   puts $txt "$nick"
}
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
KrzychuG
Master


Joined: 16 Aug 2003
Posts: 306
Location: Torun, Poland

PostPosted: Sun May 07, 2006 9:47 am    Post subject: Reply with quote

Code:

bind join - * join_onjoin

proc join_onjoin {nick uhost hand chan} {
  set txt [open "online.txt"]
  puts $txt "$nick"
  close $txt ;# it's important to close the file!
}


;P
_________________
Que?
Back to top
View user's profile Send private message Visit poster's website
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 9:49 am    Post subject: Reply with quote

Ok, thanks that is the first part of the script Cool

Now how remove the line if somone parts Mad
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun May 07, 2006 10:26 am    Post subject: Reply with quote

best you save the nicks as a list. and lsearch/lreplace the nick (or lappend in case to add one).
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 10:29 am    Post subject: Reply with quote

Uhm, i cant script TCL... Could you make it for me..
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 07, 2006 11:22 am    Post subject: Reply with quote

Code:
bind time - ?0* savelist
bind join - * addtolist
bind part - * remfromlist
bind sign - * remfromlist

if {![file exists online.txt]} { close [open online.txt w] }
set nicklist [split [read [set oltxt [open online.txt]]] \n][close $oltxt]

proc savelist args {
 set file [open online.txt w]
 foreach n $::nicklist {
  if {$n != ""} { puts $file $n }
 }
 close $file
}

proc addtolist {nick uhost hand chan} {
 global nicklist
 set nick [string tolower $nick]
 if {[lsearch -exact $nicklist $nick] == -1} {
  lappend nicklist $nick
 }
}

proc remfromlist {nick uhost hand chan rsn} {
 global nicklist
 set nick [string tolower $nick]
 if {[set i [lsearch -exact $nicklist $nick]] != -1} {
  set nicklist [lreplace $nicklist $i $i]
 }
}

This will add the nicks on join to the list and will remove the nicks from the list on part/quit. The list will be saved every 10 minutes into the file.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 11:24 am    Post subject: Reply with quote

Sorry, but i need live if somone parts he must write and joins too:$
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 07, 2006 11:26 am    Post subject: Reply with quote

Well, what you're requesting is not recommended. If you want it to save immediately, you know what to fix.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 11:29 am    Post subject: Reply with quote

Why it isnt recommed? BTW is this good without timer?:

Code:
bind join - * addtolist
bind part - * remfromlist
bind sign - * remfromlist

if {![file exists online.txt]} { close [open online.txt w] }
set nicklist [split [read [set oltxt [open online.txt]]] \n][close $oltxt]

proc savelist args {
 set file [open online.txt w]
 foreach n $::nicklist {
  if {$n != ""} { puts $file $n }
 }
 close $file
}

proc addtolist {nick uhost hand chan} {
 global nicklist
 set nick [string tolower $nick]
 if {[lsearch -exact $nicklist $nick] == -1} {
  lappend nicklist $nick
 }
}

proc remfromlist {nick uhost hand chan rsn} {
 global nicklist
 set nick [string tolower $nick]
 if {[set i [lsearch -exact $nicklist $nick]] != -1} {
  set nicklist [lreplace $nicklist $i $i]
 }
}
[/code]
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun May 07, 2006 11:38 am    Post subject: Reply with quote

It's not recommended because it becomes CPU intensive to open and close the file everytime someone joins/parts/quits especially on mass events. Your code is alright, you only need to change these procs:
Code:
proc addtolist {nick uhost hand chan} {
 global nicklist
 set nick [string tolower $nick]
 if {[lsearch -exact $nicklist $nick] == -1} {
  lappend nicklist $nick
  savelist
 }
}

proc remfromlist {nick uhost hand chan rsn} {
 global nicklist
 set nick [string tolower $nick]
 if {[set i [lsearch -exact $nicklist $nick]] != -1} {
  set nicklist [lreplace $nicklist $i $i]
  savelist
 }
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Nivko
Voice


Joined: 15 Nov 2005
Posts: 22
Location: The Netherlands, Helmond

PostPosted: Sun May 07, 2006 11:47 am    Post subject: Reply with quote

So this:

Code:
proc addtolist {nick uhost hand chan} {
 global nicklist
 set nick [string tolower $nick]
 if {[lsearch -exact $nicklist $nick] == -1} {
  lappend nicklist $nick
  savelist
 }
}

proc remfromlist {nick uhost hand chan rsn} {
 global nicklist
 set nick [string tolower $nick]
 if {[set i [lsearch -exact $nicklist $nick]] != -1} {
  set nicklist [lreplace $nicklist $i $i]
  savelist
 }
}
proc savelist args {
 set file [open online.txt w]
 foreach n $::nicklist {
  if {$n != ""} { puts $file $n }
 }
 close $file
}


I gonna this it and else i use your way
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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