Esempio n. 1
0
File: prbot.c Progetto: rfw/prbot
static bool
handle_privmsg(int fd, struct ircmsg_privmsg *msg)
{
	if (strstr(msg->text, IRC_NICK ": ") == msg->text && msg->chan[0] == '#') {
        char *head = msg->text + strlen(IRC_NICK) + 2;

        if (strstr(head, "record ") == head) {
            handle_cmd_record(fd, msg, head + 7);
        } else if (strstr(head, "records ") == head) {
            handle_cmd_records(fd, msg, head + 8);
        } else {
            irc_privmsg(fd, msg->chan, "%s: shut the f**k up.", msg->name.nick);
        }
    }

	return true;
}
Esempio n. 2
0
static bool
handle_privmsg(int fd, struct ircmsg_privmsg *msg)
{
    // Only handle messages directed at the bot.
    if (strncmp(msg->text, IRC_NICK, strlen(IRC_NICK)) != 0)
        return true;

    // Only handle messages in a channel.
    if (msg->chan[0] != '#')
        return true;

    char *cmd = msg->text + strlen(IRC_NICK ": ");

    if (BeginsWith(cmd, "help"))
        return handle_cmd_help(fd, msg, head + 4);
    if (BeginsWith(cmd, "record "))
        return handle_cmd_record(fd, msg, head + 7);
    if (BeginsWith(cmd, "records "))
        return handle_cmd_records(fd, msg, head + 8);

    irc_privmsg(fd, msg->chan, "%s: shut the f**k up.", msg->name.nick);
    return true;
}