0

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

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

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

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

PS:我更改了 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";
	
	 

}

4

2 回答 2

0

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

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

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

B. 您的环境设置不正确,您是否将下载页面上的额外包添加到您的项目中?

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

于 2015-01-10T05:19:02.833 回答
0

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

public static final String OAUTH = "oath:6lw8eg2zw81pmpj09kbr9pa62d006f";
于 2016-04-07T11:34:12.747 回答