This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

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

Help for those learning Tcl or writing their own scripts.
Post Reply
b
bierbong
Voice
Posts: 7
Joined: Thu May 21, 2009 12:40 pm

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

Post by bierbong »

hello,
i have a *.txt with some lines of text. i want to parse it to a certain channel. i realized it with:

Code: Select all

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?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

# 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"
Last edited by Sir_Fz on Mon Jul 06, 2009 4:09 pm, edited 1 time in total.
b
bierbong
Voice
Posts: 7
Joined: Thu May 21, 2009 12:40 pm

Post by bierbong »

thx!!!
b
bierbong
Voice
Posts: 7
Joined: Thu May 21, 2009 12:40 pm

Post by bierbong »

it is still very slow ( every 2 seconds -> 1 line ). anybody knows why?
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

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: Select all

 putserv "privmsg #channel :$line"
with

Code: Select all

 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)
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Try putquick instead of putserv, otherwise using same syntax.
I must have had nothing to do
b
bierbong
Voice
Posts: 7
Joined: Thu May 21, 2009 12:40 pm

Post by bierbong »

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

//edit: i think, it is my eggdrop :(
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

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

Code: Select all

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
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

You should be able to bypass flood protection using:

Code: Select all

putdccraw 0 <size_of_msg> <msg>\n

Code: Select all

proc putflood {arg} {
  putdccraw 0 [expr [string bytelength $arg] + 1] $arg\n
} 
or using the above

Code: Select all

putflood "string"
XplaiN but think of me as stupid
Post Reply