private static string SubstituteMarkup(string p, Slack instance) { return(Regex.Replace(p, @"<([@#])(.*?)>", (match) => { switch (match.Groups[1].Value) { case "#": var chan = instance.GetChannel(match.Groups[2].Value); if (chan == null) { break; } return "#" + chan.Name; case "@": var user = instance.GetUser(match.Groups[2].Value); if (user == null) { break; } return "@" + user.Name; } return match.Groups[0].Value; })); }
public void TestSend() { var slack = new Slack(); Assert.IsTrue(slack.Init(Token), "Invalid Token"); Assert.IsTrue(slack.Connect(), "Failed to Connect"); while (!slack.RecievedHello) { Thread.Sleep(0); } slack.SendMessage(slack.GetChannel("#botspam").Id, "Test!"); slack.SendMessage("#botspam", "Test2"); }
bool ICommand.Run(string MessageText, Message RawMessage, bool IsTargeted, Slack Instance) { var match = Regex.Match( MessageText, @"Introduce yourself", RegexOptions.IgnoreCase); if (match.Success && IsTargeted) { Introduce(Instance, Instance.GetChannel(RawMessage.Channel)); } return(false); }