⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idirc.pas

📁 Indy控件的使用源代码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  FNames.Free;
  FBans.Free;
  inherited Destroy;
end;

{ Set the topic of the channel. }
procedure TIdIRCChannel.SetTopic(AValue: String);
begin
  FClient.SetTopic(FName, AValue);
end;

{ Compile a mode command to change the mode of the channel. }
procedure TIdIRCChannel.SetMode(AValue: TIdIRCChannelModes);
var
  Element: TIdIRCChannelMode;
  Difference: TIdIRCChannelModes;
  TempOptions: String;
begin
  TempOptions := '';    {Do not Localize}
  { If no difference in modes, then exit. }
  if FMode = AValue then
  begin
    Exit;
  end;
  { Calculate which modes have been removed. }
  Difference := FMode - AValue;
  if Difference <> [] then
  begin
    if ChangeType <> ctSubtract then
    begin
      TempOptions := TempOptions + '-';    {Do not Localize}
      ChangeType := ctSubtract;
    end;
    for Element := cmPrivate to cmKey do
    begin
      if Element in Difference then
      begin
        TempOptions := TempOptions + ChannelModeChars[Ord(Element)];
      end;
    end;
  end;
  { Calculate which modes have been added. }
  Difference := AValue - FMode;
  if Difference <> [] then
  begin
    if ChangeType <> ctAdd then
    begin
      TempOptions := TempOptions + '+';    {Do not Localize}
      ChangeType := ctAdd;
    end;
    { Will not add Limit or Key modes.  These must be added with the Limit and
      Key properties. }
    for Element := cmPrivate to cmKey do
    begin
      if (Element <> cmUserLimit) and (Element <> cmKey) then
      begin
        if Element in Difference then
        begin
          TempOptions := TempOptions + ChannelModeChars[Ord(Element)];
        end;
      end;
    end;
  end;
  { If compiling mode changes. }
  if FModeChange then
  begin
    { Add the mode change. }
    ModeOptions := ModeOptions + TempOptions;
  end
  { Send the mode change immediately. }
  else
  begin
    FClient.Mode(FName, TempOptions, '');    {Do not Localize}
  end;
end;

procedure TIdIRCChannel.SetLimit(AValue: Integer);
begin
  { If compiling mode changes. }
  if FModeChange then
  begin
    { If the change type needs to be modified. }
    if ChangeType <> ctAdd then
    begin
      ModeOptions := ModeOptions + '+';    {Do not Localize}
      ChangeType := ctAdd;
    end;
    { Add the mode change. }
    ModeOptions := ModeOptions + 'l';    {Do not Localize}
    { If there are already some parameters, then add a space separator. }
    if ModeParams <> '' then    {Do not Localize}
    begin
      ModeParams := ModeParams + ' ';    {Do not Localize}
    end;
    { Add the parameter. }
    ModeParams := ModeParams + Format('%s', [FLimit]);    {Do not Localize}
  end
  { Send the mode change immediately. }
  else
  begin
    FClient.Mode(FName, '+l', Format('%s', [FLimit]));    {Do not Localize}
  end;
end;

procedure TIdIRCChannel.SetKey(AValue: String);
begin
  { If compiling mode changes. }
  if FModeChange then
  begin
    { If the change type needs to be modified. }
    if ChangeType <> ctAdd then
    begin
      ModeOptions := ModeOptions + '+';    {Do not Localize}
      ChangeType := ctAdd;
    end;
    { Add the mode change. }
    ModeOptions := ModeOptions + 'k';    {Do not Localize}
    { If there are already some parameters, then add a space separator. }
    if ModeParams <> '' then    {Do not Localize}
    begin
      ModeParams := ModeParams + ' ';    {Do not Localize}
    end;
    { Add the parameter. }
    ModeParams := ModeParams + FKey;
  end
  { Send the mode change immediately. }
  else
  begin
    FClient.Mode(FName, '+k', FKey);    {Do not Localize}
  end;
end;

{ Send a message to the channel. }
procedure TIdIRCChannel.Say(AMsg: String);
begin
  FClient.Say(FName, AMsg);
end;

{ Part the channel. }
procedure TIdIRCChannel.Part(AReason: String);
begin
  FClient.Part(FName, AReason);
end;

{ Kick a person from the channel. }
procedure TIdIRCChannel.Kick(ANick, AReason: String);
begin
  FClient.Kick(FName, ANick, AReason);
end;

{ Begin compiling all subsequent mode changes into one mode command. }
procedure TIdIRCChannel.BeginMode;
begin
  ModeOptions := '';    {Do not Localize}
  ModeParams := '';    {Do not Localize}
  ChangeType := ctNone;
  FModeChange := True;
end;

{ Send all compiled mode changes as one mode command. }
procedure TIdIRCChannel.EndMode;
begin
  { If no mode changes have been compiled, then do not send the command. }
  if ModeOptions <> '' then    {Do not Localize}
  begin
    FClient.Mode(FName, ModeOptions, ModeParams);
  end;
  FModeChange := False;
end;

{ Give a user channel operator status. }
procedure TIdIRCChannel.Op(ANick: String);
begin
  { If compiling mode changes. }
  if FModeChange then
  begin
    { If the change type needs to be modified. }
    if ChangeType <> ctAdd then
    begin
      ModeOptions := ModeOptions + '+';    {Do not Localize}
      ChangeType := ctAdd;
    end;
    { Add the mode change. }
    ModeOptions := ModeOptions + 'o';    {Do not Localize}
    { If there are already some parameters, then add a space separator. }
    if ModeParams <> '' then    {Do not Localize}
    begin
      ModeParams := ModeParams + ' ';    {Do not Localize}
    end;
    { Add the parameter. }
    ModeParams := ModeParams + ANick;
  end
  { Send the mode change immediately. }
  else
  begin
    FClient.Mode(FName, '+o', ANick);    {Do not Localize}
  end;
end;

{ Remove channel operator status from a user. }
procedure TIdIRCChannel.Deop(ANick: String);
begin
  { If compiling mode changes. }
  if FModeChange then
  begin
    { If the change type needs to be modified. }
    if ChangeType <> ctSubtract then
    begin
      ModeOptions := ModeOptions + '-';    {Do not Localize}
      ChangeType := ctSubtract;
    end;
    { Add the mode change. }
    ModeOptions := ModeOptions + 'o';    {Do not Localize}
    { If there are already some parameters, then add a space separator. }
    if ModeParams <> '' then    {Do not Localize}
    begin
      ModeParams := ModeParams + ' ';    {Do not Localize}
    end;
    { Add the parameter. }
    ModeParams := ModeParams + ANick;
  end
  { Send the mode change immediately. }
  else
  begin
    FClient.Mode(FName, '-o', ANick);    {Do not Localize}
  end;
end;

{ Give a user a voice in a moderated channel. }
procedure TIdIRCChannel.Voice(ANick: String);
begin
  { If compiling mode changes. }
  if FModeChange then
  begin
    { If the change type needs to be modified. }
    if ChangeType <> ctAdd then
    begin
      ModeOptions := ModeOptions + '+';    {Do not Localize}
      ChangeType := ctAdd;
    end;
    { Add the mode change. }
    ModeOptions := ModeOptions + 'v';    {Do not Localize}
    { If there are already some parameters, then add a space separator. }
    if ModeParams <> '' then    {Do not Localize}
    begin
      ModeParams := ModeParams + ' ';    {Do not Localize}
    end;
    { Add the parameter. }
    ModeParams := ModeParams + ANick;
  end
  { Send the mode change immediately. }
  else
  begin
    FClient.Mode(FName, '+v', ANick);    {Do not Localize}
  end;
end;

{ Remove the voice from a user in a moderated channel. }
procedure TIdIRCChannel.Devoice(ANick: String);
begin
  { If compiling mode changes. }
  if FModeChange then
  begin
    { If the change type needs to be modified. }
    if ChangeType <> ctSubtract then
    begin
      ModeOptions := ModeOptions + '-';    {Do not Localize}
      ChangeType := ctSubtract;
    end;
    { Add the mode change. }
    ModeOptions := ModeOptions + 'v';    {Do not Localize}
    { If there are already some parameters, then add a space separator. }
    if ModeParams <> '' then    {Do not Localize}
    begin
      ModeParams := ModeParams + ' ';    {Do not Localize}
    end;
    { Add the parameter. }
    ModeParams := ModeParams + ANick;
  end
  { Send the mode change immediately. }
  else
  begin
    FClient.Mode(FName, '-v', ANick);    {Do not Localize}
  end;
end;

{ Ban a user from the channel. }
procedure TIdIRCChannel.Ban(AHostmask: String);
begin
  { If compiling mode changes. }
  if FModeChange then
  begin
    { If the change type needs to be modified. }
    if ChangeType <> ctAdd then
    begin
      ModeOptions := ModeOptions + '+';    {Do not Localize}
      ChangeType := ctAdd;
    end;
    { Add the mode change. }
    ModeOptions := ModeOptions + 'b';    {Do not Localize}
    { If there are already some parameters, then add a space separator. }
    if ModeParams <> '' then    {Do not Localize}
    begin
      ModeParams := ModeParams + ' ';    {Do not Localize}
    end;
    { Add the parameter. }
    ModeParams := ModeParams + AHostmask;
  end
  { Send the mode change immediately. }
  else
  beg

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -