Example #1
0
        public void RoomAnnounce(Message message, IMessageClient client, string announcement)
        {
            IEntity user     = client.GetUser(message.UserId);
            string  response = string.Format("{0} says \" {1} \"", user.Name, announcement);

            client.Broadcast(response);
        }
Example #2
0
File: Status.cs Project: NBot/NBot
        public void Hear(Message message, IMessageClient client, IBrain brain)
        {
            string time     = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            string result   = time + " in the room " + message.RoomId;
            var    userName = client.GetUser(message.UserId).Name;

            brain.SetValue(LastSpokeKey(userName), result);
        }
Example #3
0
 public void DoExcuseMe(Message mesage, IMessageClient client)
 {
     IEntity user = client.GetUser(mesage.UserId);
     IRestClient httpClient = GetJsonServiceClient("http://developerexcuses.com/");
     var result = httpClient.Get<string>("/");
     Match matches = Regex.Match(result, "<a href=\"/\" .*>(.*)</a>");
     string excuse = matches.Groups[1].Value;
     client.ReplyTo(mesage, string.Format("{0}, your excuse is \"{1}\".", user.Name, excuse));
 }
Example #4
0
        public void DoExcuseMe(Message mesage, IMessageClient client)
        {
            IEntity     user       = client.GetUser(mesage.UserId);
            IRestClient httpClient = GetJsonServiceClient("http://developerexcuses.com/");
            var         result     = httpClient.Get <string>("/");
            Match       matches    = Regex.Match(result, "<a href=\"/\" .*>(.*)</a>");
            string      excuse     = matches.Groups[1].Value;

            client.ReplyTo(mesage, string.Format("{0}, your excuse is \"{1}\".", user.Name, excuse));
        }
Example #5
0
File: Pager.cs Project: NBot/NBot
        public void PageUser(Message message, IMessageClient client, string name)
        {
            string         regex = string.Format("(.*)({0})(.*)", name);
            List <IEntity> rooms = client.GetAllRooms().ToList();

            string       sentFrom         = client.GetUser(message.UserId).Name;
            IEntity      requestedRoom    = rooms.Single(r => r.Id == message.RoomId);
            const string pageMessage      = "Paging {0} ... Paging {0} ... Your presence is requested by {1} in the \"{2}\" room.";
            const string failureMessage   = "Sorry, nobody by the name {0} could be found.";
            const string userIsInYourRoom = "Lulz!! {0} is in your room.";
            var          roomsUserIsIn    = new List <IEntity>();

            bool hasMatch = false;

            foreach (IEntity room in rooms)
            {
                IEnumerable <IEntity> usersInRoom = client.GetUsersInRoom(room.Id);
                foreach (IEntity user in usersInRoom)
                {
                    if (Regex.IsMatch(user.Name, regex, RegexOptions.IgnoreCase))
                    {
                        roomsUserIsIn.Add(room);
                        string response = string.Format(pageMessage, user.Name, sentFrom, requestedRoom.Name);

                        if (room.Id == requestedRoom.Id)
                        {
                            response = string.Format(userIsInYourRoom, user.Name);
                        }

                        client.Send(response, room.Id);
                        hasMatch = true;
                    }
                }
            }

            if (!hasMatch)
            {
                string response = string.Format(failureMessage, name);
                client.Send(response, requestedRoom.Id);
            }
            else
            {
                var responseMessage = new StringBuilder();
                responseMessage.AppendLine(string.Format("{0}, \"{1}\" was found in the following rooms:", sentFrom, name));

                foreach (IEntity room in roomsUserIsIn)
                {
                    responseMessage.AppendLine(string.Format("- {0}", room.Name));
                }

                client.Send(responseMessage.ToString(), requestedRoom.Id);
            }
        }
