需要帮助使用 Indy 组件在 Delphi 2010 中编写 IRC 客户端

发布于 2024-09-18 10:28:57 字数 1063 浏览 4 评论 0原文

我正在尝试使用 Indy 组件在 Delphi 2010 中编写一个基本的 irc 客户端。 我能够使用下面的示例 A 连接到我的 irc 服务器(unrealircd)。

连接后,我有许多程序应该在收到私人消息、ping、ctcp、通道模式等时执行操作,但它们永远不会对任何这些传入事件做出反应。

样品A: 当按下按钮 4 时,它会连接到 IRC 服务器。 已成功加入指定名称的频道。

procedure TForm1.Button4Click(Sender: TObject);
begin
  IdIRC1.Host := '72.20.53.142';
  IdIRC1.Port := 6667;
  IdIRC1.Nickname := ssh.frmmain.Edit1.text;//insert your nickname here
    try
    idIRC1.Connect;
  except
    if not idIRC1.Connected then
      begin
        Memo2.Lines.add('Error Connecting to ' + idIRC1.Host);
        Exit;
      end;
  end;
  Memo2.Lines.add ('Connected to Auth Server');
  idIRC1.Join(channel,key);
  Memo2.Lines.add ('Auth Accepted');
end;

这些事件根本不起作用,并且在编译期间不会生成任何错误。

procedure TForm1.IdIRC1Connected(Sender: TObject);
begin
  memo2.Lines.Clear;
  memo2.Lines.add ('2Connected');
end;

procedure TForm1.IdIRC1ServerVersion(ASender: TIdContext; Version, Host, Comments: String);
begin
memo2.Lines.Add(Version +'Host '+Host+'Comments '+Comments);
end;

Im trying to code a basic irc client in Delphi 2010 using Indy components.
Im able to connect to my irc server (unrealircd) using sample A below.

After connecting I have many procedures that should perform actions when it receives a private message, ping, ctcp, channel modes etc. but they never react to any of these incoming events.

Sample A:
This connects to the IRC server when button4 is pressed.
It sucessfully joins the channel with the name specified.

procedure TForm1.Button4Click(Sender: TObject);
begin
  IdIRC1.Host := '72.20.53.142';
  IdIRC1.Port := 6667;
  IdIRC1.Nickname := ssh.frmmain.Edit1.text;//insert your nickname here
    try
    idIRC1.Connect;
  except
    if not idIRC1.Connected then
      begin
        Memo2.Lines.add('Error Connecting to ' + idIRC1.Host);
        Exit;
      end;
  end;
  Memo2.Lines.add ('Connected to Auth Server');
  idIRC1.Join(channel,key);
  Memo2.Lines.add ('Auth Accepted');
end;

These events dont work at all and no errors are generated during a compile.

procedure TForm1.IdIRC1Connected(Sender: TObject);
begin
  memo2.Lines.Clear;
  memo2.Lines.add ('2Connected');
end;

procedure TForm1.IdIRC1ServerVersion(ASender: TIdContext; Version, Host, Comments: String);
begin
memo2.Lines.Add(Version +'Host '+Host+'Comments '+Comments);
end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

停顿的约定 2024-09-25 10:28:57

我已经有几个人看过这个,似乎有一些 unicode 问题破坏了我的 TClientSocket irc 设置,即使当我转移到 indy 并使用官方网站上的示例时,我仍然无法启动任何东西,例如onconnect 事件。

一位朋友有一个他在 Delphi 2010 中使用相同版本的 indy 编写的应用程序的副本,我设法导入他的项目,它开始工作。

不知道为什么

Ive had a few people look at this, and it just seems theres some unicode issues that destroyed my TClientSocket irc setup, and even when I moved to indy and used samples off the official site I was still unable to get anything to fire such as the onconnect event.

A friend had a copy of an application he wrote in Delphi 2010 using the same version of indy and I managed to import his project and it started working.

Not sure why

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文