-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: send original message as md codeblock * test: tested and added additional formatting
- Loading branch information
Showing
3 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package applications | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/aussiebroadwan/tony/framework" | ||
) | ||
|
||
func sendOriginalMessageAsCodeblock(ctx framework.MessageContext, channelId, content string) { | ||
// Convert all ` to ' to avoid code block formatting | ||
content = strings.ReplaceAll(content, "`", "'") | ||
|
||
// truncate the content to 2000 characters - the code block will add 6 characters plus the markdown label (2) and the newlines (2) = 10 | ||
if len(content) > 2000-10 { | ||
content = content[:2000-10] | ||
} | ||
|
||
// Convert the content to a code block | ||
content = "```md\n" + content + "\n```" | ||
|
||
// Send a copy of the original content to the user | ||
ctx.Session().ChannelMessageSend(channelId, content) | ||
} |