diff --git a/webhookbot/db.sql b/webhookbot/db.sql index eb62a95a..5c0233fa 100644 --- a/webhookbot/db.sql +++ b/webhookbot/db.sql @@ -2,6 +2,8 @@ CREATE TABLE `hooks` ( `id` varchar(100) NOT NULL, `name` varchar(100) NOT NULL, `conv_id` varchar(100) NOT NULL, + `template` varchar(10000) NOT NULL, + CONSTRAINT hook UNIQUE (`name`,`conv_id`), PRIMARY KEY (`id`), KEY `conv_id` (`conv_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/webhookbot/main.go b/webhookbot/main.go index 51add8a7..e1629049 100644 --- a/webhookbot/main.go +++ b/webhookbot/main.go @@ -45,10 +45,20 @@ const back = "`" const backs = "```" func (s *BotServer) makeAdvertisement() kbchat.Advertisement { - createExtended := fmt.Sprintf(`Create a new webhook for sending messages into the current conversation. You must supply a name as well to identify the webhook. To use a webhook URL, supply a %smsg%s URL parameter, or a JSON POST body with a field %smsg%s. + createExtended := fmt.Sprintf(`Create a new webhook for sending messages into the current conversation. You must supply a name as well to identify the webhook. To use a webhook URL, supply a %smsg%s URL parameter, or a JSON POST body with a field %smsg%s. You can also supply a template, which allows you to customize the message displayed by the webhook, and the URL and/or JSON fields it will accept. For more information on templates, use the %s!webhook help%s command. Example:%s - !webhook create alerts%s`, back, back, back, back, backs, backs) + !webhook create alerts%s + + Example (using custom template):%s + !webhook create alerts *{{.title}}* + %s{{.body}}%s%s`, + back, back, back, back, back, back, backs, backs, backs, back, back, backs) + updateExtended := fmt.Sprintf(`Update an existing webhook's template. Leave the template field empty to use the default template. For more information on templates, use the %s!webhook help%s command. + + Example:%s + !webhook update alerts *New Alert: {{.title}}* + %s{{.body}}%s%s`, back, back, backs, back, back, backs) removeExtended := fmt.Sprintf(`Remove a webhook from the current conversation. You must supply the name of the webhook. Example:%s @@ -57,14 +67,26 @@ func (s *BotServer) makeAdvertisement() kbchat.Advertisement { cmds := []chat1.UserBotCommandInput{ { Name: "webhook create", + Usage: " [