تبليغاتX
(-_-)لینک کینگ(-_-)

(-_-)لینک کینگ(-_-)

لینکهای زیبا

delphiscript;   // <---  Do not move this line.

{
Behrooz
}

Const
  IS_ERROR=-1;
  IS_START=1;
  IS_PM=2;
  IS_CHAT=3;
  IS_ADD=4;
  IS_JOINROBOT=5;
  IS_JOIN=6;
  IS_LEFT=7;
  IS_TIMER=8;
  IS_CATEGORY=9;


Function Cut(S:String;emot:Boolean):String;
var
  i:Integer;
  tmp:String;
Begin
  tmp:='';
  for  i:= 1 to Length(s) do
    if s[i]=#39 then
      tmp:=tmp+#39+#39
    else
      tmp:=tmp+s[i];
  if Emot then begin
    VarsRoYa.DelEmotSing:=tmp;
    tmp:=VarsRoYa.DelEmotSing;
  end;
  Result:=tmp;
End;


procedure Next_Join;
Begin
  if  VarsRoYa.ListChatRoom.Count=0 then exit;
  if   (VarsRoYa.ListChatRoom.Count < VarsRoYa.Varint01+1) then
   VarsRoYa.Varint01:=-1;
  VarsRoYa.Varint01:=VarsRoYa.Varint01+1;
  VarsRoYa.RoomName:=VarsRoya.ListChatRoom.Strings[VarsRoYa.Varint01];
  VarsRoYa.Varint02:=0;
//  ShowMessage(VarsRoYa.RoomName);
end;


