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 

how to cache a text-file and write it out to a channel?

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


Joined: 21 May 2009
Posts: 7

PostPosted: Mon Jun 29, 2009 2:07 am    Post subject: how to cache a text-file and write it out to a channel? Reply with quote

hello,
i have a *.txt with some lines of text. i want to parse it to a certain channel. i realized it with:
Code:
set fs [open "$file2" r]
while {![eof $fs]} {
gets $fs line
if {$line == "" } {
} else {
putserv "PRIVMSG #xxx :$line";
}
}
close $fs


but it is very slow... is there a way to cache the lines or something?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 29, 2009 3:13 am    Post subject: Reply with quote

Code:
# read file once into a list
set fslines [split [read [set fs [open $file2]]][close $fs] \n]

# elements of the list contain lines from file
foreach line $fslines {
 putserv "privmsg #channel :$line"
}


Edit: Fixed "putserver" to "putserv"
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts


Last edited by Sir_Fz on Mon Jul 06, 2009 4:09 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
bierbong
Voice


Joined: 21 May 2009
Posts: 7

PostPosted: Thu Jul 02, 2009 10:43 am    Post subject: Reply with quote

thx!!!
Back to top
View user's profile Send private message
bierbong
Voice


Joined: 21 May 2009
Posts: 7

PostPosted: Mon Jul 06, 2009 12:54 pm    Post subject: Reply with quote

it is still very slow ( every 2 seconds -> 1 line ). anybody knows why?
Back to top
View user's profile Send private message
raider2k
Op


Joined: 01 Jan 2008
Posts: 140

PostPosted: Mon Jul 06, 2009 1:40 pm    Post subject: Reply with quote

most probably because of the ircds built-in flood protection,
refer to your live operators and/or check out the ircds webpage (if there is one)

you might also want to try replacing (testing purpose only!):

Code:

 putserv "privmsg #channel :$line"


with

Code:

 putlog "privmsg #channel :$line"


and then watch your partyline after rehashing if it comes fast or not.
if it does - its the ircds floodprotection, if it doesnt - code error (which i highly doubt)
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Tue Jul 07, 2009 9:47 am    Post subject: Reply with quote

Try putquick instead of putserv, otherwise using same syntax.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
bierbong
Voice


Joined: 21 May 2009
Posts: 7

PostPosted: Tue Jul 07, 2009 1:39 pm    Post subject: Reply with quote

thx, now its a touch faster.
the first 4 lines are posted very fast, but than the same as above- every 2 seconds one line Sad

//edit: i think, it is my eggdrop Sad
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Tue Jul 07, 2009 3:31 pm    Post subject: Reply with quote

Did you try the suggestion by raider2k ie. using putlog to output to the bot's partyline instead of to IRC. This tells you if it is server lag or server flood protection (if it now outputs to the partyline quickly) or a possible code error (if it still outputs to the partyline slowly).
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jul 07, 2009 3:48 pm    Post subject: Reply with quote

puthelp, putserv, and putquick all use eggdrop's server-queue's with different priorities. All are, however, affected by eggdrop's penalty point estimation - which is used to prevent your eggdrop from flooding off.

Even if you would bypass this queue (using the putdccraw command), the irc server would still throttle your output, and in addition, possibly boot you off the network for flooding.

There are some server-software that might allow trusted clients to circumvent such flood protection. You would probably only find such features in reality in private networks.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Tue Jul 07, 2009 4:15 pm    Post subject: Reply with quote

I just ran a test to confirm what has been said previously

Code:

bind PUB - .flood pFlood

proc pFlood {nick uhost hand chan text} {
    set id [open flood.txt r]
    set data [split [read -nonewline $id] \n]
    close $id
    foreach line $data {
        putquick "PRIVMSG $chan :$line"
    }
    return 0
}


The content of the text file is as follows :-

this is line one
this is line two
this is line three
this is line four
this is line five
this is line six
this is line seven
this is line eight
this is line nine
this is line ten

The first 4 lines are output to the IRC channel pretty much immediately and the remainder every second or two.

As nml375 suggested, this may well improve using putdccraw but I would not wish to try. DALnet is fairly relaxed up to a point, then pretty draconian. I am using my Windrop (same host as my connection) for the testing.

It does beg the question, why would you wish to deliberately output many lines at once? Unless it is your intention to flood. Knowing the likely outcome, this is something that most people would wish to avoid.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Thu Jul 23, 2009 6:32 am    Post subject: Reply with quote

You should be able to bypass flood protection using:

Code:
putdccraw 0 <size_of_msg> <msg>\n


Code:
proc putflood {arg} {
  putdccraw 0 [expr [string bytelength $arg] + 1] $arg\n
}


or using the above

Code:
putflood "string"

_________________
XplaiN but think of me as stupid
Back to top
View user's profile Send private message Visit poster's website
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