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.

Speedup of printout

Old posts that have not been replied to for several years.
Locked
M
M0dj0

Speedup of printout

Post by M0dj0 »

I have done a C module that gathers and holds information about the top 10 clans of a ranking ladder at www.clanbase.com.

When a user types a trigger, e.g. !cbtop10, in the bot channel the user gets a print out that looks like this. Through PRIVMSG ...

[09:52:44] <SFL|Intel> Here are the top10 ranked clans in ladder CounterStrike 5vs5 [SWE] @ www.clanbase.com .
[09:52:45] <SFL|Intel> [ Rank ][ Rating ][               Name               ][ Win ][ Loss ][ Draw ][        Comments         ]
[09:52:46] <SFL|Intel> [   1  ][  1907  ][           Clan matrix            ][  45 ][    3 ][    0 ][                         ]
[09:52:48] <SFL|Intel> [   2  ][  1674  ][          Gamepoint.swe           ][  35 ][    5 ][    2 ][                         ]
[09:52:50] <SFL|Intel> [   3  ][  1666  ][             A-Laget              ][  70 ][   19 ][    3 ][                         ]
[09:52:52] <SFL|Intel> [   4  ][  1658  ][           clan [znitz]           ][  43 ][   11 ][    0 ][                         ]
[09:52:54] <SFL|Intel> [   5  ][  1591  ][            CosaNostra            ][  30 ][    8 ][    0 ][                         ]
[09:52:56] <SFL|Intel> [   6  ][  1530  ][              Pallar              ][  50 ][   30 ][    4 ][                         ]
[09:52:58] <SFL|Intel> [   7  ][  1508  ][          Feared Gamers           ][  26 ][   12 ][    2 ][                         ]
[09:53:00] <SFL|Intel> [   8  ][  1493  ][             HiGhland             ][  28 ][    8 ][    1 ][                         ]
[09:53:02] <SFL|Intel> [   9  ][  1485  ][            de saliga             ][  19 ][    0 ][    0 ][                         ]
[09:53:04] <SFL|Intel> [  10  ][  1482  ][               SUMO               ][  12 ][    5 ][    1 ][                         ]
[09:53:06] <SFL|Intel> For the complete ladder goto : http://www.clanbase.com/rating.php?lid=220 .

In the example the swedish Counter-Strike ladder 5vs5 is used.

In the code I send the PRIVMSG's to DP_SERVER at the moment, and as you can se from the example the print out is fairly fast in the beginning, but decreasing to one message every two seconds. If I instead send the PRIVMSG's to DP_HELP as described in the MODULES doc, the time between two PRIVMSG's is 2 seconds.

Now, is there any way to speed up the print out ?

// M0dj0
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Yes and no.

You could directly print out to the server, totaly bypassing the queues alltogether, but flooding the bot off.

The reason for the change in soeed of messages, is due to penalty calculation.

Some IRC servers use this, to detect the differance between a flood and a lot of text.

In eggdrop, it makes sure that the server knows the differance, by using slow output. At the same time, it presents a nice feature, where other servers flood protection, is usualy prevented from triggering.

Each message sent to the server, has a penalty value.

When the server queues start sending messages, they increase the panalty value, by the amount that command would present. Once a second, the value is decreased by 1.

Thus, when eggdrop reaches a certain penalty limit, it will slow down it's output. Once the secondly deduction reaches a lower value, it will start sending faster again.

These limits are there to protect you.

As noted above, you can bypass the server queues and go directly to the server. Using a secondly timer, and your own small queue system, you can use this method to output a message every second.

This is highly prone to flooding.

To see the method used to print directly tot he server, see the function, dedicated to the putdccraw command (I think thats the name).
M
M0dj0

Post by M0dj0 »

Ok, I guessed it might have something todo with the IRC servers ... thanx for the information.

I think I'll stick to the "nice" method for now, it is slow but if there is a nice soloution of the other problem I described in the thread about "parallellism" it should work and the risk of flooding off the bot is kept low.

