Closed AndrewArace closed 8 years ago
Nice work. Thanks for your help.
You're welcome :-) lots more if you're interested - working on a responder that plays Pokémon battles using the pokeapi right now.
On Tue, Oct 27, 2015, 7:34 PM Jammerware notifications@github.com wrote:
Nice work. Thanks for your help.
— Reply to this email directly or view it on GitHub https://github.com/jammerware/margiebot/pull/5#issuecomment-151675230.
Trying to figure out a way to have the MargieBot respond to a user in DM instead of on the channel the user commented on. This worked:
public BotMessage GetResponse(ResponseContext context)
{
BotMessage toreturn = new BotMessage();
string whoasksid = context.Message.User.ID;
string alias = context.UserNameCache[whoasksid];
toreturn.Text = alias + ", EC2 Scanning activated!";
if(context.Message.Text.ToLower().EndsWith("private"))
{
toreturn.ChatHub = context.Message.ChatHub;
toreturn.ChatHub.Type = SlackChatHubType.DM;
toreturn.ChatHub.ID = whoasksid;
toreturn.ChatHub.Name = "@" + whoasksid;
}
return toreturn;
}
Fixed issue where when the bot was invited into a new chathub, that hub was not registered correctly with the ConnectedHubs list.
Added escape condition on the Say() method to correctly handle a null message, giving Responders the ability to "return null" when they didn't really have anything to say.