Example #1
1
 public void botChat()
 {
     chatBot = new Bot();
     chatBot.loadSettings();
     chatUser = new User(talkingTo, chatBot);
     chatBot.loadAIMLFromFiles();
     chatBot.isAcceptingUserInput = true;
 }
Example #2
0
 static void Main(string[] args)
 {
     AIMLbot.Bot chatBot;
     AIMLbot.User chatUser;
     string channel = args[0];
     string rnick = args[1];
     string rmsg = args[2];
     try
     {
     if (rmsg.StartsWith("!") == false)
     {
     string query = rmsg;
     ObsidianFunctions.Functions ObsidFunc = new ObsidianFunctions.Functions();
     chatBot = new AIMLbot.Bot();
     chatBot.loadSettings();
     chatUser = new AIMLbot.User(rnick, chatBot);
     chatBot.loadAIMLFromFiles();
     chatBot.isAcceptingUserInput = true;
     AIMLbot.Request r = new AIMLbot.Request(query, chatUser, chatBot);
     AIMLbot.Result res = chatBot.Chat(r);
     Console.WriteLine("PRIVMSG " + rnick + " :" + res.Output);
     }
     }
     catch (Exception ex)
     {
     Console.WriteLine("PRIVMSG " + rnick + " :" + ex.ToString());
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            string settingsPath = Path.Combine(Environment.CurrentDirectory, Path.Combine("config", "Settings.xml"));

            Bot myBot = new Bot();
            myBot.loadSettings(settingsPath);
            User myUser = new User("consoleUser", myBot);
            myBot.isAcceptingUserInput = false;
            myBot.loadAIMLFromFiles();
            myBot.isAcceptingUserInput = true;
            while (true)
            {
                Console.Write("You: ");
                string input = Console.ReadLine();
                if (input.ToLower() == "quit")
                {
                    break;
                }
                else
                {
                    Request r = new Request(input, myUser, myBot);
                    Result res = myBot.Chat(r);
                    Console.WriteLine("Bot: " + res.Output);
                }
            }
        }
Example #4
0
        public void InitAI()
        {
            string aimlDirectory = Application.StartupPath.ToString(CultureInfo.CurrentCulture);

            //string confdir = aimlDirectory + "\\config\\";
            aimlDirectory += "\\aiml\\";

            bool direxists = DirExists(aimlDirectory);

            if (direxists)
            {
                myBot = null;
                //GC.Collect();
                //myBot = new AIMLbot.Bot();
                ////string a1 = myBot.PathToAIML;
                ////string a2 = myBot.PathToConfigFiles;
                //myBot.isAcceptingUserInput = false;
                //myBot.loadSettings();
                //myBot.loadAIMLFromFiles();

                //myBot.isAcceptingUserInput = true;

                //AIMLbot.Utils.SettingsDictionary dic = myBot.Substitutions;

                myBot = new AIMLbot.Bot();
                myBot.loadSettings();
                myBot.loadAIMLFromFiles();
                myBot.isAcceptingUserInput = true;
            }
            else
            {
                Logger.Log("AI is enabled but AI libraries are not installed.", Helpers.LogLevel.Warning);
            }
        }
Example #5
0
    void Start()

    {
        //  Debug.Log("aaaaa");
        LogSystem.InstallDefaultReactors();

        //  Create credential and instantiate service
        Credentials credentials = new Credentials("c20a3f60-9df3-4d5b-86e5-027ccde5c42c", "mnCUwtXFpNSl", "https://gateway.watsonplatform.net/conversation/api");

        _conversation             = new Conversation(credentials);
        _conversation.VersionDate = _conversationVersionDate;

        bot     = new AIMLbot.Bot();
        user    = new AIMLbot.User("User", bot);
        request = new AIMLbot.Request("", user, bot);
        result  = new AIMLbot.Result(user, bot, request);
        bot.loadSettings(Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
        // Load AIML files from AIML path defined in Settings.xml
        bot.loadAIMLFromFiles();
        if (bot != null)
        {
            bot.UseJavaScript = true;
        }


        //   TextToSpeechMark ttsm = gameObject.GetComponent<TextToSpeechMark>();
        //  AskQuestion();
    }
Example #6
0
        static void Main(string[] args)
        {
            AIMLbot.Bot  chatBot;
            AIMLbot.User chatUser;
            string       channel = args[0];
            string       rnick   = args[1];
            string       rmsg    = args[2];

            try
            {
                if (rmsg.StartsWith("!") == false)
                {
                    string query = rmsg;
                    ObsidianFunctions.Functions ObsidFunc = new ObsidianFunctions.Functions();
                    chatBot = new AIMLbot.Bot();
                    chatBot.loadSettings();
                    chatUser = new AIMLbot.User(rnick, chatBot);
                    chatBot.loadAIMLFromFiles();
                    chatBot.isAcceptingUserInput = true;
                    AIMLbot.Request r   = new AIMLbot.Request(query, chatUser, chatBot);
                    AIMLbot.Result  res = chatBot.Chat(r);
                    Console.WriteLine("PRIVMSG " + rnick + " :" + res.Output);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("PRIVMSG " + rnick + " :" + ex.ToString());
            }
        }
Example #7
0
        private static async void BotOnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            Bot.Types.Message msg = e.Message;

            if (msg == null)
            {
                return;
            }

            if (msg.Type == Bot.Types.Enums.MessageType.TextMessage)
            {
                AIMLbot.Bot AI = new AIMLbot.Bot();

                AI.loadSettings(); // This loads the settings from the config folder

                AI.loadAIMLFromFiles();

                AIMLbot.User me_aiml = new AIMLbot.User("dd", AI);

                Request r   = new Request(msg.Text, me_aiml, AI);
                Result  res = AI.Chat(r);
                string  s   = res.ToString();
                await bot.SendTextMessageAsync(msg.Chat.Id, s);
            }

            //if (msg.Type == Bot.Types.Enums.MessageType.TextMessage)
            //{
            //    //await bot.SendTextMessageAsync(msg.Chat.Id, "Здарова " + msg.From.FirstName
            //}
        }
Example #8
0
    /// <summary>
    /// Initialize our derived MonoBehaviour
    /// </summary>
    void Start()
    {
        // Initialize Program # variables
// For Webplayer plattform and WebGl
#if (UNITY_WEBPLAYER || UNITY_WEBGL)
        ProgramSharpWebplayerCoroutine WebplayerCoroutine = this.gameObject.GetComponent <ProgramSharpWebplayerCoroutine>();
        if (WebplayerCoroutine != null)
        {
            bot = new AIMLbot.Bot(WebplayerCoroutine, Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
        }
        else
        {
            Debug.LogWarning("You need to attatch the Webplayer Component in Webplayer plattform mode.");
        }
// Other plattforms
#else
        // Only for Windows, Linux and Mac OSX
        bot = new AIMLbot.Bot();
#endif
        user    = new AIMLbot.User("User", bot);
        request = new AIMLbot.Request("", user, bot);
        result  = new AIMLbot.Result(user, bot, request);
// Only for Windows, Linux, Mac OSX Android and IOS
#if !(UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_ANDROID || UNITY_IOS)
        // Load Settings from Xml file in config directory. Plattform dependend Path issues may
        // occur.
        bot.loadSettings(Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
        // Load AIML files from AIML path defined in Settings.xml
        bot.loadAIMLFromFiles();
#endif
// Android and IOS release
#if (UNITY_ANDROID || UNITY_IOS)
        // Load Settings from Xml file in config directory within resources folder.
        bot.loadSettings("Chatbot/Program #/config/Settings");
        // Load AIML files from AIML path defined in Settings.xml
        bot.loadAIMLFromFiles();
#endif
        // Define to or not to use JavaScript (Jurassic) in AIML
        if (bot != null)
        {
            bot.UseJavaScript = true;
        }
    }
Example #9
0
        private void ReloadBtn_Click(object sender, RoutedEventArgs e)
        {
            bot = new AIMLbot.Bot();
            bot.loadSettings();
            bot.isAcceptingUserInput = false;
            bot.loadAIMLFromFiles();
            bot.isAcceptingUserInput = true;
            user = new User("Уважаемый", bot);

            user.Predicates.addSetting("favouriteanimal", "default");
            user.Predicates.addSetting("name", "default");
        }
Example #10
0
        private Dictionary<string, User> _users; // The people chatting to this bot

        #endregion Fields

        #region Constructors

        public AimlChatProvider(string ownerFirstName)
        {
            System.Console.WriteLine("[AILMCharProvider] CHAT:STARTLISTENING, CHAT:STOPLISTENING, CHAT:RELOAD_NLP are acceptable commands from client chat channel.");
            _bot = new AimlBot();
            _bot.loadSettings();
            _bot.isAcceptingUserInput = false;
            _bot.loadAIMLFromFiles();

            _bot.isAcceptingUserInput = true;

            _users = new Dictionary<string, User>();
            _chatActive = false;
            _ownerFirstName = ownerFirstName;
        }
Example #11
0
        static void getOutput(String input)
        {
            Bot myBot = new Bot();
            User myUser = new User("consoleUser", myBot);

                 myBot.loadSettings();
             myBot.isAcceptingUserInput = false;
             myBot.loadAIMLFromFiles();
             myBot.isAcceptingUserInput = true;

             Request r = new Request(input, myUser, myBot);
             Result res = myBot.Chat(r);
             Console.WriteLine("Bot: " + res.Output);
        }
Example #12
0
 /// <summary>
 /// Initialize our derived MonoBehaviour
 /// </summary>
 void Start()
 {
     CommText     = GameObject.Find("CommText").GetComponent <Text>();
     ResponseText = GameObject.Find("ResponseText").GetComponent <Text>();
     bot          = new AIMLbot.Bot();
     user         = new AIMLbot.User("User", bot);
     request      = new AIMLbot.Request("", user, bot);
     result       = new AIMLbot.Result(user, bot, request);
     bot.loadSettings(Application.dataPath + "/Chatbot/Program #/config/Settings.xml");
     bot.loadAIMLFromFiles();
     if (bot != null)
     {
         bot.UseJavaScript = true;
     }
 }
 //
 public void do_first()
 {
     Bot myBot = new Bot();
     const string UserId = "Team Atlas";
     myBot.loadSettings();
     User myUser = new User(UserId, myBot);
     myBot.isAcceptingUserInput = false;
     myBot.loadAIMLFromFiles();
     myBot.isAcceptingUserInput = true;
     setBot(myBot);
     setUser(myUser);
     //nick : creating Speech Synthesizer events
     sSynth.SetOutputToDefaultAudioDevice();
     sSynth.SpeakStarted += new EventHandler<SpeakStartedEventArgs>(synth_SpeakStarted);
     sSynth.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(synth_SpeakCompleted);
     //
 }
Example #14
0
        public MainWindow()
        {
            InitializeComponent();

            asyncWorker         = new BackgroundWorker();
            asyncWorker.DoWork += launchWorkerAsync;

            bot = new AIMLbot.Bot();
            bot.loadSettings();
            bot.isAcceptingUserInput = false;
            bot.loadAIMLFromFiles();
            bot.isAcceptingUserInput = true;
            user = new User("Уважаемый", bot);

            user.Predicates.addSetting("favouriteanimal", "default");
            user.Predicates.addSetting("name", "default");

            Config.current = Config.LoadFromJson(Path.Combine("..", "..", "config.json"));
            generator      = new ImageProcessor();
            initNet();
            net.LoadFromJson(Path.Combine("..", "..", "bot.json"));
        }
Example #15
0
        public static bool LoadFromFile(string file, out Bot bot)
        {
            bot = null;
            if (!file.EndsWith(".xml") | !File.Exists(file))
            {
                return(false);
            }
            string directory     = Path.GetDirectoryName(Path.GetFullPath(file));
            string aimldirectory = Path.Combine(directory, "aiml");

            bot = new Bot();
            bot.isAcceptingUserInput = false;
            bot.loadSettings(file);
            bot.DefaultPredicates.loadSettings(directory + "\\DefaultPredicates.xml");
            bot.GenderSubstitutions.loadSettings(directory + "\\GenderSubstitutions.xml");
            bot.Person2Substitutions.loadSettings(directory + "\\Person2Substitutions.xml");
            bot.PersonSubstitutions.loadSettings(directory + "\\PersonSubstitutions.xml");
            bot.loadSplitters(directory + "\\Splitters.xml");
            bot.Substitutions.loadSettings(directory + "\\Substitutions.xml");
            bot.loadAIMLFromFiles(aimldirectory);
            bot.isAcceptingUserInput = true;
            return(true);
        }
Example #16
0
 static void Main(string[] args)
 {
     Bot myBot = new Bot();
     myBot.loadSettings();
     User myUser = new User("consoleUser", myBot);
     myBot.isAcceptingUserInput = false;
     myBot.loadAIMLFromFiles();
     myBot.isAcceptingUserInput = true;
     while (true)
     {
         Console.Write("You: ");
         string input = Console.ReadLine();
         if (input.ToLower() == "quit")
         {
             break;
         }
         else
         {
             Request r = new Request(input, myUser, myBot);
             Result res = myBot.Chat(r);
             Console.WriteLine("Bot: " + res.Output);
         }
     }
 }
Example #17
0
        public void InitAI()
        {
            string aimlDirectory = Application.StartupPath.ToString(CultureInfo.CurrentCulture);
            //string confdir = aimlDirectory + "\\config\\";
            aimlDirectory += "\\aiml\\";

            bool direxists = DirExists(aimlDirectory);

            if (direxists)
            {
                myBot = null;
                //GC.Collect();
                //myBot = new AIMLbot.Bot();
                ////string a1 = myBot.PathToAIML;
                ////string a2 = myBot.PathToConfigFiles;
                //myBot.isAcceptingUserInput = false;
                //myBot.loadSettings();
                //myBot.loadAIMLFromFiles();

                //myBot.isAcceptingUserInput = true;

                //AIMLbot.Utils.SettingsDictionary dic = myBot.Substitutions;

                myBot = new AIMLbot.Bot();
                myBot.loadSettings();
                myBot.loadAIMLFromFiles();
                myBot.isAcceptingUserInput = true;
            }
            else
            {
                Logger.Log("AI is enabled but AI libraries are not installed.", Helpers.LogLevel.Warning);
            }
        }
        /// <summary>
        /// Create a converter for the specified XML file
        /// </summary>
        /// <param name="xmlFilename"></param>
        public QueryHandler(FeatureGraph graph, List<TemporalConstraint> myTemporalConstraintList)
        {
            // Load the AIML Bot
            this.bot = new Bot();
            this.temporalConstraintList = myTemporalConstraintList;
            bot.loadSettings();
            bot.isAcceptingUserInput = false;
            bot.loadAIMLFromFiles();
            bot.isAcceptingUserInput = true;
            this.user = new User("user", this.bot);

            // Load the Feature Graph
            this.graph = graph;

            // Feature Names, with which to index the graph
            this.features = graph.getFeatureNames();

            this.turn = 1;
            this.topic = null;

            //Build lists of equivalent relationships
            //is, are, was, is a kind of, is a
            equivalent_relationships.Add(new List<string>() { "is", "are", "was", "is a kind of", "is a" });
            //was a member of, is a member of
            equivalent_relationships.Add(new List<string>() { "was a member of", "is a member of" });
            //won a gold medal in, won
            equivalent_relationships.Add(new List<string>() { "won a gold medal in", "won" });
            //is one of, was one of the, was one of
            equivalent_relationships.Add(new List<string>() { "is one of", "was one of the", "was one of" });
            //include, includes, included
            equivalent_relationships.Add(new List<string>() { "include", "includes", "included" });
            //took place on
            equivalent_relationships.Add(new List<string>() { "took place on" });
            //took place at
            equivalent_relationships.Add(new List<string>() { "took place at" });
            //has, had
            equivalent_relationships.Add(new List<string>() { "has", "had" });
            //includes event
            equivalent_relationships.Add(new List<string>() { "includes event" });
            //includes member, included member
            equivalent_relationships.Add(new List<string>() { "includes member", "included member" });
            //include athlete
            equivalent_relationships.Add(new List<string>() { "include athlete" });
            //is southwest of, is southeast of, is northeast of, is north of,
            //is west of, is east of, is south of, is northwest of
            equivalent_relationships.Add(new List<string>() { "is southwest of", "is southeast of"
                , "is northeast of", "is north of", "is west of", "is east of", "is south of", "is northwest of" });

            //Build list of filter nodes.
            //Each filter node is identified by its Data values in the XML
            filter_nodes.Add("Male");
            filter_nodes.Add("Female");
            filter_nodes.Add("Cities");
            filter_nodes.Add("Sports");
            filter_nodes.Add("Gold Medallists");
            filter_nodes.Add("Venues");
            filter_nodes.Add("Time");
            filter_nodes.Add("Aug. 8th, 2008");
            filter_nodes.Add("Aug. 24th, 2008");
            filter_nodes.Add("Aug. 9th, 2008");
            filter_nodes.Add("Aug. 10th, 2008");
            filter_nodes.Add("Aug. 11th, 2008");
            filter_nodes.Add("Aug. 12th, 2008");
            filter_nodes.Add("Aug. 13th, 2008");
            filter_nodes.Add("Aug. 14th, 2008");
            filter_nodes.Add("Aug. 15th, 2008");
            filter_nodes.Add("Aug. 16th, 2008");
            filter_nodes.Add("Aug. 17th, 2008");
            filter_nodes.Add("Aug. 18th, 2008");
            filter_nodes.Add("Aug. 19th, 2008");
            filter_nodes.Add("Aug. 20th, 2008");
            filter_nodes.Add("Aug. 21st, 2008");
            filter_nodes.Add("Aug. 22nd, 2008");
            filter_nodes.Add("Aug. 23rd, 2008");

            //Build list of relationships which should not be used in analogies.
            no_analogy_relationships.Add("occurred before");
            no_analogy_relationships.Add("occurred after");
            no_analogy_relationships.Add("include");
            no_analogy_relationships.Add("includes");
            no_analogy_relationships.Add("included");
            no_analogy_relationships.Add("has");
            no_analogy_relationships.Add("had");
        }
        public override void Init()
        {
            myAimlBot = new Bot();
            myAimlBot.loadSettings();
            myAimlBot.isAcceptingUserInput = false;
            myAimlBot.loadAIMLFromFiles();
            myAimlBot.isAcceptingUserInput = true;

            base.Init();
        }
Example #20
0
        async void do_work(object sender, DoWorkEventArgs e)
        {
            var worker = sender as BackgroundWorker;
            var key    = e.Argument as String;

            try
            {
                var bot = new Telegram.Bot.TelegramBotClient(key);
                await bot.SetWebhookAsync("");

                AIMLbot.Bot lazy = new AIMLbot.Bot();


                lazy.loadSettings();
                lazy.loadAIMLFromFiles();
                lazy.isAcceptingUserInput = false;
                AIMLbot.User us = new AIMLbot.User("Username", lazy);
                lazy.isAcceptingUserInput = true;


                bot.OnCallbackQuery += async(object sc, Telegram.Bot.Args.CallbackQueryEventArgs ev) =>
                {
                    Telegram.Bot.Types.FileToSend s;
                    var message = ev.CallbackQuery.Message;
                    if (ev.CallbackQuery.Data == "callback1")
                    {
                        s = new Telegram.Bot.Types.FileToSend("https://i.pinimg.com/originals/f7/e9/80/f7e980c9700c8395535b835e66f02a59.jpg");
                    }
                    else if (ev.CallbackQuery.Data == "callback2")
                    {
                        s = new Telegram.Bot.Types.FileToSend("https://static.independent.co.uk/s3fs-public/thumbnails/image/2012/02/29/22/pg-28-sloth-cooke.jpg");
                    }
                    await bot.SendPhotoAsync(message.Chat.Id, s, "Sure! But... not today :)");

                    await bot.AnswerCallbackQueryAsync(ev.CallbackQuery.Id);
                };

                bot.OnUpdate += async(object su, Telegram.Bot.Args.UpdateEventArgs evu) =>
                {
                    if (evu.Update.CallbackQuery != null || evu.Update.InlineQuery != null)
                    {
                        return;
                    }
                    var update  = evu.Update;
                    var message = update.Message;
                    if (message == null)
                    {
                        return;
                    }
                    if (message.Type == Telegram.Bot.Types.Enums.MessageType.TextMessage)
                    {
                        if (message.Text[0] == '/')
                        {
                            if (message.Text == "/test")
                            {
                                await bot.SendTextMessageAsync(message.Chat.Id, "Yeah...",
                                                               replyToMessageId : message.MessageId);
                            }

                            if (message.Text == "/sleep")
                            {
                                var s = new Telegram.Bot.Types.FileToSend("https://beano-uploads-production.imgix.net/store/f4046f22dffe92e3f2167accb6942f788159d0f979f970dcda59f1d0e529?auto=compress&w=752&h=423&fit=min");
                                await bot.SendPhotoAsync(message.Chat.Id,
                                                         s, "Yeeeeeeeeeah, sleeeeeeeeep!");
                            }

                            if (message.Text == "/song")
                            {
                                var s = new Telegram.Bot.Types.FileToSend("http://store.naitimp3.ru/download/0/cGR1a0tRTWJwZW8wMlI2aitkT1UzVkxNdXE2dUNiRTAvcGRkeGphMTVFVTdQcGFURWlFOFQyUGZFTXJ6UVo4cWxVSUNza2NOQUpoZkJOU2ozYTJhWUpLSVdiUTRTanQrVmZnN1hQV1U5Tkk9/eels_i_need_some_sleep_(NaitiMP3.ru).mp3");
                                await bot.SendAudioAsync(message.Chat.Id, s, "", 4, "Eels", "I need some sleep...");
                            }

                            if (message.Text == "/work")
                            {
                                var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(
                                    new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardButton[][]
                                {
                                    // First row
                                    new [] {
                                        // First column
                                        new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardCallbackButton("Work", "callback1"),

                                        // Second column
                                        new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardCallbackButton("Work harder", "callback2")
                                    },
                                }
                                    );

                                await bot.SendTextMessageAsync(message.Chat.Id, "Hmmmm... What should I do?..!", Telegram.Bot.Types.Enums.ParseMode.Default, false, false, 0, keyboard);
                            }
                        }
                        else if ((message.Text[0] >= 'а' && message.Text[0] <= 'я') || (message.Text[0] >= 'А' && message.Text[0] <= 'Я'))
                        {
                            await bot.SendTextMessageAsync(message.Chat.Id, "I'm too lazy to learn russian, sorry...",
                                                           replyToMessageId : message.MessageId);
                        }
                        else
                        {
                            AIMLbot.Request r   = new AIMLbot.Request(message.Text, us, lazy);
                            AIMLbot.Result  res = lazy.Chat(r);

                            await bot.SendTextMessageAsync(message.Chat.Id, res.Output,
                                                           replyToMessageId : message.MessageId);
                        }
                    }
                };

                bot.StartReceiving();
            }
            catch (Telegram.Bot.Exceptions.ApiRequestException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #21
0
 public void beginChat(Dictionary<String, dynamic> myDic)
 {
     if (General.s.permission.ContainsKey(myDic["user"]) && (General.s.permission[myDic["user"]] >= 2))
     {
         String tmp = (((String) myDic["text"]).Replace("*beginChat:", "")).Trim();
         AIMLbot.Bot bot = new Bot();
         General.sc.SendMessage(myDic["channel"],
             "Loading...." + Helper.GetApplicationPath() + "/" + tmp + "_config/Settings.xml");
         bot.loadSettings(Helper.GetApplicationPath() + "/" + tmp + "_config/Settings.xml");
         bot.loadAIMLFromFiles();
         AIMLbot.User user = new AIMLbot.User(myDic["user"], bot);
         General.active_users.Add(tmp, user);
         General.sc.SendMessage(myDic["channel"], "It begun!");
     }
     else
     {
         General.sc.SendMessage(myDic["channel"], "Insufficient permission!");
     }
 }