// M0dj0
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It's not the IRC servers doing this, it is eggdrop.

However, it is doing it to prvent the IRC server killing it's connection for flooding.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

This proposal of opening a dcc connection sounds interresting.

stdragon: You can find an example of the data in my module in the thread "Speedup of printout".

stdragon, egghead: I would be very greatfull if it would be possible for You to help me with just and example of how to establish a dcc connection with the client. Please post it in the thread "Speedup of printout", since thats the most appropriate one for this matter.

// M0dj0
An example TCL script can be found at http://members.fortunecity.com/eggheadtcl/menu.tcl.txt

The important part send by the bot to the client is:

Code: Select all

putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $menuport\001" 
That statement contains the IP in long number format and the port the client should connect to. The client then may connect to the specified port on the specified ip.
As soon as that connection is established, you then can dump out the information and immediately close the connection.
S
Squirre1
Voice
Posts: 14
Joined: Thu Jul 18, 2002 12:49 am

Post by Squirre1 »

How can this code be modified to accept a variable after the menu selection? Specifically number 2.. I want a user to be able to type in a variable after there selection so we can use that to query the database...

Currently when ever I try I get:
2 Squirre1 is not possible, try again

Also, I get this in my log:
[11:16] <BotName> [11:18] Telnet connection: connection.from.user.net/2032
[11:16] <BotName> [11:19] Timeout/EOF ident connection

Is there any way to speed up the above because that is like a 10-20 second pause and I would like the users to get the menu instantly after the dcc session is made..

TIA

Code: Select all

load d:/pathto/fbsql.dll
set menuport 47000

#---------------------------------------------------------------------
# handle public !menu request: initialize DCC CHAT...
#---------------------------------------------------------------------

bind msg -|- !regmenu pubmenu

proc pubmenu {nick uhost hand chan} {
  global menuport
  putlog "Request for menu by $nick (aka $hand)"
  putserv "PRIVMSG $nick :\001DCC CHAT chat 11111111111 $menuport\001"  
}

listen $menuport script presentmenu

proc presentmenu { idx } {
   # upon a successfull connection:
   # present the menu...
   menuchoice $idx
   # ... and control to waitchoice
   control $idx waitchoice
}

proc menuchoice { idx } {
   putdcc $idx ""
   putdcc $idx "Type the option number you wish to select and hit ENTER:"
   putdcc $idx "1. List Current Registrants"
   putdcc $idx "2. List a Individual Status (Type "2 <username>")
}

#---------------------------------------------------------------------
# proc waitchoice is triggered if the user types something...
# the proc returns either 0 or 1
# return 0: user input is sent to the procedure again
# return 1: control is returned to the bot (will close connection)
#---------------------------------------------------------------------

