本文整理汇总了Java中com.google.code.chatterbotapi.ChatterBotType类的典型用法代码示例。如果您正苦于以下问题:Java ChatterBotType类的具体用法?Java ChatterBotType怎么用?Java ChatterBotType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChatterBotType类属于com.google.code.chatterbotapi包,在下文中一共展示了ChatterBotType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGui
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
@Override
public void initGui()
{
this.reponse = this.getRandomString();
this.textfield = new GuiTextField(this.fontRendererObj, this.width / 2 - 150, 50, 300, 20);
this.textfield.setMaxStringLength(300);
this.textfield.setFocused(true);
this.factory = new ChatterBotFactory();
try {
this.bot = this.factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
this.bot_session = this.bot.createSession();
} catch (Exception e) {
e.printStackTrace();
}
this.buttonList.add(new GuiButton(42, this.width / 4, this.height - 40, this.width / 2, 20, ChatColor.RESET + "Say"));
}
示例2: execute
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
@Override
public void execute(GnarMessage message, String[] args)
{
try
{
if (bot == null)
{
bot = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
session = bot.createSession();
message.reply("Pandora-Bot session created for the server.");
}
String input = StringUtils.join(args, " ");
String output = session.think(input);
message.replyRaw("**[PandoraBot]** ─ `" + output + "`");
}
catch (Exception e)
{
message.reply("PandoraBot has encountered an exception. Resetting PandoraBot.");
bot = null;
}
}
示例3: execute
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
@Override
public void execute(GnarMessage message, String[] args)
{
try
{
if (!sessionMap.containsKey(message.getAuthor()))
{
ChatterBot bot = factory.create(ChatterBotType.CLEVERBOT);
sessionMap.put(message.getAuthor(), bot.createSession());
}
message.replyRaw(sessionMap.get(message.getAuthor()).think(StringUtils.join(args, " ")));
}
catch (Exception e)
{
message.reply("Chat Bot encountered an exception. Restarting. `:[`");
sessionMap.remove(message.getAuthor());
}
}
示例4: execute
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
@Override
public void execute(GnarMessage message, String[] args)
{
try
{
if (bot == null)
{
bot = factory.create(ChatterBotType.CLEVERBOT);
session = bot.createSession();
message.reply("Clever-Bot session created for the server.");
}
String input = StringUtils.join(args, " ");
String output = session.think(input);
message.replyRaw("**[CleverBot]** ─ `" + output + "`");
}
catch (Exception e)
{
message.reply("CleverBot has encountered an exception. Resetting CleverBot.");
bot = null;
}
}
示例5: talkToSelf
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public String talkToSelf(String input) {
try {
ChatterBot bot1 = factory.create(ChatterBotType.CLEVERBOT);
ChatterBotSession bot1session = bot1.createSession();
ChatterBot bot2 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
ChatterBotSession bot2session = bot2.createSession();
while (continueToTalkToSelf) {
System.out.println("bot1> " + input);
input = bot2session.think(input);
log.info(input);
System.out.println("bot2> " + input);
log.info(input);
input = bot1session.think(input);
}
} catch (Exception e) {
Logging.logError(e);
}
return input;
}
示例6: handle
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
private void handle(ChatMessage message) throws Exception {
if (!CHATBOT_TROLL) {
try {
String[] args = message.getContent().split(" ");
if (commands.containsKey(args[0])) {
String response = commands.get(args[0]).command(message, Arrays.copyOfRange(args, 1, args.length));
if (response == null) return;
Keyboard.type(response);
if (DEBUG) System.out.println(response);
}
} catch (SkypeException e) {
System.out.println("invalid message " + message);
e.printStackTrace();
}
} else {
ChatterBotSession bot;
if (!cleverBots.containsKey(message.getSenderId()))
cleverBots.put(message.getSenderId(), botFactory.create(ChatterBotType.CLEVERBOT).createSession());
bot = cleverBots.get(message.getSenderId());
Keyboard.type(bot.think(
message.
getContent()));
}
}
示例7: talkToSelf
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public String talkToSelf(String input) {
try {
ChatterBot bot1 = factory.create(ChatterBotType.CLEVERBOT);
ChatterBotSession bot1session = bot1.createSession();
ChatterBot bot2 = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
ChatterBotSession bot2session = bot2.createSession();
while (continueToTalkToSelf) {
System.out.println("bot1> " + input);
input = bot2session.think(input);
log.info(input);
System.out.println("bot2> " + input);
log.info(input);
input = bot1session.think(input);
}
} catch (Exception e) {
Logging.logError(e);
}
return input;
}
示例8: CleverBot
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public CleverBot() {
try {
cleverBotSession = getChatFactory()
.create(ChatterBotType.CLEVERBOT)
.createSession();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Failed to build clever bot");
}
}
示例9: PandoraBot
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public PandoraBot() {
try {
pandoraBotSession = getChatFactory()
.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477")
.createSession();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Failed to build pandora bot");
}
}
示例10: createClever
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
private ChatterBot createClever() {
try {
return new ChatterBotFactory()
.create(ChatterBotType.CLEVERBOT, sentryProperties.getDiscord().getCleverBotApiKey());
} catch (Exception e) {
log.warn("Could not create CleverBot session", e);
}
return null;
}
示例11: setAi
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public void setAi(Chat chat, String id) {
if(sessions.containsKey(chat)) {
clearChat(chat);
}
Core.send(chat, "Creating new bot with AI-ID " + id);
try {
bots.put(chat, factory.create(ChatterBotType.PANDORABOTS, id));
sessions.put(chat, bots.get(chat).createSession());
} catch (Exception e) {
Core.send(chat, "Error: " + e.getMessage());
return;
}
Core.send(chat, "Session created");
}
示例12: createBotSessions
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
/**
* Creates Bot and the Bot Session.
* Uses CleverBot.
*/
private void createBotSessions() {
try {
bot = botFactory.create(ChatterBotType.CLEVERBOT);
botSession = bot.createSession();
} catch (Exception e) {
interrupt();
}
}
示例13: CleverbotSession
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public CleverbotSession() throws Exception
{
JSONObject json = new JSONObject(Util.getFileContents("config.json"));
ChatterBotFactory factory = new ChatterBotFactory();
ChatterBot bot = factory.create(ChatterBotType.CLEVERBOT, json.getString("cleverbotAPIKey"));
session = bot.createSession(Locale.ENGLISH);
}
示例14: init
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public boolean init() {
try {
factory = new ChatterBotFactory();
// chatterbot = factory.create(type);
chatterbot = factory.create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
// chatterbot = factory.create(ChatterBotType.CLEVERBOT);
session = chatterbot.createSession();
} catch (Exception e) {
Logging.logError(e);
}
return true;
}
示例15: CommandCleverbot
import com.google.code.chatterbotapi.ChatterBotType; //导入依赖的package包/类
public CommandCleverbot() {
try {
bot = new ChatterBotFactory().create(ChatterBotType.CLEVERBOT).createSession();
} catch (Exception e) {
e.printStackTrace();
}
}