Exemplo n.º 1
0
        public void messageReceived()
        {
            var session = CleverbotSession.NewSession("oWBfq3FGSQA8Xo50", "PyQAXcJswt7DsPply9lSq2e1pN0bd1wK");

            myBot.discord.MessageReceived += async(s, e) =>
            {
                if (!e.Message.IsAuthor && e.Message.IsMentioningMe())
                {
                    string msg = e.Message.Text.Replace("@" + myBot.discord.CurrentUser.Name + " ", "").Replace("!", "");
                    foreach (BotCommand cmd in myBot.commands)
                    {
                        if (msg == cmd.getCommand())
                        {
                            return;
                        }
                    }
                    try {
                        await e.Channel.SendIsTyping();

                        await e.Channel.SendMessage(session.Send(msg));
                    }catch (ArgumentException exc)
                    {
                        await e.Channel.SendMessage("Something went wrong with the bot :(");
                    }
                }
            };
        }
Exemplo n.º 2
0
    static void Main()
    {
        string message;
        var    session = CleverbotSession.NewSession("apiUser", "apiKey");

        do
        {
            Console.Write("Type your message: ");
            message = Console.ReadLine();
            Console.Write("Bot: ");
            Console.WriteLine(session.Send(message));
        } while (message.ToLower().Trim() != "exit");
    }
Exemplo n.º 3
0
        public string CallCleverbot()
        {
            string question, answer = "";

            //API User and Pass Keys
            var session = CleverbotSession.NewSession("0VrnWzbEZNTu267C", "SQ6OtXq07kede794AByhwee7pMA6aewT");

            Console.Write("Ask Cleverbot Something:");
            question = Console.ReadLine();
            answer   = session.Send(question);
            Console.WriteLine(answer);

            return(answer);
        }
Exemplo n.º 4
0
 public static void Init()
 {
     if (Bot.Config.CleverbotEnabled)
     {
         IsServiceAvailable = CreateCleverBotSession(Bot.Config.CleverbotNick);
         if (!IsServiceAvailable)
         {
             try
             {
                 cleverBotSession = CleverbotSession.NewSession(Bot.Config.CleverbotAPIUser, Bot.Config.CleverbotAPIKey);
             }
             catch (Exception e)
             {
                 Console.WriteLine("Error while setting up Cleverbot-API...\r\nExceptionMsg: " + e.Message);
             }
         }
     }
 }
Exemplo n.º 5
0
        protected override void OnConfigChanged(string arg, string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return;
            }

            switch (arg)
            {
            case "add":
                var session = CleverbotSession.NewSession(ApiUser, ApiKey);
                Sessions.Add(value, session);
                this[arg]   = null;
                this[value] = session.BotNick;
                break;

            case "remove":
                Sessions.Remove(value);
                this[arg] = null;
                break;
            }
        }
Exemplo n.º 6
0
        public static CleverbotSession createSession()
        {
            var session = CleverbotSession.NewSession(apiUser, apiKey);

            return(session);
        }