- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从 here 找到了一个 IRC 机器人骨架尽管作者说应该可以,但它无法编译。 gcc 基本上会抛出这些错误
/tmp/cc39tOaX.o: In function
raw': bot.c:(.text+0x73): undefined
va_start' bot.c:(.text+0xaa): undefined reference to `va_end' collect2: error: ld returned 1 exit status
reference to
这似乎意味着这两个函数在原始函数中调用之前没有定义?
无论如何,这是代码。任何对开始解决这个问题的帮助都会有很大的帮助。
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <netdb.h>
int conn;
char sbuf[512];
void raw(char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vsnprintf(sbuf, 512, fmt, ap);
va_end(ap);
printf("<< %s", sbuf);
write(conn, sbuf, strlen(sbuf));
}
int main() {
char *nick = "test";
char *channel = NULL;
char *host = "irc.dav7.net";
char *port = "6667";
char *user, *command, *where, *message, *sep, *target;
int i, j, l, sl, o = -1, start, wordcount;
char buf[513];
struct addrinfo hints, *res;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
getaddrinfo(host, port, &hints, &res);
conn = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
connect(conn, res->ai_addr, res->ai_addrlen);
raw("USER %s 0 0 :%s\r\n", nick, nick);
raw("NICK %s\r\n", nick);
while ((sl = read(conn, sbuf, 512))) {
for (i = 0; i < sl; i++) {
o++;
buf[o] = sbuf[i];
if ((i > 0 && sbuf[i] == '\n' && sbuf[i - 1] == '\r') || o == 512) {
buf[o + 1] = '\0';
l = o;
o = -1;
printf(">> %s", buf);
if (!strncmp(buf, "PING", 4)) {
buf[1] = 'O';
raw(buf);
} else if (buf[0] == ':') {
wordcount = 0;
user = command = where = message = NULL;
for (j = 1; j < l; j++) {
if (buf[j] == ' ') {
buf[j] = '\0';
wordcount++;
switch(wordcount) {
case 1: user = buf + 1; break;
case 2: command = buf + start; break;
case 3: where = buf + start; break;
}
if (j == l - 1) continue;
start = j + 1;
} else if (buf[j] == ':' && wordcount == 3) {
if (j < l - 1) message = buf + j + 1;
break;
}
}
if (wordcount < 2) continue;
if (!strncmp(command, "001", 3) && channel != NULL) {
raw("JOIN %s\r\n", channel);
} else if (!strncmp(command, "PRIVMSG", 7) || !strncmp(command, "NOTICE", 6)) {
if (where == NULL || message == NULL) continue;
if ((sep = strchr(user, '!')) != NULL) user[sep - user] = '\0';
if (where[0] == '#' || where[0] == '&' || where[0] == '+' || where[0] == '!') target = where; else target = user;
printf("[from: %s] [reply-with: %s] [where: %s] [reply-to: %s] %s", user, command, where, target, message);
//raw("%s %s :%s", command, target, message); // If you enable this the IRCd will get its "*** Looking up your hostname..." messages thrown back at it but it works...
}
}
}
}
}
return 0;
}
我尝试在函数 raw() 之前定义 va_start 和 va_end
void va_start();
void va_end();
但这并没有改变任何东西..
最佳答案
man va_start
给了我:
SYNOPSIS
#include <stdarg.h>
void va_start(va_list ap, last);
type va_arg(va_list ap, type);
void va_end(va_list ap);
void va_copy(va_list dest, va_list src);
通过添加 #include <stdarg.h>
这对我有用。
关于c - 用 C 语言编写的 IRC 机器人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32778786/
基于浏览器的 irc 客户端是否可以在不使用任何网关的情况下工作,即直接与 irc 服务器通信? 最佳答案 HTML5 WebSocket 无法连接到非 WebSocket 服务器。使用 WebSoc
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭11 年前。 Improve th
在我的 IRC Bot 中,有一些命令我希望只能由我使用,并且我想检查以确保使用我的名字的任何人都被识别为 nickserv (idented)。但是,我无法找到一种简单的方法来确定这一点,这就是我在
我想在我的网站上实现聊天服务,想知道如何从头开始创建一个简单的基于浏览器的 IRC 客户端? 我有一个 linux box,可以在上面安装任何我想要的东西。 Google 找到了关于如何设置 IRC
我希望能够在不加入 IRC channel 的情况下从 IRC channel 获取用户列表及其详细信息,从而增加其用户数量。 所以不要发出 JOIN #chan然后 NAMES #chan要获取用户
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我正在尝试编写我自己的 IRC 服务器。我引用的是 IRC RFC,但它让我有点困惑。如果我严格遵守 RFC,我认为任何流行的客户端都不会与我的服务器一起工作,比如 mIRC。例如,RFC 规定服务器
我正在使用标准库中的 TcpStream 开发一个 IRC 机器人。 我能够阅读输入的所有行,但 IRC 服务器似乎没有响应我的身份请求。我以为我发送请求的时间太早了,所以我尝试在发送 IDENT 之
我想连接到 ExIrc 中的两台服务器使用 Elixir ,我找不到一个简单的解决方案。我对 elixir 还很陌生,我能做的就是使用“伞”来运行两个应用程序并使它们相互连接? (我想用一个应用程序连
这个数字不是 RFC 1459 的一部分,但我希望能够使用它以便在 IRC 机器人中正确堆叠和取消堆叠模式。有没有不发送这个的主流 IRC 服务器? 最佳答案 这是规范的可选建议,这意味着编写客户端的
我对此进行了广泛的搜索,只找到了特定于机器人的客户端。我知道它们基本相同,但是对于我想做的事情,我就是想不通。 我正在尝试编写一个 python 客户端,它表面上是纯粹而简单的。例如,当从命令行运行时
我正在使用 net.Socket 模块连接到 EFNET 并测试我的代码,以便向我的机器人添加重新连接事件。 我可以通过哪些方式来模拟机器人断开连接?问题是 2-3 周后就会断开连接 - 我添加了事件
require "socket" server = "irc.rizon.net" port = "6667" nick = "Ruby IRC Bot" channel = "#0x40" s =
我正在尝试编写一个函数,使用 Twisted Python 将 IRC channel 中的昵称列表打印到该 channel 。我该怎么做呢?我已经阅读了 API 文档,并且在该站点上只看到一个与我的
我有一个命令,我想将其限制在某些级别。我正在使用 unreal3.2.6 IRC。 我读到这个: 但我仍然不确定我可以做些什么来检查用户排名。 我想看看用户是否是“语音”或更高级别。什么可以查找用户,
我正在计划建立一个 IRC 网络并一直在探索各种选择。我打算使用Inspircd IRC Server 。以及运行 meteor 的网络服务器。是否可以使用 websockets 构建一个 Web I
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 8年前关闭。 Improve this qu
如何获得 Weechat 配置变量?例如,我可以设置配置: /set irc.servers.freenode.ssl on 如何检索我设置的值? 最佳答案 要检查配置变量的值,您可以这样做: /se
有没有办法告诉irssi我要自动加入当前打开的所有 channel ? 我想要类似的东西: /channel add -auto /save 最佳答案 我找到了答案here: /alias adda
我整天都在搜寻Google,并且正在寻找一种方法来编写具有不同颜色的文本,就像我在其他IRC channel 上经常看到的那样。我想通过基于CLI的irssi实现此目的。我发现了多种无法正常工作的方法
我是一名优秀的程序员,十分优秀!