【问题标题】:Why Does My Twitch IRC Bot not Connect?为什么我的 Twitch IRC 机器人无法连接?
【发布时间】:2015-02-21 11:00:48
【问题描述】:

所以我决定尝试编写一个 twitch IRC 机器人,只是为了体验一下。到目前为止,我已经学到了很多东西,但现在我遇到了障碍,似乎无法让机器人连接起来。

我有一个可以连接到 twitch irc 的 IRC 客户端,但我无法 ping irc.twitch.tv 我的机器人使用 PircBotX 框架作为它的基础,到目前为止它应该做的只是连接到服务器,但它没有。我在 eclipse 中设置了所有东西,一切看起来都很好,但机器人从未真正连接过。它不断尝试,但似乎永远无法通过。

我不确定为什么它不起作用。我还端口转发了端口,以防万一它需要在路由器上但没有运气。 当我在 Eclipse 中运行机器人时,它开始尝试连接然后停止运行。

我一直在从 pircbotx 的文档中拼凑出一些东西,这个机器人的代码:https://github.com/MattsMc/MankiniBot 和我发现的这个 youtube 系列:https://www.youtube.com/watch?v=a1WDUKI5-PI。你能提供的任何帮助都会很棒。谢谢。

P.S:我更改了 OAUTH 代码,因此无需担心 :)

基本上这是我的代码:

package firedingo.project.bot;



import com.google.common.collect.*;
import com.google.guava.*;
import org.pircbotx.Configuration;
import org.pircbotx.PircBotX;


public class TheDingoPack {
	private int count;
	
	//starting config again in case config derp is issue, will need clean up HERE
	Configuration<PircBotX> Config = new Configuration.Builder<PircBotX>()
			.setServerPassword(firedingo.project.bot.reference.Reference.OAUTH)
			.setName(firedingo.project.bot.reference.Reference.NICK)
			.setLogin(firedingo.project.bot.reference.Reference.NICK)
			.setAutoNickChange(true)
			.setServerHostname(firedingo.project.bot.reference.Reference.HOST)
			.setServerPort(firedingo.project.bot.reference.Reference.PORT)
			
			.addAutoJoinChannel(firedingo.project.bot.reference.Reference.BOTCHAN)
			.buildConfiguration();
	
	//Constructor to actually create the bot
	public TheDingoPack() {
		PircBotX TheDingoPack = new PircBotX(Config);
	try {
		TheDingoPack.startBot();
		System.out.println("Attempting To Connect");
	}
	catch(Exception e) {
		System.out.println("Connection Failed - Error Thrown");
	}

	
}
	//realized constructor needed a call so added it here. Nearly derped :P
	 public static void main(String[] args) {
		 new TheDingoPack();
	 }
}

package firedingo.project.bot.reference;

public class Reference {

	//Connection Details As Constants For Easy Customizability
	public static final String NICK = "thedingopack";
	public static final String HOST = "irc.twitch.tv";
	public static final String OAUTH = "6lw8eg2zw81pmpj09kbr9pa62d006f";
	public static final int PORT = 6667;
	//these two channels can be changed as necessary, extras can also be added.
	public static final String BOTCHAN = "#thedingopack";
	public static final String MODCHAN = "#firedingo99365";
	
	 

}

【问题讨论】:

    标签: bots irc twitch


    【解决方案1】:

    我试着在这里回答你的问题,但 Stack Overflow 只会让我发布两个链接,所以这里是它的短...

    我将您的代码复制/粘贴到我的环境中,替换为我的机器人统计信息并运行它,我没有遇到任何问题。这使我选择了两种选择之一……

    A.您没有该机器人的帐户(我认为这不太可能,因为您有 OAuth 代码)

    B.您的环境设置不正确,您是否将在 download page 上找到的额外包添加到您的项目中?

    如果不是并且您不知道如何操作,或者您只是想确切地知道要添加哪些 .jar(因为几个软件包有一堆毫无意义的),我制作了一个关于如何设置它的教程。你可以找到它here

    【讨论】:

      【解决方案2】:

      我记得你需要把完整的誓言代码像这样

      public static final String OAUTH = "oath:6lw8eg2zw81pmpj09kbr9pa62d006f";
      

      【讨论】:

        猜你喜欢
        • 2011-01-21
        • 2015-02-09
        • 2018-12-31
        • 2014-09-18
        • 1970-01-01
        • 2011-01-22
        • 1970-01-01
        • 1970-01-01
        • 2012-08-13
        相关资源
        最近更新 更多