Skip to main content

miniirc_discord

Available on PyPI.

A wrapper for miniirc (GitHub, GitLab) to allow bots or clients made in miniirc to connect to (proprietary) Discord servers via discord.py with minimal code changes.

How to use

To use miniirc_discord, you already need to know how to use miniirc (GitHub, GitLab). Instead of creating a miniirc.IRC object, however, you need to use miniirc_discord.Discord. This is very similar, however has some differences:

  • miniirc_discord.Discord objects are created with miniirc_discord.Discord('TOKEN').
  • There is a stateless_mode keyword argument.
  • The discord_client attribute returns an instance of discord.Client, or None if stateless_mode is enabled.
  • There is a get_server_count() method which returns the number of guilds the bot is in.

Channels will start in # if they are public and are currently just a channel ID.

Some formatting from IRC to Discord should be translated nicely, however more complex codes and formatting from Discord to IRC are currently not.

Your bot will need to be able to request the "message content" intent for miniirc_discord to work properly.

Stateless mode

The stateless_mode keyword argument will instruct discord.py to disable the user cache and any intents not required by miniirc_discord. This should be enabled if you are not using discord_client to cut back on memory and bandwidth usage.

Since miniirc_discord 0.6.0, the stateless_mode keyword argument is True by default.

Example

TOKEN = os.environ['DISCORD_TOKEN']

irc = miniirc_discord.Discord(TOKEN)
channel = irc.discord_client.get_channel(channel_id)  # Error!

# Disabling stateless mode will add a "discord_client" attribute
irc = miniirc_discord.Discord(TOKEN, stateless_mode=False)
channel = irc.discord_client.get_channel(channel_id)  # No error

Supported commands

PRIVMSG

PRIVMSG operates like you'd expect and IRC formatting codes are converted to markdown. You can use the +draft/reply IRCv3 tag to reply to a message.

CTCP ACTION (irc.me())

This works similarly to PRIVMSG, except the CTCP ACTION is also converted to a Discord /me.

NOTICE

NOTICEs are converted into embeds by miniirc_discord. To set an embed title, you can add a bold line to the start of the embed:

irc.notice(channel, '\x02Embed title\x02\nEmbed content')

You can add an IRC colour code to the start of the line to set the embed colour:

# Green embed
irc.notice(channel, '\x033\x02Embed title\x02\x03\nEmbed content')

# Light blue embed
irc.notice(channel, '\x0312\x02Embed title\x02\x03\nEmbed content')

Older versions of miniirc_discord had a non-standard IRCv3 tag to set the embed title. This is still supported, however you should switch to the above syntax when possible.

TAGMSG

You can add reactions to messages using the +draft/react message tag.

Example:

@irc.Handler('PRIVMSG', colon=False, ircv3=True)
def handle_privmsg(irc, hostmask, tags, args):
    if args[1] == '$react':
        irc.send('TAGMSG', args[0], tags={
            '+draft/reply': tags.get('msgid'),
            '+draft/react': '🆗️'
        })

AWAY

AWAY will set the bot's "Playing" text. If you want to change the prefix to something else, you can set the non-standard IRCv3 client tag +discordapp.com/type to (Playing, Streaming, Listening to or Watching). The +discordapp.com/status tag can be set to 'online', 'idle', 'dnd' or 'invisible'.

Installation and setting up

You can install miniirc_discord with pip. On Linux-based systems, you would do sudo pip3 install miniirc_discord. Version numbers should follow SemVer since 0.4.0 and are no longer in sync with miniirc.

Getting a bot token

To get a Discord bot token and invite link, see this guide. Make sure you enable the message content intent in the bot settings page.

Metadata

Release files for miniirc-discord 0.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miniirc-discord 0.6.2
File Size Uploaded
miniirc_discord-0.6.2.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for miniirc-discord 0.6.2
File Interpreter ABI Platform
miniirc_discord-0.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 18.4 kB

Release files / miniirc_discord-0.6.2.tar.gz

Download URL miniirc_discord-0.6.2.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ad666ef73b5f9a095a93a9a0da66d9665c05639f28c3e69c4477a62ad300889f
BLAKE2b-256 checksum
How to use checksums
a4d3984ddf1aa304bd446030714b356b853f089c2895ddceeefef11cd210c1db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / miniirc_discord-0.6.2-py3-none-any.whl

Download URL miniirc_discord-0.6.2-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1bf30e5ae6e457abe9e3d7def01015ab91af57b0dd6b344bd00d6557f4d1095e
BLAKE2b-256 checksum
How to use checksums
7c08852bc15dcd3b54455e07123863aff1a5765921e22b240039ec73bad39793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.6.2 This release

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.18

2 release files

0.5.16

2 release files

0.5.15

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page