Created
November 18, 2023 18:09
-
-
Save ComputerTech312/dbb892ab98b20f1fde30dbfcfc1bdc9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import irc3 | |
from irc3.plugins.command import command | |
@irc3.plugin | |
class MyPlugin: | |
def __init__(self, bot): | |
self.bot = bot | |
self.relay_enabled = {} | |
@command(permission='admin', public=True | |
async def disable(self, mask, target, args): | |
"""Disable message relay for a channel | |
%%disable <channel> | |
""" | |
channel = args['<channel>'] | |
self.relay_enabled[channel] = False | |
return f"Relay disabled for {channel}" | |
@irc3.event(irc3.rfc.PRIVMSG) | |
async def on_message(self, mask, target, data, **kwargs): | |
if target in self.relay_enabled and self.relay_enabled[target]: | |
if target != self.bot.config.main_channel: | |
self.bot.privmsg(self.bot.config.main_channel, f"[{target}] <{mask.nick}>: {data}") | |
@irc3.event(irc3.rfc.JOIN) | |
async def on_join(self, channel, mask): | |
self.relay_enabled[channel] = True | |
config = { | |
"nick": 'test', | |
"username": 'test', | |
"realname": 'Dazzled', | |
"autojoins": ['#channel', '#channel1', '#channel2'], | |
"host": 'irc.address.net', | |
"port": 6697, | |
"ssl": True, | |
"sasl_username": 'Username', | |
"sasl_password": 'Password', | |
"includes": ['irc3.plugins.core', __name__], | |
"main_channel": '#channel' | |
} | |
if __name__ == '__main__': | |
bot = irc3.IrcBot.from_config(config) | |
bot.run(forever=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment