Add option to clean invites from relayed messages
This commit is contained in:
parent
7697887391
commit
b70ce6e79e
@ -29,14 +29,13 @@ command_prefix = !
|
||||
port = 8080
|
||||
channel_id = 576585506658189332
|
||||
allow_logins = true
|
||||
clean_invites = true
|
||||
```
|
||||
|
||||
4. Enable mod security and add `discordmt` to the http mods. In additon, set `discord.port` in your `minetest.conf` to match the port you used in `relay.conf`and optionally set `discord.text_color` to a hex color string if you'd like to color relayed messages from Discord.
|
||||
4. Set `discord.port` in your `minetest.conf` to match the port you used in `relay.conf`. You may also set `discord.text_color` to a hex color string if you'd like to color relayed messages from Discord.
|
||||
|
||||
Example `minetest.conf` excerpt:
|
||||
```
|
||||
secure.enable_security = true
|
||||
secure.http_mods = discordmt
|
||||
discord.port = 8080
|
||||
discord.text_color = #a7a7a7
|
||||
```
|
||||
|
@ -1,7 +1,8 @@
|
||||
[BOT]
|
||||
token = <Insert Discord bot token here>
|
||||
token = <Discord bot token goes here>
|
||||
command_prefix = !
|
||||
[RELAY]
|
||||
port = 8080
|
||||
channel_id = <Insert Discord channel ID here>
|
||||
channel_id = <Discord channel ID goes here>
|
||||
allow_logins = true
|
||||
clean_invites = true
|
||||
|
13
server.py
13
server.py
@ -31,6 +31,9 @@ class Queue():
|
||||
def isEmpty(self):
|
||||
return len(self.queue) == 0
|
||||
|
||||
def clean_invites(string):
|
||||
return ' '.join([word for word in string.split() if not ('discord.gg' in word) and not ('discordapp.com/invite' in word)])
|
||||
|
||||
outgoing_msgs = Queue()
|
||||
command_queue = Queue()
|
||||
login_queue = Queue()
|
||||
@ -46,6 +49,7 @@ connected = False
|
||||
port = int(config['RELAY']['port'])
|
||||
token = config['BOT']['token']
|
||||
logins_allowed = True if config['RELAY']['allow_logins'] == 'true' else False
|
||||
do_clean_invites = True if config['RELAY']['clean_invites'] == 'true' else False
|
||||
|
||||
last_request = 0
|
||||
|
||||
@ -108,10 +112,15 @@ async def on_message(message):
|
||||
global outgoing_msgs
|
||||
if check_timeout():
|
||||
if (message.channel.id == channel_id) and (message.author.id != bot.user.id):
|
||||
outgoing_msgs.add({
|
||||
msg = {
|
||||
'author': message.author.name,
|
||||
'content': message.content.replace('\n', '/')
|
||||
})
|
||||
}
|
||||
if do_clean_invites:
|
||||
msg['content'] = clean_invites(msg['content'])
|
||||
if msg['content'] != '':
|
||||
outgoing_msgs.add(msg)
|
||||
|
||||
await bot.process_commands(message)
|
||||
|
||||
@bot.command(help='Runs an ingame command from Discord.')
|
||||
|
Loading…
x
Reference in New Issue
Block a user