本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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.");
}
}
示例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]"));
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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));
}
示例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;
}
示例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) });
}
}
示例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);
}
}
示例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,
});
}