proc waitchoice { idx choice args} {
   global botnick server
   switch -- $choice {
      1 { reglist $idx }
      2 { regstat $idx $args }
      EXIT { return 1 }
      exit { return 1 }
      "" { return 1 ; # connection terminated by client }
      default { putidx $idx "$choice is not possible, try again" }
   }
   # present the menu again...
   menuchoice $idx
   # ... and leave control here
   return 0
}

proc reglist { idx } {
  set text ""
  set regcount 0
  sql1 connect 192.168.1.1 username password
  sql1 selectdb vbulletin
  sql2 connect 192.168.1.1 username password
  sql2 selectdb vbulletin
  sql1 startquery "SELECT userid,field6,field7,field15,field21,field28 from userfield where field10='Registered' ORDER BY field15 DESC, field23 ASC" -array registrant
  while {[sql1 fetchrow] != ""} {
    sql2 startquery "SELECT username from user where userid='$registrant(userid)'" -array userinfo
    sql2 fetchrow
    if { $registrant(field15) == "3PAID"} {set paystat "3,0PAID"}
    if { $registrant(field15) == "2PENDING"} {set paystat "8,0PENDING"}
    if { $registrant(field15) == "1REJECT"} {set paystat "4,0Contact test@test.org"}
    if { $registrant(field15) == ""} {set paystat "4,0Not Pre-Paid"}
    incr regcount
    putdcc $idx "$regcount. 1,0$registrant(field6) $registrant(field7) - Nick: 12,0$userinfo(username) 1,0- PayStatus: $paystat\r\n"
    sql2 endquery
  }
  sql2 disconnect
  sql1 endquery
  sql1 disconnect
}

proc regstat { idx args } {
  set text ""
  set attendee [lindex $args 0]
  sql1 connect 192.168.1.1 username password
  sql1 selectdb vbulletin
  sql2 connect 192.168.1.1 username password
  sql2 selectdb vbulletin
  sql1 startquery "SELECT userid from user where username='$attendee'" -array registrant
  while {[sql1 fetchrow] != ""} {
    sql2 startquery "SELECT field6,field7,field15,field21,field28 from user where userid='$registrant(userid)'" -array userinfo
    sql2 fetchrow
    if { $userinfo(field15) == "3PAID"} {set paystat "3,0PAID"}
    if { $userinfo(field15) == "2PENDING"} {set paystat "8,0PENDING"}
    if { $userinfo(field15) == "1REJECT"} {set paystat "4,0Contact test@test.org"}
    if { $userinfo(field15) == ""} {set paystat "4,0Not Pre-Paid"}
    putdcc $idx "1,0$userinfo(field6) $userinfo(field7) - Nick: 12,0$attendee 1,0- PayStatus: $paystat\r\n"
    sql2 endquery
  }
  sql2 disconnect
  sql1 endquery
  sql1 disconnect
}

putlog "Menu version 0 loaded: DCC connections on port $menuport."
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Squirre1 wrote:Is there any way to speed up the above because that is like a 10-20 second pause and I would like the users to get the menu instantly after the dcc session is made..
What's your current ident-timeout?

...posting in the wrong forum again, are we?
Procs triggered by a connection put under 'control' are called with two arguments, the first is the idx of the connection, the second is the entire line of user input, OR "" if the user disconnected.
S
Squirre1
Voice
Posts: 14
Joined: Thu Jul 18, 2002 12:49 am

Post by Squirre1 »

well the ident-timeout is set to 2, but it is in relation with this script and this script was associated with this thread by a previous post.. This is jsut an expansion of that script...
Procs triggered by a connection put under 'control' are called with two arguments, the first is the idx of the connection, the second is the entire line of user input, OR "" if the user disconnected.
Ok then where is the script not working aka "me jacking it up" because if I put in "2 Username" and hit enter.. I get back "2 Username is not possible, try again"
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Here: proc waitchoice { idx choice args} {

The 'args' argument serves no purpose. Everything you type is passed as a single string and end up in 'choice', so in order to make this work the way you want to you better 'split' the string and use lindex to access the words or what ever suits you best.
S
Squirre1
Voice
Posts: 14
Joined: Thu Jul 18, 2002 12:49 am

Post by Squirre1 »

This was the miracle line....

set args [lrange $choice 1 end] ; set choice [lindex $choice 0]
a
abe2000

Post by abe2000 »

ppslim wrote:You could directly print out to the server, totaly bypassing the queues alltogether, but flooding the bot off.
How? mine wont flood off because it's opered.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

For scripts, use the undocumented pudccraw command.

This uses the format
putdccraw <idx> <length> <data>
To send to the IRC server, sue a IDX of 0.

This command allows for embeded NULLs, so a length is required.
a
abe2000

Post by abe2000 »

Thanks, it took a while before I understood I needed a \015 at the end to empty the buffer, but now it works great. :)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

OOPS - yup.

It isn't the buffer that needs emptying.

IRC works on a command termination using a newline. As such, \n needs to be sent
Locked