option to replace IRC control chars with markdown
^C^B isn't allowed through Discord's API, and I'm sure some other stuff like colors that I don't use. this makes it a server option to replace them with Markdown, though I think this would only ever be interesting for BitlBee + Discord
This commit is contained in:
parent
1036c08147
commit
53c874dc21
|
@ -891,6 +891,12 @@ class IRCBot(irc.client.SimpleIRCClient):
|
||||||
log.warning("reply() called with no event and no explicit target, aborting")
|
log.warning("reply() called with no event and no explicit target, aborting")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# convert characters that don't make sense for Discord (like ^C^B)
|
||||||
|
if self.connection.server_config.replace_irc_control_with_markdown:
|
||||||
|
log.debug("old replystr: %s", replystr)
|
||||||
|
replystr = replystr.replace('\x02', '**')
|
||||||
|
log.debug("new replystr: %s", replystr)
|
||||||
|
|
||||||
log.debug("replypath: %s", replypath)
|
log.debug("replypath: %s", replypath)
|
||||||
|
|
||||||
if replystr is not None:
|
if replystr is not None:
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.1.2 on 2021-04-25 17:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('ircbot', '0017_ircchannel_server'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='ircserver',
|
||||||
|
name='replace_irc_control_with_markdown',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
|
@ -84,6 +84,8 @@ class IrcServer(models.Model):
|
||||||
xmlrpc_host = models.CharField(max_length=200, default='localhost')
|
xmlrpc_host = models.CharField(max_length=200, default='localhost')
|
||||||
xmlrpc_port = models.PositiveSmallIntegerField(default=13132)
|
xmlrpc_port = models.PositiveSmallIntegerField(default=13132)
|
||||||
|
|
||||||
|
replace_irc_control_with_markdown = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Provide string summary of the server."""
|
"""Provide string summary of the server."""
|
||||||
return f"{self.name} ({self.hostname}/{self.port})"
|
return f"{self.name} ({self.hostname}/{self.port})"
|
||||||
|
|
Loading…
Reference in New Issue