Example #6
0
        public void PageUser(Message message, IMessageClient client, string name)
        {
            string regex = string.Format("(.*)({0})(.*)", name);
            List<IEntity> rooms = client.GetAllRooms().ToList();

            string sentFrom = client.GetUser(message.UserId).Name;
            IEntity requestedRoom = rooms.Single(r => r.Id == message.RoomId);
            const string pageMessage = "Paging {0} ... Paging {0} ... Your presence is requested by {1} in the \"{2}\" room.";
            const string failureMessage = "Sorry, nobody by the name {0} could be found.";
            const string userIsInYourRoom = "Lulz!! {0} is in your room.";
            var roomsUserIsIn = new List<IEntity>();

            bool hasMatch = false;
            foreach (IEntity room in rooms)
            {
                IEnumerable<IEntity> usersInRoom = client.GetUsersInRoom(room.Id);
                foreach (IEntity user in usersInRoom)
                {
                    if (Regex.IsMatch(user.Name, regex, RegexOptions.IgnoreCase))
                    {
                        roomsUserIsIn.Add(room);
                        string response = string.Format(pageMessage, user.Name, sentFrom, requestedRoom.Name);

                        if (room.Id == requestedRoom.Id)
                            response = string.Format(userIsInYourRoom, user.Name);

                        client.Send(response, room.Id);
                        hasMatch = true;
                    }
                }
            }

            if (!hasMatch)
            {
                string response = string.Format(failureMessage, name);
                client.Send(response, requestedRoom.Id);
            }
            else
            {
                var responseMessage = new StringBuilder();
                responseMessage.AppendLine(string.Format("{0}, \"{1}\" was found in the following rooms:", sentFrom, name));

                foreach (IEntity room in roomsUserIsIn)
                {
                    responseMessage.AppendLine(string.Format("- {0}", room.Name));
                }

                client.Send(responseMessage.ToString(), requestedRoom.Id);
            }
        }
Example #7
0
 public void HandleStatusChange(Message message, IMessageClient client, IBrain brain, string query)
 {
     string time = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
     //string result = "wut";
     var userName = client.GetUser(message.UserId).Name;
     if (query.ToLower().StartsWith("in"))
     {
         //result = "i recognize " + message.UserId + " checked in at " + time;
         brain.SetValue(LastCheckinKey(userName), time);
         brain.RemoveKey(LastCheckoutKey(userName));
     }
     else if (query.ToLower().StartsWith("out"))
     {
         //result = "i recognize " + message.UserId + " checked out at " + time;
         brain.SetValue(LastCheckoutKey(userName), time);
         brain.RemoveKey(LastCheckinKey(userName));
     }
     //client.ReplyTo(message, result);
 }
Example #8
0
File: Status.cs Project: NBot/NBot
        public void HandleStatusChange(Message message, IMessageClient client, IBrain brain, string query)
        {
            string time = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            //string result = "wut";
            var userName = client.GetUser(message.UserId).Name;

            if (query.ToLower().StartsWith("in"))
            {
                //result = "i recognize " + message.UserId + " checked in at " + time;
                brain.SetValue(LastCheckinKey(userName), time);
                brain.RemoveKey(LastCheckoutKey(userName));
            }
            else if (query.ToLower().StartsWith("out"))
            {
                //result = "i recognize " + message.UserId + " checked out at " + time;
                brain.SetValue(LastCheckoutKey(userName), time);
                brain.RemoveKey(LastCheckinKey(userName));
            }
            //client.ReplyTo(message, result);
        }
Example #9
0
 public void SayHello(Message message, IMessageClient client)
 {
     var user = client.GetUser(message.UserId);
     client.ReplyTo(message, string.Format(GetRandomItem(_hellos), user.Name));
 }
Example #10
0
 public void SayGoodMorning(Message message, IMessageClient client)
 {
     var user = client.GetUser(message.UserId);
     client.ReplyTo(message, string.Format(GetRandomItem(_mornings), user.Name));
 }
Example #11
0
 public IEntity GetUser(string userId)
 {
     return(_innerMessageClient.GetUser(userId));
 }
Example #12
0
 public void RoomAnnounce(Message message, IMessageClient client, string announcement)
 {
     IEntity user = client.GetUser(message.UserId);
     string response = string.Format("{0} says \" {1} \"", user.Name, announcement);
     client.Broadcast(response);
 }
Example #13
0
File: Hello.cs Project: NBot/NBot
        public void SayGoodMorning(Message message, IMessageClient client)
        {
            var user = client.GetUser(message.UserId);

            client.ReplyTo(message, string.Format(GetRandomItem(_mornings), user.Name));
        }
Example #14
0
File: Hello.cs Project: NBot/NBot
        public void SayHello(Message message, IMessageClient client)
        {
            var user = client.GetUser(message.UserId);

            client.ReplyTo(message, string.Format(GetRandomItem(_hellos), user.Name));
        }
Example #15
0
        public void Hear(Message message, IMessageClient client, IBrain brain)
        {
            string time = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            string result = time + " in the room " + message.RoomId;
            var userName = client.GetUser(message.UserId).Name;

            brain.SetValue(LastSpokeKey(userName), result);
        }