Procedure Store_User;
Begin
  ADOQuery1.SQL.Text:='Select * From users Where ( user = '''+VarsRoYa.UserPM+''' )';
  ADOQuery1.Open;
  if ADOQuery1.IsEmpty then begin
    ADOQuery1.Close;
    ADOQuery1.SQL.Text:='INSERT INTO users  VALUES ('''+VarsRoya.UserPM+''')';
    ADOQuery1.ExecSQL;
  End;
  ADOQuery1.Close;
End;


Function IsDigit(st:String):Boolean;
var
  i:Integer;
begin
  Result:=True;
  For i:=1 to Length(st) do
   if (st[i]>#57) or (st[i]<#48) then begin
     Result:=False;
     exit;
   end;
End;

Procedure Link;
var
  con,i:Integer;
  Req,name,link:String;
begin
  con:=5;
  if VarsRoya.ListParam.Count>1 then  begin
    VarsRoYa.SendStr:=#13#10'Syntax : <b>/Link [Number]</b> View links'#13#10;
    if VarsRoya.UserPM=VarsRoya.Owner then begin
      VarsRoYa.SendStr:=VarsRoYa.SendStr+'<b>/Link add "Name" "Link" </b> Add Link'#13#10;
      VarsRoYa.SendStr:=VarsRoYa.SendStr+'<b>/Link del <Number> </b> note: Number < RecordCount'#13#10;
    end;
    Req:=Lowercase(Cut(VarsRoya.ListParam.Strings[1],True));
    if (VarsRoya.UserPM=VarsRoya.Owner) then begin
      if (Req='add') then begin
        if VarsRoya.ListParam.Count>3 then  begin
          Name:=Lowercase(Cut(VarsRoya.ListParam.Strings[2],False));
          Link:=Lowercase(Cut(VarsRoya.ListParam.Strings[3],False));
          ADOQuery1.Close;
          ADOQuery1.SQL.Text:='INSERT INTO Links (name,link) VALUES ('''+Name+''','''+Link+''')';
          ADOQuery1.ExecSQL;
          VarsRoYa.SendStr:='mer30:d.';
        end;
      end;

      if (Req='del') then begin
        if VarsRoya.ListParam.Count>2 then  begin
          Name:=Lowercase(Cut(VarsRoya.ListParam.Strings[2],False));
          if IsDigit(Name) then begin
            i:=StrToInt(Name);
            ADOQuery1.SQL.Text:='Select * From links';
            ADOQuery1.Close;
            ADOQuery1.Open;
            if ADOQuery1.RecordCount>=i then begin
              ADOQuery1.RecNo:=ADOQuery1.RecordCount-i+1;
              ADOQuery1.Delete;
              VarsRoYa.SendStr:='Deleted.';
            end;
            ADOQuery1.Close;
          end;
        end;
      end;

    end;
    if IsDigit(req) then begin
      con:=StrToInt(req);
      if con=0 then con:=5;
    end else
    exit;
  end;

  ADOQuery1.SQL.Text:='Select * From links';
  ADOQuery1.Close;
  ADOQuery1.Open;
  i:=0;
  VarsRoYa.SendStr:=#13#10;
  ADOQuery1.Last;
  while not ADOQuery1.Bof do begin
    i:=i+1;
    VarsRoYa.SendStr:=VarsRoYa.SendStr+Format('%d- %s --> %s'#13#10,[i,ADOQuery1.FieldByName('name').AsString,ADOQuery1.FieldByName('link').AsString]);
    if i>=con then break;
    ADOQuery1.Prior;
  end;
 ADOQuery1.Close;
end;


Procedure ADS_pro;
var
  i:Integer;
begin
  Randomize;
  i:=Random (30)+1;
  if i mod 5= 0 then begin
    ADOQuery1.SQL.Text:='Select * From ads';
    ADOQuery1.Close;
    ADOQuery1.Open;
    if not ADOQuery1.IsEmpty then begin
      i:=Random (ADOQuery1.RecordCount)+1;
      ADOQuery1.RecNo:=i;
      VarsRoYa.SendStr:=VarsRoYa.SendStr+VarsRoya.mLine+'Ads -> '+ADOQuery1.FieldByName('name').AsString;
    End;
    ADOQuery1.Close;

  end;
End;


Procedure Dete_PM;
var
 i:Integer;
 tmp,Req,Res:String;
 Flag:Boolean;
begin
  req:='';
  Randomize;
  ADOQuery1.Close;
  Store_User;
  Try
     if  VarsRoYa.SendStr<>'' then exit;
     VarsRoYa.SendStr :=#13+#10'baba''kam ovordam :('+#13+#10;
     VarsRoYa.SendStr := VarsRoYa.SendStr + 'eike gofti yani che? intori yadam bede /learn "Soal" "javab" ;)';
     Flag:=True;
     if VarsRoya.ListParam.Count<1 then exit;
     Req:=Lowercase(VarsRoya.ListParam.Strings[0]);
     if Req = '/learn' then begin
       if VarsRoya.ListParam.Count<3 then  exit;
       Req:=Cut(VarsRoya.ListParam.Strings[1],True);
       Res:=Cut(VarsRoya.ListParam.Strings[2],False);
       ADOQuery1.SQL.Text:='Select * From Message Where ( requst ='''+Req+''' )';
       ADOQuery1.Open;
       if ADOQuery1.IsEmpty then begin
         ADOQuery1.Close;
         ADOQuery1.SQL.Text:='INSERT INTO Message ( requst , response , users ) VALUES ('''+Req+''','''+Res+''','''+VarsRoya.UserPM+''')';
         ADOQuery1.ExecSQL;
         VarsRoYa.SendStr:='Store.';
       End else
         VarsRoYa.SendStr:='Repetitive word .';
       ADOQuery1.Close;
       Flag:=False;
     end;

     if Req = '/next' then begin
       Next_Join;
       Flag:=False;
       VarsRoYa.Mode:=IS_PM;
       VarsRoYa.SendStr:='OK, Next.';
     End;

     if Req = '/delete' then begin
       VarsRoYa.SendStr:='Syntax : <b>/delete "Question"';
       Flag:=False;
       if VarsRoya.ListParam.Count<2 then exit;
       Req:=Cut(VarsRoya.ListParam.Strings[1],True);
       if VarsRoya.UserPm=VarsRoya.Owner then
         ADOQuery1.SQL.Text:='Delete * From Message Where ( Requst ='''+Req+''' )'
       else
         ADOQuery1.SQL.Text:='Delete * From Message Where (( Requst ='''+Req+''' ) and (users ='''+VarsRoya.UserPM+'''))';
       if ADOQuery1.ExecSQL<>0 then
         VarsRoYa.SendStr:=Format('"%s" Deleted',[Req])
       else
         VarsRoYa.SendStr:=Format('"%s" Not fount',[Req]);

       ADOQuery1.Close;
     end;

     if Req = '/edit' then begin
       VarsRoYa.SendStr:='Syntax : /edit <b>"Question" "New Answer"';
       Flag:=False;
       if VarsRoya.ListParam.Count<3 then exit;
       Req:=Cut(VarsRoya.ListParam.Strings[1],True);
       Res:=Cut(VarsRoya.ListParam.Strings[2],False);
       if VarsRoya.UserPm=VarsRoya.Owner then
         ADOQuery1.SQL.Text:='Select * From Message Where ( Requst ='''+Req+''' )'
       else
         ADOQuery1.SQL.Text:='Select * From Message Where (( Requst ='''+Req+''' ) and (users ='''+VarsRoya.UserPM+'''))';
       ADOQuery1.Open;
       if not ADOQuery1.IsEmpty then begin
         ADOQuery1.Edit;
         ADOQuery1.FieldByName('Response').AsString:=Res;
         ADOQuery1.Post;
         VarsRoYa.SendStr:='Update';
       End else
         VarsRoYa.SendStr:=Format('"%s" Not fount',[Req]);
       ADOQuery1.Close;
     end;

     if Req = '/link' then begin
       link;
       Flag:=False;
     end;
  Finally
     if Flag then begin
       For i:=1 to VarsRoya.ListParam.Count-1 do
         Req:= Req+' '+VarsRoya.ListParam.Strings[i] ;
       Req:=Cut(Req,True);
//       ADOQuery1.SQL.Text:='Select * From Message Where ( Requst ='''+Req+''' )';
       ADOQuery1.SQL.Text:='Select * From Message Where Requst LIKE ''%'+Req+'%''';
       ADOQuery1.Open;
       if not ADOQuery1.IsEmpty then begin
         i:=Random (ADOQuery1.RecordCount)+1;
         ADOQuery1.RecNo:=i;
         VarsRoYa.SendStr := ADOQuery1.FieldByName('Response').AsString;
       end;
       ADOQuery1.close;
     end;
     ADS_pro;
  end;
