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.

Opening a DCC...

Old posts that have not been replied to for several years.
Locked
K
Kingster

Opening a DCC...

Post by Kingster »

I must be missing something somewhere... I have been looking at all the threads in here that talk about opening a dcc chat, but I just don't freaking get it.

Basically, I am still tweaking my qstat code... and I want to give the user the option to have the results sent by dcc (thereby being faster).

Here is the current code that just uses the standard putserv...

Code: Select all

pub:qstat_results {nick pf} {
  set output_list ""
  while {[gets $pf line] >= 0} {
    lappend output_list $line
  }
    if {[string match "DOWN*" [lindex $output_list 0]]} {
      putserv "PRIVMSG $nick :Connection refused while querying server"
      break
    } elseif {[string match "HOSTNOTFOUND*" [lindex $output_list 0]]} {
      putserv "PRIVMSG $nick :Host not found"
      break
    } elseif {[string match "TIMEOUT*" [lindex $output_list 0]]} {
      putserv "PRIVMSG $nick :Timeout while querying server"
      break
    } else {
      foreach output_line $output_list {
        if {[string index $output_line 1]==0} {
          putserv "PRIVMSG $nick :\00304,0 $output_line"
        } elseif {[string index $output_line 1]==1} {
          putserv "PRIVMSG $nick :\00302,0 $output_line"
        } else {
          putserv "PRIVMSG $nick :\00301,0 $output_line"
        }
      }
    }
  }
How do I make the bot initiate the DCC to the user (rather than have the user initiate)? Once how do I make the bot realize that the chat has been accepted and then dump the results?

Thanks for the help!
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Find a script that makes its own dcc connections, like an fserve. Then borrow the code.
s
spyda
Halfop
Posts: 64
Joined: Mon Aug 12, 2002 2:22 am
Location: Australia

Try This

Post by spyda »

Code: Select all

set asus(port) "8000"

bind MSG - dcc_chat asus_dcc

proc asus_dcc {nick uhost hand vasus} {
  global asus botnick
  ## Do all ya check stuff here##
  ## ![validuser $hand] ##
  putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $asus(port)\001"
}

listen $asus(port) script asus_catch

proc asus_catch {idx} {
  asus_dcc_window $idx
  control $idx asus_dcc_catch
}

proc asus_dcc_window {idx} {
  global botnick
  putdcc $idx "Welcome to $botnick Dcc CHAT."
  putdcc $idx "All my msgs will be sent in here, so plz keep this window  open while using my services"
  putdcc $idx "At any time write /002.help/002 for any help.
}

proc asus_dcc_catch {idx dcc_catch} {
  global botnick
  if {[string [split $asus_catch] 0] == ".help"} {
   putdcc $idx " $botnick HELP"
   putdcc $idx " etc etc...."
 }
}
I had a script that I wrote for about the same perpose. So with some changes, I hope that helps you out!

It is not tested. But it looks right. So if I get time in the next 3 days (I wont be online for about a week I think, if I get this new Job!) I will test to make sure that it works and post the bug fix....

LOL :D . I looked over it for the last time quickly and I missed the last } in asus_dcc_catch. But I think that is it.

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

Post by ppslim »

I would recomend setting up the litening port before sending the CTCP message. What if the port is allready in use?

Another method is to use port number 0. Apparently, you can use this to get aggrop to find a port for you, and this port number is used as the retrun value.
K
Kingster

Post by Kingster »

Alright... Finally had the time to sit back down and work on this... I have it mostly working... the only thing that I run into is if 2 or more people try to get server status at the same time, it sends the output requested by the first user to the last person that requested it.

How can I lock it until it is finished sending to one person? I'm not worried about it keeping the chat open, as I only want it to open the dcc, send the status requested, and kill it. Any thoughts?

Code: Select all

# Configuration settings:

# Public trigger
set tr "!"

# Flags needed to use the commands
set qstat_flag "-|-"

# Path to qstat folder containing qstat stuff/scripts and the qstat program
set pathqstat "/home/ircadmin/MonkBOT/qstat"

# Channels you _dont_ want the bot to reply to public triggers on (seperate with spaces):
set nopub ""

#Set default DCC port for the DCC Chat transfers
set qstatport "48000"

listen $qstatport script qstat_dcc_post

bind pub $qstat_flag ${tr}dservers pub:dservers
bind pub $qstat_flag ${tr}dserver1 pub:dserver1
.
.
.
bind pub $qstat_flag ${tr}dserver7 pub:dserver7


proc qstat:check_input {text} {
  regsub -all {<|>|&|\|/|%|[|]|[$]} $text "" text
  return $text
}

proc pub:dservers {nick host hand chan arg} {
  global pathqstat tr nopub stat
  if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
  set stat [open "|$pathqstat/qstat -cfg $pathqstat/qstat.cfg -f $pathqstat/servers.lst -sort l -Ts $pathqstat/servermini.qstat" r]
  pub:dqstat_results $nick
}


proc pub:dserver1 {nick host hand chan arg} {
  global pathqstat tr nopub stat
  if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
  set stat [open "|$pathqstat/qstat -cfg $pathqstat/qstat.cfg -uns 204.149.41.5 -sort TF -P -Ts $pathqstat/serverfull.qstat -Tp $pathqstat/players.qstat" r]
  pub:dqstat_results $nick
}
.
.
.
proc pub:dserver7 {nick host hand chan arg} {
  global pathqstat tr nopub stat
  if {[lsearch -exact $nopub [string tolower $chan]] >= 0} {return 0}
  set stat [open "|$pathqstat/qstat -cfg $pathqstat/qstat.cfg -ut2s 64.246.32.42 -sort TF -P -Ts $pathqstat/serverfull.qstat -Tp $pathqstat/players.qstat" r]
  pub:dqstat_results $nick
}

proc pub:dqstat_results {nick} {
  global bot botnick qstatport
  putserv "PRIVMSG $nick :\001DCC CHAT chat [myip] $qstatport\001"
}

proc qstat_dcc_post {idx} {
global stat
putlog "Posting qstat results to $idx"
set output_list ""
  while {[gets $stat line] >= 0} {
    lappend output_list $line
  }
    if {[string match "DOWN*" [lindex $output_list 0]]} {
      putdcc $idx "Connection refused while querying server"
      break
    } elseif {[string match "HOSTNOTFOUND*" [lindex $output_list 0]]} {
      putdcc $idx "Host not found"
      break
    } elseif {[string match "TIMEOUT*" [lindex $output_list 0]]} {
      putdcc $idx "Timeout while querying server"
      break
    } else {
      foreach output_line $output_list {
        if {[string index $output_line 0]==0} {
          set str [format "%2s | %5s | %6s | %20s" [lindex $output_line 0] [lindex $output_line 1] [lindex $output_line 2] [lindex $output_line 3]]
          putdcc $idx "\00304 $str"
        } elseif {[string index $output_line 0]==1} {
          set str [format "%2s | %5s | %6s | %20s" [lindex $output_line 0] [lindex $output_line 1] [lindex $output_line 2] [lindex $output_line 3]]
          putdcc $idx "\00302 $str"
        } elseif {[string index $output_line 0]==2} {
          set str [format "%2s | %5s | %6s | %20s" [lindex $output_line 0] [lindex $output_line 1] [lindex $output_line 2] [lindex $output_line 3]]
          putdcc $idx "\00307 $str -- Spectator"
        } else {
          putdcc $idx "$output_line"
        }
      set str ""
      }
    killdcc $idx
    set stat ""
    }
  putlog "Post of info to $idx finished"
  }

putlog "dqstat.tcl DCC of QSTAT results script loaded"
K
Kingster

Post by Kingster »

No one? Come on... Please? :)
Locked