-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachments not working #73
Comments
@ralgozino Could you check if the bot account has permission required for listing webhooks ? According to MM APIv4 doc: List incoming webhooks : Permissions : reference: https://api.mattermost.com/#tag/webhooks%2Fpaths%2F~1hooks~1incoming%2Fget |
Hello! |
@ralgozino Thanks for the feedback. It seems the unexpected behavior happens when there are multiple channels with incoming hooks of different teams. It might be a bug. I am looking into it. |
- A fix to issue #73 - Previously if there is not webhook found, mmpy_bot will try to create one for specified team. This is considered inappropriate and removed. - Support `webhook_id` parameter at `reply_webapi` and `send_webapi` method call - Document will be updated later if no further fix needed
hi @ralgozino I made a PR #74 and it's merged to master. Method 1: Specify webhook_id as parameterYou can specify from mmpy_bot.bot import respond_to
@respond_to('reply')
def reply(message):
attachments = [{
'fallback': 'Fallback text',
'author_name': 'Author',
'author_link': 'http://github.com',
'text': 'Some text here ...',
'color': '#59afe1'
}]
message.reply_webapi(
'Response to team I got message from.',
attachments,
webhook_id='p7tuwghy37r63jp4nf3tsopque',
)
# Optional: Send message to specified channel
message.send_webapi(
'Response to another team.',
attachments,
webhook_id='aib7mnahsfy5zrt6tf3ycbghic',
) Method 2: Specify WEBHOOK_ID in settings.py or local_settings.py
You can also set import os
PLUGINS = [
'my_plugins',
]
BOT_URL = os.environ.get("BOT_URL", 'http://your_server_dn/api/v4')
BOT_LOGIN = os.environ.get("DRIVERBOT_LOGIN", '[email protected]')
BOT_NAME = os.environ.get("DRIVERBOT_NAME", 'bot')
BOT_PASSWORD = os.environ.get("DRIVERBOT_PASSWORD", 'passwd')
# this team name should be the same as in driver_settings
BOT_TEAM = os.environ.get("BOT_TEAM", 'test_team')
# default public channel name
BOT_CHANNEL = os.environ.get("BOT_CHANNEL", 'off-topic')
# a private channel in BOT_TEAM
BOT_PRIVATE_CHANNEL = os.environ.get("BOT_PRIVATE_CHANNEL", 'test')
SSL_VERIFY = True
# default webhook_id of test_team/off-topic
WEBHOOK_ID = 'p7tuwghy37r63jp4nf3tsopque' Notice
|
Describe the bug
Error while trying to reply using
reply_webapi()
method.How To Reproduce
Create a plugin that replys to some keyword, try to answer with an attachment as shown in the readme:
Expected behavior
The message should be answered with an attachment.
Operating Environment (please complete the following information):
Additional context
Add any other context about the problem here [e.g. Settings for your bot, API Version]
The text was updated successfully, but these errors were encountered: