public override void doAction(Comedian bot)
        {
            //Go to Sleep State if bedtime
            if ((bot.WakeTime > bot.SleepTime && (DateTime.Now.TimeOfDay < bot.WakeTime && DateTime.Now.TimeOfDay >= bot.SleepTime)) || (bot.WakeTime < bot.SleepTime && (DateTime.Now.TimeOfDay < bot.WakeTime || DateTime.Now.TimeOfDay >= bot.SleepTime)))
            {
                attentionCounter = ++attentionCounter % 4;

                if (attentionCounter == 0) //8 seconds elapsed
                {
                    //Say Good Night
                    lock (bot.OutgoingMessage)
                    {
                        bot.OutgoingMessage.Enqueue(new ChatMessage(bot.PSource, bot.retrieve(bot.PSource)[0], bot.PSource.MasterAccount, new TextMessage(getAIMLResponse("SayStatementPattern sleepy", getPrimaryUser(bot), bot))));
                    }
                    bot.setNextState(StateFactory.getBotState("Sleep", bot));
                }
            }
            else if ((bot.OffWorkTime > bot.WorkTime && (DateTime.Now.TimeOfDay < bot.OffWorkTime && DateTime.Now.TimeOfDay >= bot.WorkTime)) || (bot.OffWorkTime < bot.WorkTime && (DateTime.Now.TimeOfDay < bot.OffWorkTime || DateTime.Now.TimeOfDay >= bot.WorkTime)))
            {
                attentionCounter = ++attentionCounter % 30;

                if (attentionCounter == 0) //1 minute elapsed
                {
                    //Say Time for Work
                    lock (bot.OutgoingMessage)
                    {
                        bot.OutgoingMessage.Enqueue(new ChatMessage(bot.PSource, bot.retrieve(bot.PSource)[0], bot.PSource.MasterAccount, new TextMessage(getAIMLResponse("SayStatementPattern time for work", getPrimaryUser(bot), bot))));
                    }
                    bot.setNextState(StateFactory.getBotState("Busy", bot));
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Given an input string, return an output from the AIML bot.
        /// </summary>
        /// <param name="input">string</param>
        /// <param name="user">User (so conversations can be tracked by the bot, per user)</param>
        /// <returns>string</returns>
        public string getAIMLResponse(string input, User user, Comedian bot)
        {
            Request r   = new Request(input, user, bot);
            Result  res = bot.Chat(r);

            return(res.Output);
        }
Пример #3
0
 public override void doAction(Comedian bot)
 {
     if ((bot.WakeTime > bot.SleepTime && (DateTime.Now.TimeOfDay >= bot.WakeTime || DateTime.Now.TimeOfDay < bot.SleepTime)) || (bot.WakeTime < bot.SleepTime && (DateTime.Now.TimeOfDay >= bot.WakeTime && DateTime.Now.TimeOfDay < bot.SleepTime)))
     {
         bot.setNextState(StateFactory.getBotState("Greeting", bot));
     }
 }
Пример #4
0
        public override void doAction(Comedian bot)
        {
            lock (bot.OutgoingMessage)
            {
                bot.OutgoingMessage.Enqueue(new ChatMessage(bot.PSource, bot.retrieve(bot.PSource)[0], bot.PSource.MasterAccount, new TextMessage(getAIMLResponse("SayStatementPattern hello", getPrimaryUser(bot), bot))));
            }

            bot.setNextState(StateFactory.getBotState("Available", bot));
        }
Пример #5
0
        public BotState getBotState(string stateName, Comedian bot)
        {
            if (flyweights.ContainsKey(stateName))
            {
                return(flyweights[stateName]);
            }
            //if Flyweight is not found
            else
            {
                BotState newState;

                switch (stateName)
                {
                case "Initiate":
                    newState = new InitiateState();
                    flyweights.Add(stateName, newState);
                    break;

                case "Greeting":
                    newState = new GreetingState();
                    flyweights.Add(stateName, newState);
                    break;

                case "Available":
                    newState = new AvailableState();
                    flyweights.Add(stateName, newState);
                    break;

                case "Busy":
                    newState = new BusyState();
                    flyweights.Add(stateName, newState);
                    break;

                case "Rest":
                    newState = new RestState();
                    flyweights.Add(stateName, newState);
                    break;

                case "Sleep":
                    newState = new SleepState();
                    flyweights.Add(stateName, newState);
                    break;

                default:
                    newState = null;
                    break;
                }

                return(newState);
            }
        }
Пример #6
0
        public override void doAction(Comedian bot)
        {
            restCounter = ++restCounter % 300;

            if (restCounter == 0) //10 minutes elapsed
            {
                //Say Back to Work
                lock (bot.OutgoingMessage)
                {
                    bot.OutgoingMessage.Enqueue(new ChatMessage(bot.PSource, bot.retrieve(bot.PSource)[0], bot.PSource.MasterAccount, new TextMessage(getAIMLResponse("SayStatement Back to work", getPrimaryUser(bot), bot))));
                }
                bot.setNextState(StateFactory.getBotState("Busy", bot));
            }
        }
Пример #7
0
 //Find the user associated to the master account in the primary chat source
 protected User getPrimaryUser(Comedian bot)
 {
     if (bot.PSource.MasterAccount.Owner.Profile != null)
     {
         if (!bot.Users.ContainsKey(bot.PSource.MasterAccount.Owner.Profile.Name))
         {
             bot.Users.Add(bot.PSource.MasterAccount.Owner.Profile.Name, new User(bot.PSource.MasterAccount.Owner.Profile.Name, bot));
         }
         return(bot.Users[bot.PSource.MasterAccount.Owner.Profile.Name]);
     }
     else
     {
         if (!bot.Users.ContainsKey(bot.PSource.MasterAccount.Username))
         {
             bot.Users.Add(bot.PSource.MasterAccount.Username, new User(bot.PSource.MasterAccount.Username, bot));
         }
         return(bot.Users[bot.PSource.MasterAccount.Username]);
     }
 }
Пример #8
0
        public override void doAction(Comedian bot)
        {
            workCounter = ++workCounter % 2700;

            //Time to get off work?
            if ((bot.OffWorkTime > bot.WorkTime && (DateTime.Now.TimeOfDay >= bot.OffWorkTime || DateTime.Now.TimeOfDay < bot.WorkTime)) || (bot.OffWorkTime < bot.WorkTime && (DateTime.Now.TimeOfDay >= bot.OffWorkTime && DateTime.Now.TimeOfDay < bot.WorkTime)))
            {
                bot.setNextState(StateFactory.getBotState("Available", bot));
            }
            //Time for a break from work
            else if (workCounter == 0) //90 minutes elapsed
            {
                if (new Random().Next(0, 2) == 0)
                {
                    bot.setNextState(StateFactory.getBotState("Social", bot));
                }
                else
                {
                    bot.setNextState(StateFactory.getBotState("Rest", bot));
                }
            }
        }
Пример #9
0
 public abstract void doAction(Comedian bot);