fbradyirl / webex_bot

Python package for a Webex Bot based on websockets.
MIT License
68 stars 44 forks source link

Initial Support for messages with file attachments #50

Closed mochipon closed 4 months ago

mochipon commented 5 months ago

This Pull Request introduces basic support for the 'share' verb, enabling the handling of messages with file attachments.

A key point to note is that there are two patterns of messages with files: those that come with text and those that are sent without any text, containing only the file(s).

For messages without text, the message object retrieved by self.teams.messages.get(message_base_64_id) does not contain a text. An example of such a message object is as follows:

{
  "id": "<snip>",
  "roomId": "<snip>",
  "roomType": "direct",
  "files": [
    "https://webexapis.com/v1/contents/<snip>"
  ],
  "personId": "<snip>",
  "personEmail": "<snip>",
  "created": "2024-03-05T03:46:01.711Z",
  "isVoiceClip": false
}

When a command is not understood or is absent, the help_command is invoked. So it's important to remember that the help_command will be always executed when a message contains only a file, with no accompanying text.

While I believe there may be a better approach, this PR serves to implement the necessary minimum support. Further improvements can be built upon this foundation.

Please review the changes, and if there are any additional considerations or modifications needed, please let me know. Thank you!

potentially fixes #38

ecoen66 commented 4 months ago

See pull request #54