Esempio n. 1
1
 public void botChat()
 {
     chatBot = new Bot();
     chatBot.loadSettings();
     chatUser = new User(talkingTo, chatBot);
     chatBot.loadAIMLFromFiles();
     chatBot.isAcceptingUserInput = true;
 }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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();
    }
Esempio n. 4
0
        //methods
        public bool initialize_iBOT()
        {
            //initialize bot
            bot = new Bot();
            bot.loadSettings(); //TODO: change settings.xml in config

            //user settings
            user = new User("DefaultUser", this.bot);

            //Log writer event setting
            bot.WrittenToLog += new Bot.LogMessageDelegate(bot_Log);

            //Initialize the bot's Mind
            try
            {
                AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.bot);
                this.bot.isAcceptingUserInput = false;
                loader.loadAIML(AIMLSourcePath);
                this.bot.isAcceptingUserInput = true;
            }
            catch (Exception ex)
            {
                ExceptionMsgs += DateTime.Now.ToString() + ">> " + ex.Message + Environment.NewLine;
                return false;
            }
            //the bot is ready to serve!
            initialized = true;
            return true;
        }
Esempio n. 5
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());
     }
 }
Esempio n. 6
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
            //}
        }
Esempio n. 7
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());
            }
        }
Esempio n. 8
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);
                }
            }
        }
Esempio n. 9
0
 public Form1()
 {
     InitializeComponent();
     _myBot = new Bot();
     _myBot.loadSettings();
     _myUser = new User("consoleUser", _myBot);
     _synth = new SpeechSynthesizer();
 }
Esempio n. 10
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;
        }
    }
Esempio n. 11
0
 public aimlForm()
 {
     InitializeComponent();
     this.toolStripMenuItemSpeech.Checked = true;
     this.richTextBoxInput.Focus();
     myBot = new Bot();
     myBot.loadSettings();
     myUser = new User("DefaultUser",this.myBot);
     myBot.WrittenToLog += new Bot.LogMessageDelegate(myBot_WrittenToLog);
 }
Esempio n. 12
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");
        }
        public MainWindow()
        {
            bot = new Bot();
            user = new User("DefaultUser", bot);
            bot.loadSettings();
            AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(bot);
            bot.isAcceptingUserInput = false;
            loader.loadAIML(bot.PathToAIML);
            bot.isAcceptingUserInput = true;

            InitializeComponent();
        }
Esempio n. 14
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);
        }
Esempio n. 15
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;
        }
Esempio n. 16
0
        public string Ask(string name, string question)
        {
            var sharpBot = new Bot();
            sharpBot.loadSettings(SettingsPath);
            var loader = new AIMLbot.Utils.AIMLLoader(sharpBot);
            loader.loadAIML(aimlPath);
            sharpBot.isAcceptingUserInput = false;
            sharpBot.isAcceptingUserInput = true;

            var patient = new User(name, sharpBot);
            var request = new Request(question, patient, sharpBot);
            var answer = sharpBot.Chat(request);
            return answer.Output;
        }
Esempio n. 17
0
 private static Bot InstantiateBot()
 {
     var bot = new Bot
     {
         IsAcceptingUserInput = false
     };
     bot.loadSettings();
     var combine = Path.Combine(ConfigurationManager.AppSettings.Get("aimldirectory"), "Bot.bin");
     if (File.Exists(combine))
         bot.LoadFromBinaryFile(combine);
     else 
         bot.LoadAimlFromFiles();
     bot.IsAcceptingUserInput = true;
     return bot;
 }
Esempio n. 18
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;
     }
 }
Esempio n. 19
0
        public chat()
        {
            chat_time.AutoReset = false;
            chat_time.Elapsed += stop_chat;
            chat_time.Enabled = false;

            still_chatting = false;
            chatting_nick = new List<string>();
            myBot = new Bot();
            myBot.loadSettings();
            myUser = new User("chat_nick", myBot);

            AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(myBot);
            myBot.isAcceptingUserInput = false;
            loader.loadAIML(myBot.PathToAIML);
            myBot.isAcceptingUserInput = true;
        }
Esempio n. 20
0
        public chat()
        {
            chat_time.AutoReset = false;
            chat_time.Elapsed  += stop_chat;
            chat_time.Enabled   = false;

            still_chatting = false;
            chatting_nick  = new List <string>();
            myBot          = new AIMLbot.Bot();
            myBot.loadSettings(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "modules" + Path.DirectorySeparatorChar + "chat" + Path.DirectorySeparatorChar + "Settings.xml");
            myUser = new User("chat_nick", myBot);

            AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(myBot);
            myBot.isAcceptingUserInput = false;
            loader.loadAIML(myBot.PathToAIML);
            myBot.isAcceptingUserInput = 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);
     //
 }
