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.

socket, client compatiblity problem

Help for those learning Tcl or writing their own scripts.
Post Reply
n
nANDu
Voice
Posts: 15
Joined: Sun May 22, 2005 1:05 am

socket, client compatiblity problem

Post by nANDu »

CricInfo.LO.UK.StarLink.Org is a CricInfo's IRC server. Idea is to get the commentry frm #cricinfo channel and relay it to bots original network/channel.

Code: Select all

proc cricket {} {
	set nick "nANDu[rand 99]" 
	set sock [socket cricinfo.lo.uk.starlink.org 6667]
   puts $sock "NICK $nick" 
	puts $sock "USER nANDu . . Kishyy"
	flush $sock
	while {[lindex [split [gets $sock] :] 1] == "End of /MOTD command." } {
		 puts $sock "JOIN #cricinfo"
		 flush $sock
	}
   gets $sock line
	set reply [lindex [split $line :] 1]
	puts $sock "PONG :$reply"
   if {[lindex [split $line] 1] == "PING"} {puts $sock "PONG :$reply"}
	set lines "$line\n"
   putlog "$lines"
}
:CricInfo.LO.UK.StarLink.Org 513 nANDu37 :Your client may not be compatible with this server.
-
Not able to proceed after that...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

that must be the dumbest error message ever issued by an IRC server

the IRC server <-> client communication is asynchronous, i.e. you need to handle it with non-blocking, event-driven socket (either use Tcl's mechanism for that - [fconfigure] and [fileevent], or use eggdrop's built-in mechanism via [connect] and [control])

search the forum on the subject, there are plenty of topics elaborating on it; or/and see my script spambuster which, among many other things, does what you need to do - connects a client to IRC server
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
n
nANDu
Voice
Posts: 15
Joined: Sun May 22, 2005 1:05 am

Post by nANDu »

Hi Demond,

Thanks for the suggestion, I tried the same with [fconfigure] & [fileevent] .. i still get the same error. Nevermind i know i din understand/use them properly :/

Your spambuster was a great help, i succeeded the same with [control] & [connect]. But, i need a lil help checking a proc every minute or 5, to make sure that the socket is connected. Below is what i tried (from ur spambuster's help) :-

Code: Select all

bind time - "?0 % % % %"	cricinfo
proc cricinfo {min hr mn d yr} {
	global chanlinkidx username realname nick
	if {![info exists chanlinkidx]} {
		if {![valididx $chanlinkidx]} {
			control [set chanlinkidx [connect CricInfo.LO.UK.StarLink.Org 6667]] cric:cntrl
			putdcc $chanlinkidx USER $username 0 0 :$realname
			putdcc $chanlinkidx NICK $nick[rand 1000]
		}
	}
}
Problem:
1) Even if i kill the above $chanlinkidx, it never restarts it.
2) By trial & error i get the proc cricinfo restart. But, i get an error no such variable chanlinkidx
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

async comm means you must output to server's socket only in your control proc, responding to server's input

telnet to your server on its IRC port and see what exactly it sends you; my guess is it needs you to reply on PING cookie
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
n
nANDu
Voice
Posts: 15
Joined: Sun May 22, 2005 1:05 am

Post by nANDu »

hi demond, lil help pls


[08/01 17:00:03] <Doub> [03:10] Tcl error [cricinfo]: wrong # args: should be "cricinfo"
[08/01 17:01:34] <Doub> [03:30] #nANDu# set errorInfo
[08/01 17:01:34] <Doub> Currently: wrong # args: should be "cricinfo"
[08/01 17:01:34] <Doub> Currently: while executing
[08/01 17:01:34] <Doub> Currently: "cricinfo $_time1 $_time2 $_time3 $_time4 $_time5"

Code: Select all

bind time - "?0 *"   cricinfo
proc cricinfo {} {
	global chanlinkidx chanlinknick nick username realname 
	if {$chanlinkidx == ""} {
			set serv "CricInfo.LO.UK.StarLink.Org"
			set chanlinkidx [connect $serv 6667]
			control $chanlinkidx linkchan
			putlc "USER $username 0 0 :$realname"
			set chanlinknick $nick[rand 1000]
			putlc "NICK $chanlinknick"
	}
}
.tcl cricinfo frm the dcc works fine
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

nANDu wrote:proc cricinfo {} {
Why did you remove min, h, d, m, and y from the var list? its not optional. A bind to time will always be called with 5 arguments as you do not explicitly change it (like using the special argument "args" or adding addionals arguments to the bind line).
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...
C
CuteBangla
Halfop
Posts: 58
Joined: Mon Feb 27, 2006 10:47 pm
Location: Dhaka, Bangladesh
Contact:

Post by CuteBangla »

so wht is the final code>?
De Kus wrote:
nANDu wrote:proc cricinfo {} {
Why did you remove min, h, d, m, and y from the var list? its not optional. A bind to time will always be called with 5 arguments as you do not explicitly change it (like using the special argument "args" or adding addionals arguments to the bind line).
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Code: Select all

proc cricinfo {minute hour day month year} {
r0t3n @ #r0t3n @ Quakenet
Post Reply