Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TCuntXModuleVHost.CheckFormating(const aText: string): boolean;
- var
- i: integer;
- m: integer;
- d: integer;
- begin
- Result := True;
- { Check lengths }
- i := TextPos(aText, CMonkey, True);
- if (i > 10) then
- Exit(False);
- if (i > 0) then
- begin
- if ((Length(aText) - i) >= 64) then
- Exit(False);
- { Check for dot }
- if (TextPos(aText, CDot, False, i) = 0) then
- Exit(False);
- end
- else
- begin
- if (Length(aText) >= 64) then
- Exit(False);
- { Check for dot }
- if (TextPos(aText, CDot) = 0) then
- Exit(False);
- end;
- { Check invalid chars }
- m := 0;
- for i := 1 to Length(aText) do
- begin
- if (
- ((aText[i] <= #$2D) or (aText[i] >= #$7A)) and
- (aText[i] = #$2F) and
- ((aText[i] >= #$3A) and (aText[i] <= #$3F)) and
- ((aText[i] >= #$5B) and (aText[i] <= #$60))
- ) then
- Exit(False);
- { Check for multiple @ }
- if (aText[i] = CMonkey) then
- begin
- Inc(m);
- if (m > 1) then
- Exit(False);
- end;
- end;
- end;
- procedure TCuntXModuleVHost.EventPrivMsg(const aFromNick, aFromHost, aTarget, aText: string);
- procedure ShowHelp;
- begin
- GlobalCuntX.CmdMsg(aTarget, '* Your nickname must be registered to use a VHost!');
- GlobalCuntX.CmdMsg(aTarget, '* No special characters or color allowed in VHosts!');
- GlobalCuntX.CmdMsg(aTarget, '* After you get kicked from the channel type "/hs on" or "/ns update"');
- GlobalCuntX.CmdMsg(aTarget, ' (without quotes) to update your nickname status.');
- GlobalCuntX.CmdMsg(aTarget, '* You can also request a VHost manually using /hs request command.');
- GlobalCuntX.CmdMsg(aTarget, ' For more help with that type "/hs help" (without quotes).');
- GlobalCuntX.CmdMsg(aTarget, '* Manual host requests (using /hs command) are activated automatically every 5 minutes.');
- GlobalCuntX.CmdMsg(aTarget, '--------------------------------------------------------------------');
- GlobalCuntX.CmdMsg(aTarget, 'A VHost is in the form of IDENT@SOME.HOST');
- GlobalCuntX.CmdMsg(aTarget, 'IDENT is optional, SOME.HOST is mandatory.');
- GlobalCuntX.CmdMsg(aTarget, 'IDENT must be LESS THAN 10 characters.');
- GlobalCuntX.CmdMsg(aTarget, 'SOME.HOST must be LESS THAN 64 characters AND has to consist of at least two words separated by a dot (.)');
- GlobalCuntX.CmdMsg(aTarget, '--------------------------------------------------------------------');
- GlobalCuntX.CmdMsg(aTarget, 'Examples:');
- GlobalCuntX.CmdMsg(aTarget, '!vhost my.vhost');
- GlobalCuntX.CmdMsg(aTarget, '!vhost defecating@your.doorstep');
- GlobalCuntX.CmdMsg(aTarget, '--------------------------------------------------------------------');
- GlobalCuntX.CmdMsg(aTarget, 'To assign a VHost to all nicknames in your nickname group use !groupvhost instead of !vhost.');
- end;
- begin
- inherited;
- if (SameText(aTarget, '#vhost')) then
- begin
- Tokenizer.Split(aText, CSpace, [soCSSep]);
- if (SameText(Tokenizer[0], '!vhost')) or (SameText(Tokenizer[0], '!groupvhost')) then
- begin
- if (Tokenizer.Count = 1) then
- begin
- ShowHelp;
- Exit;
- end
- else
- begin
- { Set VHost }
- if (CheckFormating(Tokenizer[1])) then
- begin
- if (SameText(Tokenizer[0], '!vhost')) then
- GlobalCuntX.CmdMsg('hostserv', Format('set %s %s', [aFromNick, Tokenizer[1]]))
- else
- GlobalCuntX.CmdMsg('hostserv', Format('setall %s %s', [aFromNick, Tokenizer[1]]));
- GlobalCuntX.CmdMsg('hostserv', Format('activate %s', [aFromNick]));
- GlobalCuntX.CmdMsg(aTarget, Format('!tb %s!*@* 3600', [aFromNick]));
- GlobalCuntX.CmdMsg('ChanServ', Format('KICK %s %s Done. You can request another VHost in 3600 seconds.', [aTarget, aFromNick]));
- GlobalCuntX.Log(Format('%s VHost for user %s set to %s.', [CINFO, aFromNick, Tokenizer[1]]));
- end
- else
- GlobalCuntX.CmdMsg(aTarget, Format('%s, Invalid vhost. Read help again (type !vhost).', [aFromNick]));
- Exit;
- end;
- end;
- end;
- end;
Add Comment
Please, Sign In to add comment