当前位置: 首页>>代码示例>>C#>>正文


C# IMessageClient.GetUser方法代码示例

本文整理汇总了C#中IMessageClient.GetUser方法的典型用法代码示例。如果您正苦于以下问题:C# IMessageClient.GetUser方法的具体用法?C# IMessageClient.GetUser怎么用?C# IMessageClient.GetUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMessageClient的用法示例。


在下文中一共展示了IMessageClient.GetUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoExcuseMe

 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));
 }
开发者ID:JonathanStarnes,项目名称:NBot,代码行数:9,代码来源:ExcuseMe.cs

示例2: PageUser

        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);
            }
        }
开发者ID:rjt011000,项目名称:NBot,代码行数:50,代码来源:Pager.cs

示例3: HandleStatusChange

 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);
 }
开发者ID:rjt011000,项目名称:NBot,代码行数:19,代码来源:Status.cs

示例4: SayHello

 public void SayHello(Message message, IMessageClient client)
 {
     var user = client.GetUser(message.UserId);
     client.ReplyTo(message, string.Format(GetRandomItem(_hellos), user.Name));
 }
开发者ID:rjt011000,项目名称:NBot,代码行数:5,代码来源:Hello.cs

示例5: SayGoodMorning

 public void SayGoodMorning(Message message, IMessageClient client)
 {
     var user = client.GetUser(message.UserId);
     client.ReplyTo(message, string.Format(GetRandomItem(_mornings), user.Name));
 }
开发者ID:rjt011000,项目名称:NBot,代码行数:5,代码来源:Hello.cs

示例6: RoomAnnounce

 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);
 }
开发者ID:rjt011000,项目名称:NBot,代码行数:6,代码来源:Announce.cs

示例7: Hear

        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);
        }
开发者ID:rjt011000,项目名称:NBot,代码行数:8,代码来源:Status.cs


注:本文中的IMessageClient.GetUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。