unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ToolWin, ComCtrls, StdCtrls, XPMan, ImgList, IdBaseComponent,
IdAntiFreezeBase, IdAntiFreeze, IdComponent, IdTCPConnection,
IdTCPClient, IdIRC, ExtCtrls, Mask, Menus;
type
TForm1 =
class(TForm)
GroupBox1: TGroupBox;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
XPManifest1: TXPManifest;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
GroupBox2: TGroupBox;
ListView1: TListView;
ToolButton6: TToolButton;
ImageList1: TImageList;
GroupBox3: TGroupBox;
ListBox1: TListBox;
GroupBox4: TGroupBox;
ListView2: TListView;
GroupBox5: TGroupBox;
StatusBar1: TStatusBar;
IdAntiFreeze1: TIdAntiFreeze;
IdIRC1: TIdIRC;
Memo1: TMemo;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
PopupMenu1: TPopupMenu;
V1: TMenuItem;
N1: TMenuItem;
Quiz1: TMenuItem;
Antwort1: TMenuItem;
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure IdIRC1Notice(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel; Content:
String);
procedure IdIRC1Raw(Sender: TObject; AUser: TIdIRCUser; ACommand,
AContent:
String;
var Suppress: Boolean);
procedure IdIRC1UserMode(Sender: TObject; AModes:
String);
procedure IdIRC1Message(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel; Content:
String);
procedure IdIRC1Quit(Sender: TObject; AUser: TIdIRCUser);
procedure IdIRC1Part(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel);
procedure IdIRC1Parted(Sender: TObject; AChannel: TIdIRCChannel);
procedure IdIRC1Join(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel);
procedure ToolButton4Click(Sender: TObject);
procedure IdIRC1Kick(Sender: TObject; AUser, AVictim: TIdIRCUser;
AChannel: TIdIRCChannel);
procedure IdIRC1Kicked(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel);
function GetLevel(nick:
string):
string;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
benutzer: TStringList;
implementation
uses Unit3, Unit2;
{$R *.dfm}
function GetLevel(nick:
string):
string;
var
i: integer;
match: boolean;
nilist, lilist:
string;
begin
match := false;
for i := 0
to Form3.Memo1.Lines.Count-1
do
begin
nilist := Copy(Form3.Memo1.Lines.Strings[i], 1, Pos('
:', Form3.Memo1.Lines.Strings[i])-1);
lilist := Copy(Form3.Memo1.Lines.Strings[i], Pos('
:', Form3.Memo1.Lines.Strings[i])+1, length(Form3.Memo1.Lines.Strings[i]));
if nick = nilist
then
begin
Result := nick + #9 + '
[' + lilist + '
]';
match := true;
break;
end;
end;
if match = false
then
begin
Result := nick + #9 + '
[0]';
end;
end;
procedure TForm1.ToolButton6Click(Sender: TObject);
begin
Form3.ShowModal;
end;
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
if ToolButton1.Hint = '
Verbinden'
then
begin
ToolButton1.Hint := '
Trennen';
ToolButton1.ImageIndex := 2;
idIRC1.Connect;
end
else
begin
ToolButton1.Hint := '
Verbinden';
ToolButton1.ImageIndex := 0;
idIRC1.Disconnect;
end;
end;
procedure TForm1.IdIRC1Notice(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel; Content:
String);
begin
if auser.Nick = '
NickServ'
then
begin
if Content = '
If you do not change within one minute, I will change your nick.'
then
begin
idirc1.Say('
NickServ', '
identify ...');
end;
if Content = '
NickServ Your nick isn''
t registered.'
then
begin
idirc1.Say('
NickServ', '
register ... ism' + IntToStr(Random(999999)));
idirc1.Say('
NickServ', '
link ism ...');
idirc1.Join('
#night');
end;
if Content = '
Password accepted - you are now recognized.'
then
begin
idirc1.Join('
#night');
end;
end;
end;
procedure GetNicks(AUser: TIdIRCUser; ACommand, AContent:
string);
begin
Delete(AContent, 1, Pos('
:', AContent));
benutzer := TStringList.Create;
while Pos('
', AContent) > 0
do
begin
case AContent[1]
of
'
*' : Delete(AContent, 1, 1);
'
!' : Delete(AContent, 1, 1);
'
@' : Delete(AContent, 1, 1);
'
%' : Delete(AContent, 1, 1);
'
+' : Delete(AContent, 1, 1);
end;
benutzer.Sorted := true;
benutzer.Add(Copy(AContent, 1, Pos('
', AContent)-1));
Delete(AContent, 1, Pos('
', AContent));
end;
end;
procedure EndOfNicks(AUser: TIdIRCUser; ACommand, AContent:
string);
var
i: integer;
begin
for i := 0
to benutzer.Count-1
do
Form1.ListBox1.Items.Add(GetLevel(benutzer.Strings[i]));
benutzer.free;
end;
procedure TForm1.IdIRC1Raw(Sender: TObject; AUser: TIdIRCUser; ACommand,
AContent:
String;
var Suppress: Boolean);
begin
if ACommand = '
353'
then GetNicks(AUser, ACommand, AContent);
if ACommand = '
366'
then EndOfNicks(AUser, ACommand, AContent);
end;
procedure TForm1.IdIRC1UserMode(Sender: TObject; AModes:
String);
begin
idIRC1.Say('
NickServ', '
identify ...');
end;
procedure TForm1.IdIRC1Message(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel; Content:
String);
begin
Memo1.Lines.Add('
[' + DateToStr(Now) + '
][' + TimeToStr(Now) + '
] (' + auser.Nick + '
) ' + Content);
end;
procedure TForm1.IdIRC1Quit(Sender: TObject; AUser: TIdIRCUser);
begin
if auser.Nick <> idirc1.Nick
then
ListBox1.Items.Delete(ListBox1.Items.IndexOf(GetLevel(auser.Nick)))
else ListBox1.Clear;
end;
procedure TForm1.IdIRC1Part(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel);
begin
ListBox1.Items.Delete(ListBox1.Items.IndexOf(GetLevel(auser.Nick)));
end;
procedure TForm1.IdIRC1Parted(Sender: TObject; AChannel: TIdIRCChannel);
begin
ListBox1.Clear;
memo1.Clear;
end;
procedure TForm1.IdIRC1Join(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel);
begin
ListBox1.Items.Add(GetLevel(auser.nick));
end;
procedure TForm1.ToolButton4Click(Sender: TObject);
begin
Form2.ShowModal;
end;
procedure TForm1.IdIRC1Kick(Sender: TObject; AUser, AVictim: TIdIRCUser;
AChannel: TIdIRCChannel);
begin
ListBox1.Items.Delete(ListBox1.Items.IndexOf(GetLevel(auser.Nick)));
end;
procedure TForm1.IdIRC1Kicked(Sender: TObject; AUser: TIdIRCUser;
AChannel: TIdIRCChannel);
begin
ListBox1.Clear;
memo1.Clear;
end;
end.