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


C# IMessageClient类代码示例

本文整理汇总了C#中IMessageClient的典型用法代码示例。如果您正苦于以下问题:C# IMessageClient类的具体用法?C# IMessageClient怎么用?C# IMessageClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: PityTheFool

        public void PityTheFool(Message message, IMessageClient client, string phrase)
        {
            var pity = GetRandomItem(new List<string>
                {
                    "I Pity The Fool",
                    "Pity The Fool",
                    "Thou Shalt pity the fool",
                    "Pity thee",
                    "Be pitiful for those",
                    "cast pity towards those"
                });

            if (string.IsNullOrEmpty(phrase))
            {
                phrase = GetRandomItem(new List<string>
                    {
                        "who breaks the build",
                        "who doesn't test before check-in",
                        "who is last to the dessert tray",
                        "who doesn't login to campfire",
                        "who isn't nBot"
                    });
            }

            MemeGen(message, client, "1646", "5353", pity, phrase);
        }
开发者ID:rjt011000,项目名称:NBot,代码行数:26,代码来源:MemeGenerator.cs

示例2: XkcdMe

        public void XkcdMe(Message message, IMessageClient client, string number)
        {
            IRestClient jsonClient = GetJsonServiceClient("http://xkcd.com");
            var result = new RootObject();

            string jsonResponse;

            try
            {
                jsonResponse = (string.IsNullOrEmpty(number) || number == "xkcd me")
                    ? jsonClient.Get<string>("/info.0.json")
                    : jsonClient.Get<string>(string.Format("/{0}/info.0.json", number));
            }
            catch (Exception)
            {
                jsonResponse = jsonClient.Get<string>("/1/info.0.json");
            }

            result.Value = JsonObject.Parse(jsonResponse);
            string imgUrl = result.Value.Child("img").Replace("\\", "");
            string altText = result.Value.Child("alt");

            //Reply with two messages back to back
            client.ReplyTo(message, imgUrl);
            client.ReplyTo(message, altText);
        }
开发者ID:JonathanStarnes,项目名称:NBot,代码行数:26,代码来源:Xkcd.cs

示例3: Recieve

 public void Recieve(Message message, IMessageClient client)
 {
     IRestClient httpClient = GetJsonServiceClient("http://facepalm.org");
     var response = httpClient.Get<HttpWebResponse>("/img.php");
     var imageUrl = response.ResponseUri.AbsoluteUri;
     client.ReplyTo(message, imageUrl);
 }
开发者ID:rjt011000,项目名称:NBot,代码行数:7,代码来源:FacePalm.cs

