diff --git a/ircbot/bot.py b/ircbot/bot.py index 260dc23..9f9d1cf 100644 --- a/ircbot/bot.py +++ b/ircbot/bot.py @@ -891,6 +891,12 @@ class IRCBot(irc.client.SimpleIRCClient): log.warning("reply() called with no event and no explicit target, aborting") 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) if replystr is not None: diff --git a/ircbot/migrations/0018_ircserver_replace_irc_control_with_markdown.py b/ircbot/migrations/0018_ircserver_replace_irc_control_with_markdown.py new file mode 100644 index 0000000..120330f --- /dev/null +++ b/ircbot/migrations/0018_ircserver_replace_irc_control_with_markdown.py @@ -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), + ), + ] diff --git a/ircbot/models.py b/ircbot/models.py index 0effe57..e03cda5 100644 --- a/ircbot/models.py +++ b/ircbot/models.py @@ -84,6 +84,8 @@ class IrcServer(models.Model): xmlrpc_host = models.CharField(max_length=200, default='localhost') xmlrpc_port = models.PositiveSmallIntegerField(default=13132) + replace_irc_control_with_markdown = models.BooleanField(default=False) + def __str__(self): """Provide string summary of the server.""" return f"{self.name} ({self.hostname}/{self.port})"