TimeSurfer Newbie
Joined: 01 Aug 2002 Posts: 12
|
Posted: Thu Jun 08, 2006 6:53 pm Post subject: IRC CODE EXAMPLE PROBLEM |
|
|
| Code: |
option decimalsep,.
external vdsinet.dll,Public Freeware Key|90257236
#define command, net
#define function, net
#define command, win
#define function, win
inifile open,.\@name(%0).ini
%%server = @iniread(general,server)
%%port = @iniread(general,port)
%%channel = @iniread(general,channel)
%%password = @iniread(general,password)
%%clanid = @iniread(general,clanid)
%%topic1 = Clan-IRC Real Time Stats
%%topic2 = Clan-IRC Real Time Chat
%a = -2
DIALOG CREATE, Clan-IRC ,-1,0,564,346
DIALOG ADD,EDIT,eChat,44,6,400,242,,MULTI
DIALOG ADD,EDIT,eText,291,6,400,24
DIALOG ADD,BUTTON,bSubmit,292,411,148,24,&Submit,default
DIALOG ADD,BUTTON,bConnect,180,411,148,35,Connect
DIALOG ADD,BUTTON,bDisconnect,215,411,148,35,Disconnect
DIALOG ADD,BUTTON,bSave,145,411,148,35,Save Settings
DIALOG ADD,BUTTON,bModify,145,411,148,35,Modify Settings
DIALOG ADD,BUTTON,bExit,250,411,148,35,E&xit
DIALOG ADD,STATUS,sStatus
DIALOG ADD,EDIT,eServer,20,6,100,19
DIALOG ADD,EDIT,ePort,20,109,35,19
DIALOG ADD,EDIT,ePassword,20,210,60,19,,,PASSWORD
DIALOG ADD,EDIT,eClanID,20,147,60,19,ClanID
DIALOG ADD,TEXT,lServer,6,6,100,13,Server IP Address
DIALOG ADD,TEXT,lPort,6,109,35,13,Port
DIALOG ADD,TEXT,lPassword,4,210,60,13,Password
DIALOG ADD,TEXT,lClanID,6,147,60,13,Clan ID
Gosub Refresh
:Disable
DIALOG Disable,eServer
DIALOG Disable,ePort
DIALOG Disable,ePassword
DIALOG Disable,eClanID
DIALOG Hide,bSave
DIALOG SHOW
goto SetData
:SetData
%%server = @dlgtext(eServer)
%%port = @dlgtext(ePort)
%%channel1 = #%%clanid-RTS
%%channel2 = #%%clanid-RTC
%%password = @dlgtext(ePassword)
%%name = RT-Bot
%%clanid = @dlgtext(eClanID)
gosub Refresh
goto evloop
:bConnectButton
if @not(@trim(%%server))
Warn Please enter the server's IP address
%a = -1
Goto evloop
end
if @not(@trim(%%port))
Warn Please enter the server port
%a = -1
Goto evloop
end
if @not(@trim(%%password))
Warn Please enter channel password,,PASSWORD
%a = -1
Goto evloop
end
if @not(%%clanid)
Warn Please enter the Clan ID
%a = -1
Goto evloop
end
DIALOG Disable,bConnect
DIALOG Disable,bModify
DIALOG Show
net socket,auto
net socket,vdsevents
net socket,addr,@trim(%%server)
net socket,port,@trim(%%port)
net socket,client
list create,1
list create,2
%a = 0
:evloop
%e = @event()
if %E
goto %E
end
%e = @net(socket,event)
if %E
goto %E
end
wait "0.2"
end
if @EQUAL(%a,-1)
goto evloop
end
%a = @FADD(%a,1)
if @GREATER(%a,25)
gosub bJoinbutton
end
goto evloop
:bSubmitButton
%%data = @dlgtext(eText)
%%char = " "
gosub split
if @equal(@substr(%%command,1,1),/)
%%command = @strdel(%%command,1,1)
%%text = %%command %%params
gosub send
else
%%text = * %%channel2 :%%params
gosub send
end
dialog set,eText
goto evloop
:connect
%%text = USER %%name @chr(34)Clan-IRC@chr(34) @chr(34)@net(socket,addr)@chr(34) :%%name@cr()@chr(10)NICK %%name
gosub send
%a = 0
goto evloop
:bJoinButton
%%text = join %%Channel1
gosub send
%%text = join %%Channel2
gosub send
%%text = mode %%Channel1 +mntk %%password
gosub send
%%text = mode %%Channel2 +mntk %%password
gosub send
%%text = topic %%Channel1 %%topic1
gosub send
%%text = topic %%Channel2 %%topic2
gosub send
%a = -1
end
:network
%%buffer = %%buffer@net(socket,data)
if @not(@zero(@pos(@cr(),%%buffer)))
repeat
%%data = @substr(%%buffer,1,@pred(@pos(@cr(),%%buffer)))
%%buffer = @strdel(%%buffer,1,@succ(@pos(@cr(),%%buffer)))
%%char = " "
gosub split
if @equal(%%command,PING)
%%text = PONG %%params
gosub send
else
list clear,1
list assign,1,@dlgtext(eChat)
list clear,2
list assign,2,%%command %%params
dialog set,eChat,@text(1)@text(2)
end
until @zero(@pos(@cr(),%%buffer))
end
%P = @LEN(@DLGTEXT(eChat))
%P = @sendmsg(@win(~eChat),$0B1,@FSUB(%P,1),%P)
%P = @sendmsg(@win(~eChat),$0B7,0,0)
DIALOG FOCUS,eText
goto evloop
:bExitButton
end
:send
net socket,sendserver,%%text@cr()@chr(10)
list clear,1
list assign,1,@dlgtext(eChat)
list clear,2
list assign,2,%%text
dialog set,eChat,@text(1)@text(2)
exit
:split
if @zero(@pos(%%char,%%data))
%%command = %%data
%%params =
else
%%command = @substr(%%data,1,@pred(@pos(%%char,%%data)))
%%params = @substr(%%data,@succ(@pos(%%char,%%data)),@len(%%data))
end
exit
:closec
list clear,1
list assign,1,@dlgtext(eChat)
list clear,2
list assign,2,Connection closed
dialog set,eChat,@text(1)@text(2)
goto evloop
:error
warn Fatal error: @net(socket,error)
:bModifyButton
DIALOG Enable,eServer
DIALOG Enable,ePort
DIALOG Enable,ePassword
DIALOG Enable,eClanID
DIALOG Disable,bModify
DIALOG Hide,bModify
DIALOG Show,bSave
DIALOG Disable,bConnect
DIALOG SHOW
goto evloop
:bDisconnectButton
%%text = ??????????
gosub send
goto disable
:bSaveButton
DIALOG Hide,bSave
DIALOG Show,bModify
DIALOG Enable,bModify
DIALOG Enable,bConnect
goto Disable
end
:Refresh
DIALOG SET,eServer,%%Server
DIALOG SET,ePort,%%Port
DIALOG SET,ePassword,%%Password
DIALOG SET,eClanID,%%ClanID
DIALOG SHOW
inifile write,general,server,@trim(%%server)
inifile write,general,port,@trim(%%port)
inifile write,general,password,@trim(%%password)
inifile write,general,clanid,%%clanid
exit
end
:close
if @Not(list close,1)
end
if @Not(list close,2)
end
exit
|
Problem im having with this code is...
%e = @net(socket,event)
i keep getting invalid command or function for some reason (ive added the defines and still same thing
I think tommy originally made this example code.
Im using vds5[/code] _________________ T-i-m-e-S-u-r-f-e-r |
|