示例4: SearchStackOverflow

        public void SearchStackOverflow(Message message, IMessageClient client, string query)
        {
            try
            {
                var authCode = Robot.GetSetting<string>("StackappsApiKey");

                if (string.IsNullOrEmpty(authCode))
                    throw new ArgumentException("Please supply the StackappsApiKey");

                var result = GetGZipedJsonServiceClient(string.Format("http://api.stackoverflow.com/1.1/search?intitle={0}&key={1}",
                                                                Uri.EscapeDataString(query),
                                                                Uri.EscapeDataString(authCode)))
                                                                .Get<SearchResult>("/");

                if (result.Questions.Any())
                {
                    client.ReplyTo(message, string.Format("Top 5 Search results for: {0}", query));

                    foreach (Question question in result.Questions.OrderByDescending(q => q.answer_count).Take(5))
                    {
                        client.ReplyTo(message, string.Format("{0} responses to: {1} {2}", question.answer_count, question.title, "http://stackoverflow.com" + question.question_answers_url));
                    }
                }
                else
                {
                    client.ReplyTo(message, string.Format("No results found for {0}", query));
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("NBot-Sosearch", ex.ToString());
                client.ReplyTo(message, "Error in searching Stack Overflow.");
            }
        }
开发者ID:rjt011000,项目名称:NBot,代码行数:34,代码来源:Sosearch.cs

示例5: _TimeoutContext

 internal _TimeoutContext(IMessageClient messageClient)
 {
     _session = messageClient.Session;
     _client = messageClient.Client;
     if (log.IsDebugEnabled)
         log.Debug(__Res.GetString(__Res.Context_Initialized, "[not available]", _client != null ? _client.Id : "[not available]", _session != null ? _session.Id : "[not available]"));
 }
开发者ID:RanadeepPolavarapu,项目名称:LoLNotes,代码行数:7,代码来源:_TimeoutContext.cs

示例6: RollDice

        public void RollDice(Message message, IMessageClient client, string sides)
        {
            var dice = new Random(DateTime.Now.Millisecond);

            //default to typical 6 side die
            int numSides = 6;

            if (string.IsNullOrEmpty(sides) || int.TryParse(sides, out numSides))
            {
                if (numSides <= 0)
                {
                    //negative number
                    var result = "I'm sorry, i will not roll a " + numSides.ToString() +
                                 " sided dice without adult supervision. That would tear a hole in the universe...";

                    client.ReplyTo(message, result);

                    Thread.Sleep(5000);

                    client.ReplyTo(message, "No... you don't qualify as an adult");
                }
                else
                {
                    //good number
                    var result = "You rolled a " + dice.Next(1, numSides + 1) + " on a " + numSides.ToString() + " sided dice";
                    client.ReplyTo(message, result);
                }
            }
            else
            {
                //non number, or too large a number
                var result = "I can't roll a " + sides + " I am but a meager .net bot";
                client.ReplyTo(message, result);
            }
        }
开发者ID:rjt011000,项目名称:NBot,代码行数:35,代码来源:Dice.cs

示例7: BuildParameters

        private object[] BuildParameters(MethodInfo method, Message message, IMessageClient client, Dictionary<string, string> inputParameters)
        {
            ParameterInfo[] methodParameters = method.GetParameters();
            var result = new object[methodParameters.Count()];

            for (int parameterIndex = 0; parameterIndex < result.Length; parameterIndex++)
            {
                ParameterInfo parameter = methodParameters[parameterIndex];

                if (parameter.ParameterType.IsAssignableFrom(typeof(Message)))
                {
                    result[parameterIndex] = message;
                }
                else if (parameter.ParameterType == typeof(IMessageClient))
                {
                    result[parameterIndex] = client;
                }
                else if (parameter.ParameterType == typeof(IBrain))
                {
                    result[parameterIndex] = _brain;
                }
                else if (inputParameters.ContainsKey(parameter.Name))
                {
                    result[parameterIndex] = Convert.ChangeType(inputParameters[parameter.Name], parameter.ParameterType);
                }
            }

            return result;
        }
开发者ID:rjt011000,项目名称:NBot,代码行数:29,代码来源:MessageRouter.cs

示例8: SwansonMe

 public void SwansonMe(Message message, IMessageClient client)
 {
     var httpclient = GetJsonServiceClient("http://ronsays.tumblr.com");
     var html = httpclient.Get<string>("/random");
     var linkMatch = Regex.Match(html, "<div class=\"stat-media-wrapper\"><a href=\"http://ronsays.tumblr.com/image/(\\d+)\"><img\\ssrc=\"(.*)\"\\salt");
     client.ReplyTo(message, linkMatch.Groups[2].Value);
 }
开发者ID:rjt011000,项目名称:NBot,代码行数:7,代码来源:Swanson.cs

示例9: SetMessageClient

 private void SetMessageClient(IMessageClient client)
 {
   MessageClient = client;
   client.Received += (sender, e) => OnReceiveInternal(e.Message);
   client.Connected += (sender, e) => OnConnected();
   client.ConnectFailed += (sender, e) => OnConnectFailed(e.Exception);
   client.Disconnected += (sender, e) => OnDisconnected();
 }
开发者ID:sunoru,项目名称:PBO,代码行数:8,代码来源:ClientBase.cs

示例10: 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

示例11: 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

示例12: Update

		internal void Update(IMessageClient messageClient) {
			byte[] binaryContent = this.body as byte[];
			byte[] destClientBinaryId = messageClient.GetBinaryId();
			int patternPosition = Scan(binaryContent, _lastPattern, 0);
			while (patternPosition != -1) {
				Array.Copy(destClientBinaryId, 0, binaryContent, patternPosition, destClientBinaryId.Length);
				patternPosition = Scan(binaryContent, _lastPattern, 0);
			}
			_lastPattern = destClientBinaryId;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:10,代码来源:BinaryMessage.cs

示例13: PersonAlertClientRepository

 /// <summary>
 /// Initializes a new instance of the <see cref="PersonAlertClientRepository"/> class.
 /// </summary>
 /// <param name="applicationSetting">The application setting.</param>
 /// <exception cref="System.ArgumentNullException">applicationSetting;Parameter cannot be null </exception>
 public PersonAlertClientRepository(IApplicationSetting applicationSetting)
 {
     if (applicationSetting != null)
     {
         this.alertClient = DIContainer.Instance.Resolve<IAlertClient>(new ResolverOverride[] { new ParameterOverride(BaseAddressParameterName, applicationSetting.PersonNotificationServiceBaseAddress) });
         this.alertTypeClient = DIContainer.Instance.Resolve<IAlertTypeClient>(new ResolverOverride[] { new ParameterOverride(BaseAddressParameterName, applicationSetting.PersonNotificationServiceBaseAddress) });
         this.messageClient = DIContainer.Instance.Resolve<IMessageClient>(new ResolverOverride[] { new ParameterOverride(BaseAddressParameterName, applicationSetting.PersonNotificationServiceBaseAddress) });
         this.personMessageClient = DIContainer.Instance.Resolve<IPersonMessageClient>(new ResolverOverride[] { new ParameterOverride(BaseAddressParameterName, applicationSetting.PersonNotificationServiceBaseAddress) });
         this.personAlertClient = DIContainer.Instance.Resolve<IPersonAlertsClient>(new ResolverOverride[] { new ParameterOverride(BaseAddressParameterName, applicationSetting.PersonNotificationServiceBaseAddress) });
     }
 }
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:16,代码来源:PersonAlertClientRepository.cs

示例14: RegisterClient

        /// <summary>
        /// Registers a message client (implemented by the
        /// child controls).
        /// </summary>
        /// <param name="client">The client which gets messages
        /// by the master.</param>
        public void RegisterClient(IMessageClient client)
        {
            //store reference
              this.clients.Add(client);

              //add client to dropdown
              if (!this.IsPostBack)
              {
            ListItem item = new ListItem(client.ClientName, this.clients.IndexOf(client).ToString());
            this.ClientList.Items.Add(item);
              }
        }
开发者ID:skitsanos,项目名称:WDK9,代码行数:18,代码来源:parent.aspx.cs

示例15: HandleTemperatureRequest

        public async void HandleTemperatureRequest(IMessageClient client, TemperatureRequest request)
        {
            await Context;

            var temp = await service.GetTemperature(request.City);

            client.Send(new TemperatureResponse
            {
                City = request.City,
                Temperature = temp,
            });
        }
开发者ID:wushian,项目名称:Stacks,代码行数:12,代码来源:Server.cs


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