Форум: "KOL";
Текущий архив: 2007.02.18;
Скачать: [xml.tar.bz2];
ВнизIRC и KOL Найти похожие ветки
← →
vvedensky (2006-05-19 16:31) [0]Снова всем привет :)
Все-таки поставил я КОЛ мне понравилось, но вот не смог найти нужного компонента для работы с протоколом IRC
Скачал Индии но там не оказалось ирк :(
Есть ли подобные компоненты для КОЛ?
← →
thaddy (2006-05-19 19:30) [1]Yes,
I have written an IRC relay chat client (even a miranda clone, including MSN7) some time ago. MSN7 doesn"t work anymore, but IRC does
I"ll see if I can find the sources.
← →
vvedensky (2006-05-20 08:59) [2]А можно ли где посмотреть?
← →
thaddy (2006-05-20 19:25) [3]Here it is. Very basic. You need one more unit: KolScktComp.pas from bonanzas.rinet.ru
<code.
{
program KolIRC;
uses
Kol, IRC1 in "IRC1.pas";
begin
NewForm1( Form1, nil);
Run(Form1.form);
end.
}
unit IRC1;
// Basic IRC Client by Thaddy from example on
// http://www.Planet-Source-Code.com/
interface
uses
Windows, Kol, KolScktComp;
type
PForm1=^TForm1;
TForm1=object(Tobj)
Form:pControl;
btnConnect,
btnSend,
edtIRCHost,
edtPort,
edtSend,
mmReply,
Pnl1,
Pnl2:Pcontrol;
IRC:PClientSocket;
public
procedure btnConnectClick(sender:PObj);
procedure btnSendClick(sender:PObj);
procedure IRCRead(Sender: PObj;Socket: PCustomWinSocket);
procedure IRCConnect(Sender: PObj;Socket: PCustomWinSocket);
end;
procedure NewForm1( var Result: PForm1; AParent: PControl );
var
Form1:pForm1;
implementation
procedure AdjustWinControlColor(aParent:PControl;const aColor:TColor = clWindow);
var
i:integer;
begin
with aParent^ do
if Boolean(Childcount) then
for i:= 0 to pred(Childcount) do
begin
if (AnsiComparetext(Children[i].subclassname,"obj_EDIT") = 0) or
(AnsiComparetext(Children[i].subclassname,"obj_COMBOBOX") = 0) or
(AnsiComparetext(Children[i].subclassname,"obj_LISTBOX") = 0) then
Children[i].Color:=aColor;
If Children[i].childcount <> 0 then
AdjustWinControlColor(Children[i]);
end;
end;
function Hex(strData:string): string;
var sresult:string; sfinal:string; hexc:cardinal; i:integer;
begin
i:=1;
while i<=length(strData) do
begin
hexc := str2int("$" + copy(strData,i,2));
sresult := int2str(hexc);
sresult := chr(str2int(sresult));
sfinal := sfinal + sresult;
i:=i+2;
end;
result := sfinal
end;
procedure NewForm1( var Result: PForm1; AParent: PControl );
begin
New(Result,Create);
with Result^ do
begin
Form:= NewForm(AParent,"KOL Basic IRC client").SetSize(600,400).centeronparent.Tabulate;
Applet:=Form;
Form.Font.ReleaseHandle;
Form.Font.AssignHandle(GetStockObject(DEFAULT_GUI_FONT));
Form.Add2AutoFree(Result);
Pnl1:=Newpanel(form,esNone).Setalign(caTop);
btnConnect:=NewButton(Pnl1,"Connect");
edtIRCHost:=NewEditBox(Pnl1,[]).PlaceRight;
MsgOk(edtIRCHost.SubClassName);
edtIRCHost.Text := "irc.dal.net";
edtIRCHost.Width :=170;
edtPort:=NewEditBox(Pnl1,[]).PlaceRight.ResizeParent;
edtPort.Width := 80;
edtPort.Text := "6667";
Pnl2:=Newpanel(form,esNone).Setalign(caBottom);
mmReply:=NewEditBox(form,[eoMultiline]).SetAlign(caClient);
btnSend:=NewButton(Pnl2,"Send Command").AutoSize(True).ResizeParent;
edtSend:=NewEditBox(Pnl2,[]).PlaceRight;
edtSend.Width :=400;
AdjustWinControlColor(Applet);
IRC :=NewClientSocket;
IRC.ClientType :=ctNonBlocking;
IRC.OnConnect:=IRCConnect;
IRC.OnRead := IRCRead;
btnConnect.OnClick:=btnConnectClick;
btnSend.OnClick:=btnSendClick;
Form.Add2AutoFree(IRC);
end;
end;
procedure TForm1.IRCRead(Sender: PObj;
Socket: PCustomWinSocket);
var
ipacket:string; idata:string;
begin
idata:=IRC.Socket.ReceiveText;
mmReply.Text:=mmReply.text + idata;
if pos("PING",idata) <> 0 then
begin
IRC.Socket.SendText("PONG :" + copy(idata,pos(":",idata) + 1,length(idata) - pos(":",idata)) + hex("0A"));
mmReply.Text:=mmReply.Text+"OUT: " + "PONG :" + copy(idata,pos(":",idata) + 1,length(idata) - pos(":",idata)) + hex("0A");
end;
mmReply.SelLength := length(mmReply.Text);
mmReply.SelStart := length(mmReply.Text);
end;
procedure TForm1.IRCConnect(Sender: PObj;Socket: PCustomWinSocket);
begin
IRC.Socket.SendText("NICK Delphi-TestUser" + hex("0A"));
IRC.Socket.SendText("USER Delphi "" + IRC.Socket.LocalAddress + "" "" + IRC.Socket.RemoteHost + "" :Delphi Test" + hex("0A"));
end;
procedure TForm1.btnConnectClick(sender: PObj);
begin
IRC.Host:=edtIRCHost.text;
IRC.Port:=str2int(edtPort.Text);
IRC.active:=true;
end;
procedure TForm1.btnSendClick(sender: PObj);
begin
// The two commands that are most useful
with IRC.Socket^ do
begin
if lowercase(copy(edtSend.Text,1,5)) = "/join" then
begin
sendtext("JOIN " + copy(edtSend.text,6,length(edtSend.Text) - 5) + hex("0A"));
mmReply.text:=mmReply.Text + "OUT: JOIN " + copy(edtSend.text,6,length(edtSend.Text) - 5) + #13 + #10;
end
else if lowercase(copy(edtSend.Text,1,4)) = "/msg" then
begin
sendtext("PRIVMSG " + copy(edtSend.text,5,length(edtSend.Text) - 4) + hex("0A"));
mmReply.text:=mmReply.Text + "OUT: PRIVMSG " + copy(edtSend.text,6,length(edtSend.Text) - 4) + #13 + #10;
end
else
begin
sendtext(edtSend.Text + hex("0A"));
mmReply.Text:=mmReply.Text + "OUT: " + edtSend.Text + #13 + #10;
end;
end;
mmReply.SelLength := length(mmReply.Text);
mmReply.SelStart := length(mmReply.Text);
end;
end.
← →
vvedensky (2006-05-20 20:19) [4]Огромное спасибо буду пробовать :)
Страницы: 1 вся ветка
Форум: "KOL";
Текущий архив: 2007.02.18;
Скачать: [xml.tar.bz2];
Память: 0.47 MB
Время: 0.042 c