poshbotio / PoshBot

Powershell-based bot framework
MIT License
537 stars 108 forks source link

Add Source Application/backend type to $Global:PoshbotContext #104

Closed ChrisLGardner closed 6 years ago

ChrisLGardner commented 6 years ago

Based on #103 and #84 you can get a bunch of information about the PoshBot context for use in commands being run by the bot. Now that there is support for Teams and Slack and other backends on the way it would be useful to include which application or backend the message came from.

The first use case I've noticed this would be good for is plugins like xkcd that can return images or links, Slack will auto convert/expand these but Teams won't. Being able to return some markdown for Teams to work with when it's the source of the message would be very helpful.

devblackops commented 6 years ago

Makes sense @ChrisLGardner

Would you envision a new property on $global.PoshBotContext called BackendType or similar?

One potential issue I could see is people can create their own backends outside of PoshBot (like the GChat backend) and PoshBot won't be directly aware of what type they are as they are all inherited from the Backend class. I suppose $global:PoshBotContext.BackendType could be the value of $backend.GetType() which would be SlackBackend or TeamsBackend for Slack and Teams respectively.

ChrisLGardner commented 6 years ago

That's pretty much what I was thinking, I was going to have a look and see if I could add it myself but I haven't done enough with classes in PS yet to dive in to something this complex.


From: Brandon Olin notifications@github.com Sent: Tuesday, September 4, 2018 9:42:03 PM To: poshbotio/PoshBot Cc: Chris Gardner; Mention Subject: Re: [poshbotio/PoshBot] Add Source Application/backend type to $Global:PoshbotContext (#104)

Makes sense @ChrisLGardnerhttps://github.com/ChrisLGardner

Would you envision a new a new property on $global.PoshBotContext called BackendType or similar?

One potential issue I could see is people can create their own backends outside of PoshBot (like the GChat backendhttps://github.com/scrthq/PoshBot.GChat.Backend) and PoshBot won't be directly aware of what type they are as they are all inherit from the Backend class. I suppose $global:PoshBotContext.BackendType could be the value of $backend.GetType() which would be SlackBackend or TeamsBackend for Slack and Teams respectively.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/poshbotio/PoshBot/issues/104#issuecomment-418510841, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQDqFqR6mZRnjdcJe46H3dWflPr6JvVuks5uXuWbgaJpZM4WZfXc.

ChrisLGardner commented 6 years ago

I decided to have a go at it anyway and it seems to work from my limited testing.