public BotMessage GetResponse(ResponseContext context) { try { const string reason = "for a common reply"; if(context.Message.Text.Contains("it works on my machine")) { reactionApi.AddReaction(ConfigurationManager.AppSettings["BotKey"], "itworksonmymachine", context.Message.GetChannelId(), context.Message.GetTimeStamp()); } var issuer = userApi.GetUserBySlackId(context.FormattedBotUserID()); var recipient = userApi.GetUserBySlackId(context.Message.User.FormattedUserID); var seconderSlackId = context.GetSecondCousinSlackId(); if (seconderSlackId.Equals("")) seconderSlackId = recipient.SlackId; var seconder = userApi.GetUserBySlackId(seconderSlackId); fineApi.IssueAutoFine(issuer.Id, recipient.Id, seconder.Id, reason); reactionApi.AddReaction(ConfigurationManager.AppSettings["BotKey"], "fine", context.Message.GetChannelId(), context.Message.GetTimeStamp()); reactionApi.AddReaction(ConfigurationManager.AppSettings["SeconderBotKey"], "fine", context.Message.GetChannelId(), context.Message.GetTimeStamp()); return new BotMessage { Text = ""}; } catch(Exception ex) { return this.GetExceptionResponse(ex, context.Message); } }
public BotMessage GetResponse(ResponseContext context) { try { var youtubeLinkList = context.Message.GetYouTubeLinkList(); const string reason = "for sharing the following YouTube video --> "; var issuer = userApi.GetUserBySlackId(context.FormattedBotUserID()); var recipient = userApi.GetUserBySlackId(context.Message.User.FormattedUserID); var seconderSlackId = context.GetSecondCousinSlackId(); if (seconderSlackId.Equals("")) seconderSlackId = recipient.SlackId; var seconder = userApi.GetUserBySlackId(seconderSlackId); for (var i = 0; i < youtubeLinkList.Count; i++) { fineApi.IssueAutoFine(issuer.Id, recipient.Id, seconder.Id, reason + youtubeLinkList[i]); } reactionApi.AddReaction(ConfigurationManager.AppSettings["BotKey"], "fine", context.Message.GetChannelId(), context.Message.GetTimeStamp()); reactionApi.AddReaction(ConfigurationManager.AppSettings["SeconderBotKey"], "fine", context.Message.GetChannelId(), context.Message.GetTimeStamp()); return new BotMessage { Text = "" }; } catch (Exception ex) { return this.GetExceptionResponse(ex, context.Message); } }