【问题标题】:pIRCbot won't join Twitch channel or send messagespIRCbot 不会加入 Twitch 频道或发送消息
【发布时间】:2015-05-26 21:03:29
【问题描述】:

以下代码成功连接到 Twitch 的 IRC 并触发 onConnect 方法,这就是一切停止的地方。 因为 pIRCbot 启用了详细功能,我可以看到它在连接后确实发送了JOIN #twitchplayspokemon,但规范说我应该得到一个立即响应,其中包含相同的文本,后跟用户列表(这将触发 onJoin 和 onUserList 方法)不会发生。

我也尝试过连接到我的频道并使用
joinChannel("#[mychannelname]"); sendMessage("#[mychannelname]", "Hello World");
发送消息 所有这一切都是发送两个 JOIN 命令,并且不会加入,也不会在聊天中出现消息。

我使用的教程/参考是http://help.twitch.tv/customer/portal/articles/1302780-twitch-irc

其他响应也未输出。我正在获取 MOTD,但没有看到“/MOTD 命令结束”。

import org.jibble.pircbot.*;

public class MyBotMain extends PircBot {

    public static void main(String[] args) throws Exception {

        MyBotMain bot = new MyBotMain();

        bot.setVerbose(true);

        bot.setName("[myname]");
        bot.setLogin("[myname]");

        try {
            bot.connect("irc.twitch.tv", 6667, "oauth:db4aai4mh474ikbgzzuh76fv67n"); // Not the key I'm using
        } catch (NickAlreadyInUseException e) {
            System.err.println("Nickname is currently in use");
        } catch (IrcException e) {
            System.err.println("Server did not accept connection");
            e.printStackTrace();
        }
    }

    @Override
    protected void onConnect() {
        System.out.println("Connected!");
        joinChannel("#witchplayspokemon");
        super.onConnect();
    }

    @Override
    protected void onJoin(String channel, String sender, String login, String hostname) {
        System.out.println(login + " joined channel " + channel);
        super.onJoin(channel, sender, login, hostname);
    }

    @Override
    protected void onUserList(String channel, User[] users) {
        for (User user : users) {
            System.out.println(user);
        }
        super.onUserList(channel, users);
    }
}

【问题讨论】:

    标签: java sockets bots irc twitch


    【解决方案1】:

    您的代码运行良好,唯一的问题是您尝试加入的频道是“witchplayspokemon”而不是“twitchplayspokemon” onUserList(String channel, User[] users) 只给了我一个用户,但我最近在我自己的 Bot 上遇到了这个问题,所以我还不确定原因。

    【讨论】:

    • 我刚刚读到,对于 e3,twitch 已禁用用户列表/加入部分 IRC 聊天服务器,因此 onUserList(String channel, User[] users) 将无法正常工作,直到他们将其添加回.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 2021-09-18
    • 1970-01-01
    • 2014-09-18
    • 2021-01-10
    • 2016-03-31
    • 2021-03-24
    相关资源
    最近更新 更多