本文整理汇总了C#中IMessageClient类的典型用法代码示例。如果您正苦于以下问题:C# IMessageClient类的具体用法?C# IMessageClient怎么用?C# IMessageClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMessageClient类属于命名空间,在下文中一共展示了IMessageClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: FindMemeGenerator
public void FindMemeGenerator(Message message, IMessageClient client, string url)
{
IRestClient httpClient =
GetJsonServiceClient(
string.Format(
"http://version1.api.memegenerator.net/Generator_Select_ByUrlNameOrGeneratorID?generatorID=&urlName={0}",
url));
var response = httpClient.Get<string>("");
client.ReplyTo(message, response);
}
开发者ID:rjt011000,项目名称:NBot,代码行数:12,代码来源:MemeGenerator.cs
示例17: PingMe
public void PingMe(Message message, IMessageClient client, string location)
{
var startInfo = new ProcessStartInfo();
startInfo.FileName = "ping.exe";
startInfo.Arguments = location;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
var process = Process.Start(startInfo);
process.WaitForExit(5000);
var result = process.StandardOutput.ReadToEnd();
client.ReplyTo(message, result);
}
开发者ID:rjt011000,项目名称:NBot,代码行数:13,代码来源:Ping.cs
示例18: DoIsItDownForYou
public void DoIsItDownForYou(Message message, IMessageClient client, string site)
{
try
{
IRestClient jsonClient = GetJsonServiceClient(DownForMeSite);
var result = jsonClient.Get<string>(site);
Match match = Regex.Match(result, SiteIsUpReges);
client.ReplyTo(message, match.Success ? string.Format("It's just you. {0} is up for me.", site) : string.Format("Oh no {0} is down for me too!!!!! *PANIC*", site));
}
catch (Exception e)
{
client.Send("Oh no I am Down!!! *UberPanic*", message.RoomId);
}
}
开发者ID:rjt011000,项目名称:NBot,代码行数:14,代码来源:DownForMe.cs
示例19: 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
示例20: MemeGen
private void MemeGen(Message message, IMessageClient client, string generatorId, string imageId, string text0, string text1)
{
IRestClient httpClient =
GetJsonServiceClient(
string.Format(
"http://version1.api.memegenerator.net/Instance_Create?username=test&password=test&languageCode=en&generatorID={0}&imageID={3}&text0={1}&text1={2}",
generatorId,
text0,
text1,
imageId));
var response = httpClient.Get<MemeGeneratorResponse>("");
client.ReplyTo(message, response.Result.InstanceImageUrl);
}
开发者ID:rjt011000,项目名称:NBot,代码行数:15,代码来源:MemeGenerator.cs
注:本文中的IMessageClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论