end;


Procedure Dete_Chat;
var
 i:Integer;
 tmp,Req,Res:String;
begin
  if VarsRoya.ListParam.Count<1 then exit;
  Req:=VarsRoya.ListParam.Strings[0];
  For i:=1 to VarsRoya.ListParam.Count-1 do
    Req:= Req+' '+VarsRoya.ListParam.Strings[i] ;
  Req:=Cut(Req,True);
  ADOQuery1.Close;
  ADOQuery1.SQL.Text:='Select * From Message Where ( Requst ='''+Req+''' )';
  ADOQuery1.Open;
  if not ADOQuery1.IsEmpty then
    VarsRoYa.SendStr := ADOQuery1.FieldByName('Response').AsString;
  ADOQuery1.close;
  VarsRoYa.Varint02:=VarsRoYa.Varint02+1;
  ADS_pro;
  if VarsRoYa.Varint02>9 then begin
    Next_Join;
  end;
end;


Procedure Status;
var
  i:Integer;
  st:String;
begin
  Randomize;
  ADOQuery1.SQL.Text:='Select * From Status';
  ADOQuery1.Open;
  if not ADOQuery1.IsEmpty then begin
    i:=Random (ADOQuery1.RecordCount)+1;
    ADOQuery1.RecNo:=i;
    if VarsRoYa.Varint03<>i then begin
      VarsRoYa.Varint03:=i;
      VarsRoYa.Status:=ADOQuery1.FieldByName('name').AsString;
    end;
  End;
  ADOQuery1.Close;
End;

 

Function ProcMessage;
Const
  IS_ERROR=-1;
  IS_START=1;
  IS_PM=2;
  IS_CHAT=3;
  IS_ADD=4;
  IS_JOINROBOT=5;
  IS_JOIN=6;
  IS_LEFT=7;
  IS_TIMER=8;
  IS_CATEGORY=9;

var
  i:Integer;
  st:String;
begin

  St:=VarsRoYa.StrMsgNOHTML;


  if  (VarsRoYa.mode=IS_START) then begin
    Timer.Interval:=60000;
    Timer.Enabled:=True;
//    ShowMessage('Start');
    exit;
  end;

  if (VarsRoYa.Mode=IS_ADD) then begin
   //  VarsRoYa.RoomName:='salam';
    Exit;
  End;

  if  (VarsRoYa.mode=IS_CATEGORY) then begin
    VarsRoYa.Mode:=IS_PM;
    VarsRoYa.SendStr:='Start Chat ...';
    Next_Join;
    exit;
  end;

  if  VarsRoYa.Mode=IS_TIMER then begin
    Status;
    exit;
  end;

  if  VarsRoYa.Mode=IS_JOINROBOT then begin
    if (VarsRoYa.ListChatRoom.Count<3) then
      Next_Join;
    exit;
  end;

  if  VarsRoYa.Mode=IS_LEFT then begin
    if (VarsRoYa.ListChatRoom.Count<3) then
      Next_Join;
    exit;
  end;

  if VarsRoYa.Mode=IS_ERROR then begin
    if St='chat' then begin
      Next_Join;
    end;
  end;

  if  VarsRoYa.Mode=IS_JOIN then begin
    VarsRoYa.Mode:=IS_CHAT;
    VarsRoYa.SendStr:=format('salam , khobi? addam kon <b>"%s"</b> ;)',[VarsRoYa.UserPM]);
    exit;
  end;

  if VarsRoya.ListParam.Count<>0 then begin
    if Length(st)<4 then begin
       VarsRoYa.FindEmotSing:=st;
       if VarsRoYa.FindEmotSing<>'' then begin
         VarsRoYa.SendStr:=VarsRoYa.FindEmotSing;
         Exit;
       End;
    End;


    if  VarsRoYa.mode=IS_CHAT then begin
      Dete_CHAT;
      exit;
    end;

    if  VarsRoYa.mode=IS_PM then begin
      Dete_PM;
      exit;
    end;

  end;
if reg='/bf' then begin
varsroya.Status:='bache ha '+varsRoya.SendStr+'ye bf e bahal mikhad';
VarsRoya.SendStr:='alan yeki barat peida mikonam:D';
End;
if Req = '/status' then begin
       Flag:=False;
       VarsRoYa.Mode:=IS_PM;
       VarsRoYa.SendStr:=format('HeY \:D/ Esmeto Raft Status-e iDiM :"> Didi ;;) :D !?',[VarsRoYa.UserPM]);
       VarsRoYa.Status:=format('%s Joon >:D< :x Dooset Daram :">',[VarsRoYa.UserPM]);
     End;
if Req = '/gf' then begin
       Flag:=False;
       VarsRoYa.Mode:=IS_PM;
       VarsRoYa.SendStr:=format('BEBIN <B>%s</B> joON :*:"> TO HAM BALE  :> ? , ZADI TO KARE << GF >> MASHALA BE IN HAME ESHTEHA <U><B>/Help</B></U> ',[VarsRoYa.UserPM]);
VarsRoYa.Status:=format('GHOSHKONID %s Joon [GF] MIKHAD >:D< :x',[VarsRoYa.UserPM]);
     End;
if reg='/bf' then begin
varsroya.Status:='bache ha '+varsRoya.SendStr+'ye bf e bahal mikhad';
VarsRoya.SendStr:='alan yeki barat peida mikonam:D';
End;

End;

Function SInit:integer;
begin
  ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+VarsRoYa.PathPRG+'Data\Sample.mdb ;Mode=ReadWrite|Share Deny None;Persist Security Info=False';
  ADOConnection1.Connected:=True;
  ADOQuery1.Connection:=ADOConnection1;
  Result:=1;
End;

Function SFina;
begin
  ADOConnection1.Close;
End;

+ نوشته شده در  یکشنبه بیستم آذر 1384ساعت 18:59  توسط بهروز  | 

تاپ لینک

+ نوشته شده در  جمعه چهارم آذر 1384ساعت 20:33  توسط بهروز  | 

+ نوشته شده در  جمعه چهارم آذر 1384ساعت 20:33  توسط بهروز  |