Esempio n. 22
0
 public ChatRobotOperator(string userName)
 {
     bot = new Bot();
     bot.loadSettings();
     user = new User(userName, bot);
     //try
     //{
         AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(bot);
         bot.isAcceptingUserInput = false;
         loader.loadAIML(bot.PathToAIML);
         bot.isAcceptingUserInput = true;
     //}
     //catch (Exception ex)
     //{
     //    //this.outputRichTextBox.AppendText(ex.Message + Environment.NewLine);
     //}
 }
Esempio n. 23
0
 private bool LoadALICE()
 {
     try
     {
         Alice = new AIMLbot.Bot();
         Alice.isAcceptingUserInput = false;
         Alice.loadSettings();
         AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(Alice);
         Alice.isAcceptingUserInput = false;
         loader.loadAIML(Alice.PathToAIML);
         Alice.isAcceptingUserInput = true;
         return(true);
     }
     catch (Exception ex)
     {
         System.Console.WriteLine("Failed loading ALICE: " + ex.Message);
         return(false);
     }
 }
Esempio n. 24
0
        public Form2()
        {
            InitializeComponent();
            this.inputTextBox.Focus();
            myBot = new Bot();
            myBot.loadSettings();
            myUser = new User("DefaultUser", this.myBot);
            myBot.WrittenToLog += new Bot.LogMessageDelegate(myBot_WrittenToLog);

            try
            {
                AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(this.myBot);
                this.myBot.isAcceptingUserInput = false;
                loader.loadAIML(this.myBot.PathToAIML);
                this.myBot.isAcceptingUserInput = true;
            }
            catch (Exception ex)
            {
                this.outputRichTextBox.AppendText(ex.Message + Environment.NewLine);
            }
        }
Esempio n. 25
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"));
        }
Esempio n. 26
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);
        }
Esempio n. 27
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);
         }
     }
 }
Esempio n. 28
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);
            }
        }
Esempio n. 29
0
 private void LoadALICE()
 {
     try
     {
         Alice = new AIMLbot.Bot();
         Alice.isAcceptingUserInput = false;
         Alice.loadSettings();
         AIMLbot.Utils.AIMLLoader loader = new AIMLbot.Utils.AIMLLoader(Alice);
         Alice.isAcceptingUserInput = false;
         loader.loadAIML(Alice.PathToAIML);
         Alice.isAcceptingUserInput = true;
     }
     catch (Exception ex)
     {
         System.Console.WriteLine("Failed loading ALICE: " + ex.Message);
     }
 }
        /// <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");
        }
Esempio n. 31
0
        public override void Init()
        {
            myAimlBot = new Bot();
            myAimlBot.loadSettings();
            myAimlBot.isAcceptingUserInput = false;
            myAimlBot.loadAIMLFromFiles();
            myAimlBot.isAcceptingUserInput = true;

            base.Init();
        }
Esempio n. 32
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);
            }
        }
Esempio n. 33
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!");
     }
 }
Esempio n. 34
0
        static void Main(string[] args)
        {
            
            var myBot = new Bot();
            myBot.loadSettings();
            var myUser = new User("consoleUser", myBot);
            myBot.IsAcceptingUserInput = false;
            myBot.LoadAimlFromFiles();
            myBot.IsAcceptingUserInput = true;
            var synth = new SpeechSynthesizer();
            var commandProcessorFactory = new Mock<ICommandProcessorFactory>();
            var innerprocessor = new Mock<ICommandProcessor>();
            
            commandProcessorFactory.Setup(x => x.GetCommandProcessor(It.IsAny<CommandRequest>())).Returns(innerprocessor.Object);
            var processor = new CommandProcessor(commandProcessorFactory.Object, myUser, myBot);
            var results = new[]
            {
                new CommandResult
                {
                    ResultType = CommandResultTypeEnum.Text,
                    Content = "Hello Dude",
                    Pause = 1000
                    
                },
                new CommandResult
                {
                    ResultType = CommandResultTypeEnum.Text,
                    Content = "How are you?"

                },

            };
            var resultQueue = new Queue<CommandResult>(results);
            
            var result = resultQueue.Dequeue();

            while (result != null)
            {
                var sayText = string.Empty;
                switch (result.ResultType)
                {
                    case CommandResultTypeEnum.Text:
                        sayText = result.Content;
                        break;
                    case CommandResultTypeEnum.Bot:
                        var r = new Request(result.Content, myUser, myBot);
                        var res = myBot.Chat(r);
                        sayText = res.Output;
                        break;
                }
                if (!string.IsNullOrEmpty(sayText))
                {
                    Console.WriteLine(sayText);
                    synth.Speak(sayText);
                }
                if (result.WaitInput)
                {
                    var line = Console.ReadLine();
                }
                else if (result.Pause > 0)
                    Thread.Sleep(result.Pause);
                if (resultQueue.Count == 0)
                    break;
                result = resultQueue.Dequeue();
            }
            Console.ReadLine();
        }