Skip to content

Commit 6bad6e5

Browse files
committed
CHANGES:
- sendBotMessage now supports a "raw" parameter to avoid any bot formatting.
1 parent b3973e8 commit 6bad6e5

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,11 @@ After that, you can for instance send chat messages to the bot using
683683
```lua
684684
dcsbot.sendBotMessage('Hello World', '12345678') -- 12345678 is the ID of the channel, the message should appear, default is the configured chat channel
685685
```
686-
inside a trigger or anywhere else where scripting is allowed.
686+
inside a trigger or anywhere else where scripting is allowed.<br>
687+
If you want to send raw messages containing discord formatting options (like ANSI), then you can do it like so:
688+
```lua
689+
dcsbot.sendBotMessage('Hello World', '12345678', true) -- last parameter is "raw", which disables any bot-related formatting
690+
```
687691

688692
> [!IMPORTANT]
689693
> Channel always has to be a string, encapsulated with '', **not** a number because of Integer limitations in LUA.

Scripts/net/DCSServerBot/DCSServerBot.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ if dcsbot.UDPSendSocket == nil then
2424
dcsbot.UDPSendSocket:setsockname("*", 0)
2525
end
2626

27-
dcsbot.sendBotMessage = dcsbot.sendBotMessage or function (msg, channel)
27+
dcsbot.sendBotMessage = dcsbot.sendBotMessage or function (msg, channel, raw)
2828
local messageTable = {}
2929
messageTable.command = 'sendMessage'
3030
messageTable.message = msg
31+
messageTable.raw = raw or false
3132
dcsbot.sendBotTable(messageTable, channel)
3233
end
3334

plugins/mission/listener.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ async def sendMessage(self, server: Server, data: dict) -> None:
192192
channel_id = server.channels.get(Channel.EVENTS, -1)
193193
channel = self.bot.get_channel(channel_id)
194194
if channel:
195-
message = "```" + data['message'] + "```"
195+
if not data.get('raw', False):
196+
message = "```" + data['message'] + "```"
197+
else:
198+
message = data['message']
196199
if 'mention' in data:
197200
message = ''.join([
198201
self.bot.get_role(role).mention for role in self.bot.roles[data['mention']]

0 commit comments

Comments
 (0)