Guest User

Untitled

a guest
Jan 23rd, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 4.55 KB | None | 0 0
  1. function TCuntXModuleVHost.CheckFormating(const aText: string): boolean;
  2. var
  3.     i: integer;
  4.     m: integer;
  5.     d: integer;
  6. begin
  7.     Result := True;
  8.  
  9.     { Check lengths }
  10.     i := TextPos(aText, CMonkey, True);
  11.     if (i > 10) then
  12.         Exit(False);
  13.     if (i > 0) then
  14.     begin
  15.         if ((Length(aText) - i) >= 64) then
  16.             Exit(False);
  17.  
  18.         { Check for dot }
  19.         if (TextPos(aText, CDot, False, i) = 0) then
  20.             Exit(False);
  21.     end
  22.     else
  23.     begin
  24.         if (Length(aText) >= 64) then
  25.             Exit(False);
  26.  
  27.         { Check for dot }
  28.         if (TextPos(aText, CDot) = 0) then
  29.             Exit(False);
  30.     end;
  31.  
  32.     { Check invalid chars }
  33.     m     := 0;
  34.     for i := 1 to Length(aText) do
  35.     begin
  36.         if (
  37.           ((aText[i] <= #$2D) or (aText[i] >= #$7A)) and
  38.           (aText[i] = #$2F) and
  39.           ((aText[i] >= #$3A) and (aText[i] <= #$3F)) and
  40.           ((aText[i] >= #$5B) and (aText[i] <= #$60))
  41.           ) then
  42.             Exit(False);
  43.  
  44.         { Check for multiple @ }
  45.         if (aText[i] = CMonkey) then
  46.         begin
  47.             Inc(m);
  48.             if (m > 1) then
  49.                 Exit(False);
  50.         end;
  51.     end;
  52. end;
  53.  
  54.  
  55. procedure TCuntXModuleVHost.EventPrivMsg(const aFromNick, aFromHost, aTarget, aText: string);
  56.  
  57.     procedure ShowHelp;
  58.     begin
  59.         GlobalCuntX.CmdMsg(aTarget, '* Your nickname must be registered to use a VHost!');
  60.         GlobalCuntX.CmdMsg(aTarget, '* No special characters or color allowed in VHosts!');
  61.         GlobalCuntX.CmdMsg(aTarget, '* After you get kicked from the channel type "/hs on" or "/ns update"');
  62.         GlobalCuntX.CmdMsg(aTarget, '  (without quotes) to update your nickname status.');
  63.         GlobalCuntX.CmdMsg(aTarget, '* You can also request a VHost manually using /hs request command.');
  64.         GlobalCuntX.CmdMsg(aTarget, '  For more help with that type "/hs help" (without quotes).');
  65.         GlobalCuntX.CmdMsg(aTarget, '* Manual host requests (using /hs command) are activated automatically every 5 minutes.');
  66.         GlobalCuntX.CmdMsg(aTarget, '--------------------------------------------------------------------');
  67.         GlobalCuntX.CmdMsg(aTarget, 'A VHost is in the form of IDENT@SOME.HOST');
  68.         GlobalCuntX.CmdMsg(aTarget, 'IDENT is optional, SOME.HOST is mandatory.');
  69.         GlobalCuntX.CmdMsg(aTarget, 'IDENT must be LESS THAN 10 characters.');
  70.         GlobalCuntX.CmdMsg(aTarget, 'SOME.HOST must be LESS THAN 64 characters AND has to consist of at least two words separated by a dot (.)');
  71.         GlobalCuntX.CmdMsg(aTarget, '--------------------------------------------------------------------');
  72.         GlobalCuntX.CmdMsg(aTarget, 'Examples:');
  73.         GlobalCuntX.CmdMsg(aTarget, '!vhost my.vhost');
  74.         GlobalCuntX.CmdMsg(aTarget, '!vhost defecating@your.doorstep');
  75.         GlobalCuntX.CmdMsg(aTarget, '--------------------------------------------------------------------');
  76.         GlobalCuntX.CmdMsg(aTarget, 'To assign a VHost to all nicknames in your nickname group use !groupvhost instead of !vhost.');
  77.     end;
  78.  
  79. begin
  80.     inherited;
  81.  
  82.     if (SameText(aTarget, '#vhost')) then
  83.     begin
  84.         Tokenizer.Split(aText, CSpace, [soCSSep]);
  85.  
  86.         if (SameText(Tokenizer[0], '!vhost')) or (SameText(Tokenizer[0], '!groupvhost')) then
  87.         begin
  88.             if (Tokenizer.Count = 1) then
  89.             begin
  90.                 ShowHelp;
  91.                 Exit;
  92.             end
  93.             else
  94.             begin
  95.                 { Set VHost }
  96.                 if (CheckFormating(Tokenizer[1])) then
  97.                 begin
  98.                     if (SameText(Tokenizer[0], '!vhost')) then
  99.                         GlobalCuntX.CmdMsg('hostserv', Format('set %s %s', [aFromNick, Tokenizer[1]]))
  100.                     else
  101.                         GlobalCuntX.CmdMsg('hostserv', Format('setall %s %s', [aFromNick, Tokenizer[1]]));
  102.                     GlobalCuntX.CmdMsg('hostserv', Format('activate %s', [aFromNick]));
  103.                     GlobalCuntX.CmdMsg(aTarget, Format('!tb %s!*@* 3600', [aFromNick]));
  104.                     GlobalCuntX.CmdMsg('ChanServ', Format('KICK %s %s Done. You can request another VHost in 3600 seconds.', [aTarget, aFromNick]));
  105.                     GlobalCuntX.Log(Format('%s VHost for user %s set to %s.', [CINFO, aFromNick, Tokenizer[1]]));
  106.                 end
  107.                 else
  108.                     GlobalCuntX.CmdMsg(aTarget, Format('%s, Invalid vhost. Read help again (type !vhost).', [aFromNick]));
  109.                 Exit;
  110.             end;
  111.         end;
  112.     end;
  113. end;
Add Comment
Please, Sign In to add comment