📄 class_recvtcp.pas
字号:
//挂QQ服务端,如需WEB版挂QQ的,自己来改造,本人现在没有精力改造了
//不需要的东西都已经取消了
//提供该程序只是用来学习目的,千万不要用于非法用途,后果自负
//用到RX控件,和JCL库,请大家自行下载
//如果不能挂QQ的话,那就请看LumqQQ中的相关协议,改成新协议即可
//如有更新希望发一份给我 QQ:709582502 Email:Touchboy@126.com
unit Class_RecvTCP;
interface
uses
Windows,Messages, SysUtils, Variants, Classes,ExtCtrls,Forms,
MSWinsockLib_TLB,Class_QQTEA,Class_Record,Class_QQOUTPacket,Class_QQONLine,Class_QQDB;
Type
TQQRecvTCP=Class
private
FTCPSock :array [1..MAXTCPOnLineNum] of TWinSock;
FOutTime :TTimer;
FLoginTime :TTimer;
FAutoReplay :String;
procedure OnLoginTime(Sender:TObject);
procedure OnOutTime(Sender:TObject);
procedure OnDataArrival(ASender: TObject; bytesTotal: Integer);
procedure OnError(ASender: TObject; Number: Smallint;
var Description: WideString; Scode: Integer; const Source,
HelpFile: WideString; HelpContext: Integer;
var CancelDisplay: WordBool);
procedure OnSendComplete(Sender: TObject);
procedure CloseSocket(Index:integer);
procedure SetAutoReplay(const Value: String);
public
constructor Create(nLoginTime,nTimeOut:Integer;TCPForm:TComponent);
destructor Destroy; override;
procedure Accept(nAcceptID:integer);
property AutoReplay:String Read FAutoReplay Write SetAutoReplay;
procedure ResetQQServer;
end;
implementation
{ TQQRecvTCP }
constructor TQQRecvTCP.Create(nLoginTime,nTimeOut: Integer;TCPForm:TComponent);
var
i:integer;
begin
SocketNextSearch :=1;
For i:=1 to MAXTCPOnLineNum do
begin
FTCPSock[i] :=TWinSock.Create(TCPForm);
FTCPSock[i].Tag :=i;
FTCPSock[i].OnError :=OnError;
FTCPSock[i].OnDataArrival :=OnDataArrival;
FTCPSock[i].OnSendComplete:=OnSendComplete;
end;
FOutTime :=TTimer.Create(Nil);
FOutTime.Interval:=nTimeOut;
FOutTime.OnTimer :=OnOutTime;
FLoginTime :=TTimer.Create(Nil);
FLoginTime.Interval:=nLoginTime;
FLoginTime.OnTimer :=OnLoginTime;
FLoginTime.Enabled :=True;
FOutTime.Enabled :=True;
end;
destructor TQQRecvTCP.Destroy;
var
i:integer;
begin
FOutTime.Enabled :=False;
FLoginTime.Enabled :=False;
FreeAndNil(FOutTime);
FreeAndNil(FLoginTime);
For i:=1 to MAXTCPOnLineNum do
begin
FTCPSock[i].Close;
FreeAndNil(FTCPSock[i]);
end;
inherited;
end;
procedure TQQRecvTCP.OnLoginTime(Sender: TObject);
var
i:integer;
S:String;
begin
For I := 1 To MAXTCPOnLineNum do
begin
If SockInfo[I].QQIndex <> 0 Then
begin
SockInfo[I].LoginI := SockInfo[I].LoginI + 1;
If QQInfo[SockInfo[I].QQIndex].State=QsLoginSucess Then
begin
{ QQInfo[SockInfo[I].QQIndex].OneHour :=SockInfo[i].OneHour ;
QQInfo[SockInfo[I].QQIndex].OneMin :=SockInfo[i].OneMin ;
QQInfo[SockInfo[I].QQIndex].TwoHour :=SockInfo[i].TwoHour ;
QQInfo[SockInfo[I].QQIndex].Twomin :=SockInfo[i].Twomin ;
QQInfo[SockInfo[I].QQIndex].UserType:=SockInfo[i].UserType;
}
QQInfo[SockInfo[I].QQIndex].AddTime := Minute;
SockInfo[I].QQIndex := 0;
S :='在'+IntTostr(SockInfo[i].OneHour)+':'+IntTostr(SockInfo[i].OneMin)+
'至'+IntTostr(SockInfo[i].TwoHour)+':'+IntTostr(SockInfo[i].TwoMin);
FTCPSock[I].SendData('挂机成功。您的 QQ 将'+S
+' 时间段内保持在线。');
end
Else If QQInfo[SockInfo[I].QQIndex].State = QsError Then
begin
QQOnLine.Logout(SockInfo[I].QQIndex);
SockInfo[I].QQIndex := 0;
FTCPSock[I].SendData('无法登陆, 可能是你的 QQ/密码 输入错误');
end
Else If QQInfo[SockInfo[I].QQIndex].State =QsPassWordError Then begin
QQOnLine.Logout(SockInfo[I].QQIndex);
SockInfo[I].QQIndex := 0;
FTCPSock[I].SendData('QQ/密码 输入错误, 无法登陆挂机');
end;
If SockInfo[I].LoginI > 20 Then
begin
QQOnLine.Logout(SockInfo[I].QQIndex);
SockInfo[I].QQIndex := 0 ;
FTCPSock[I].SendData('连接 QQ 服务器时出现网络错误, 请稍后再试。');
end;
end;
end;
end;
procedure TQQRecvTCP.OnOutTime(Sender: TObject);
var
i:integer;
begin
For I := 1 To MAXTCPOnLineNum do
begin
If SockInfo[I].TimeoutMark <> -1 Then
begin
SockInfo[I].TimeoutMark := SockInfo[I].TimeoutMark + 1;
If SockInfo[I].TimeoutMark > 50 Then
begin
SockInfo[I].TimeoutMark := -1;
FTCPSock[I].Close
end;
end;
end;
end;
procedure TQQRecvTCP.Accept(nAcceptID: integer);
var
i:integer;
begin
If SocketNextSearch > MAXTCPOnLineNum Then SocketNextSearch := 1;
For I := SocketNextSearch To MAXTCPOnLineNum do
begin
If FTCPSock[I].State= 0 Then
begin
SockInfo[I].TimeoutMark :=0;
FTCPSock[I].Accept(nAcceptID);
SocketNextSearch := I + 1;
Application.ProcessMessages;
Exit;
end;
end;
For I := 1 To SocketNextSearch - 1 do
begin
If FTCPSock[I].State = 0 Then
begin
SockInfo[I].TimeoutMark :=0;
FTCPSock[I].Accept(nAcceptID);
SocketNextSearch := I + 1;
Application.ProcessMessages;
Break;
end;
end;
end;
procedure TQQRecvTCP.OnError(ASender: TObject; Number: Smallint;
var Description: WideString; Scode: Integer; const Source,
HelpFile: WideString; HelpContext: Integer; var CancelDisplay: WordBool);
var
index:integer;
begin
index :=TWinSock(ASender).Tag;
CloseSocket(Index);
end;
procedure TQQRecvTCP.OnDataArrival(ASender: TObject; bytesTotal: Integer);
var
i,j:integer;
hdr:String;
Arr:String;
Key :array [0..15] of byte;
Crypt :array [0..39] of byte;
Plain:TMYByte;
S2Buff :array [0..3] of byte;
S3Buff :array [0..1] of byte;
Stra:String;
index:integer;
Buff:Array of Byte;
v:OleVariant;
P:Pointer;
OneHour,OneMin,TwoHour,TwoMin,UserType:integer;
begin
index :=TWinSock(ASender).Tag;
If bytesTotal = 0 Then
begin
CloseSocket(Index);
Exit;
end;
If bytesTotal <> 59 Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -