relay

Log | Files | Refs

commit 99d3be7dfaed63314f10ad741088a08c35236fe9
parent 228369c64c640b37c9d964bdaadc79c18b8ccedd
Author: xfnw <xfnw@ttm.sh>
Date:   Wed, 23 Dec 2020 16:20:27 -0500

admin commands to send to all servers, eg remote bans

Diffstat:
Mbot.py | 10++++++++++
Mconfig.py.example | 3+++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/bot.py b/bot.py @@ -49,6 +49,12 @@ class Server(BaseServer): nick = line.source.split('!')[0] if nick == self.nickname or (line.tags and "batch" in line.tags) or "\x0f\x0f\x0f\x0f" in text: return + if nick.lower() in self.users and self.users[nick.lower()].account in ADMINS: + if text[:len(self.nickname)+2].lower() == f'{self.nickname}: '.lower(): + args = text[len(self.nickname)+2:].split(' ') + for i in self.bot.servers: + asyncio.create_task(self.bot.servers[i].ac(self.name,args)) + return for i in self.bot.servers: asyncio.create_task(self.bot.servers[i].bc(self.name,nick,text)) #await self.send(build("PRIVMSG ##xfnw :ine and boat ",[text])) @@ -60,6 +66,10 @@ class Server(BaseServer): if self.disconnected or name == self.name or "chan" not in list(dir(self)): return await self.send(build("PRIVMSG",[self.chan,"\x0f\x0f\x0f\x0f<"+nick[:1]+"\u200c"+nick[1:]+"@"+name+"> "+msg])) + async def ac(self,name,args): + if self.disconnected or "chan" not in list(dir(self)): + return + await self.send(build(args[0],[self.chan]+args[1:])) class Bot(BaseBot): def create_server(self, name: str): diff --git a/config.py.example b/config.py.example @@ -1,4 +1,5 @@ +# name hostname port tls SERVERS = [ ("freenode", "chat.freenode.net.invalid", 6697, True), ("tilde", "irc.tilde.chat.invalid", 6697, True), @@ -11,3 +12,5 @@ NICKNAME = 'testrelay' CHANNEL = '#testrelay' FNCHANNEL = '##testrelay' +ADMINS=['jess'] +