dont require prefix in pms

This commit is contained in:
xfnw 2021-05-22 16:51:55 -04:00
parent a4581a462d
commit 32a5c4c1aa
3 changed files with 18 additions and 7 deletions

20
bot.py
View File

@ -7,7 +7,7 @@ from ircrobots import Bot as BaseBot
from ircrobots import Server as BaseServer from ircrobots import Server as BaseServer
from ircrobots import ConnectionParams, SASLUserPass, SASLSCRAM from ircrobots import ConnectionParams, SASLUserPass, SASLSCRAM
from auth import username, password from auth import username, password, channel
import shared import shared
def is_admin(func): def is_admin(func):
@ -49,14 +49,14 @@ async def message(self,modname,channel,msg):
class Server(BaseServer): class Server(BaseServer):
async def line_read(self, line: Line): async def line_read(self, line: Line):
print(f"{self.name} < {line.format()}")
if 'on_'+line.command.lower() in dir(self): if 'on_'+line.command.lower() in dir(self):
asyncio.create_task(self.__getattribute__('on_'+line.command.lower())(line)) asyncio.create_task(self.__getattribute__('on_'+line.command.lower())(line))
for listener in shared.listeners: for listener in shared.listeners:
if listener[0] == line.command: if listener[0] == line.command:
asyncio.create_task(listener[1](self,line)) asyncio.create_task(listener[1](self,line))
def line_preread(self, line: Line):
async def line_send(self, line: Line): print(f"{self.name} < {line.format()}")
def line_presend(self, line: Line):
print(f"{self.name} > {line.format()}") print(f"{self.name} > {line.format()}")
@ -124,9 +124,19 @@ async def main():
host = "irc.libera.chat", host = "irc.libera.chat",
port = 6697, port = 6697,
tls = True, tls = True,
sasl = sasl_params) sasl = sasl_params,
autojoin = channel)
await bot.add_server("libera", params) await bot.add_server("libera", params)
params = ConnectionParams(
"min",
host = "einstein.sturtz.cf",
port = 6667,
tls = False,
autojoin = ['#sturtz_network'])
await bot.add_server("sturtz", params)
await bot.run() await bot.run()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -84,6 +84,8 @@ async def filter(self, c, n, m):
elif m[:4] == 'min ': elif m[:4] == 'min ':
m = m[4:] m = m[4:]
await go(self, c, n, m) await go(self, c, n, m)
elif '#' not in c and n != self.nickname:
await go(self, c, n, m)
else: else:
if len(m.split(' ')) > 1: if len(m.split(' ')) > 1:
if shared.learntime + shared.learndelay < time.time(): if shared.learntime + shared.learndelay < time.time():

View File

@ -10,6 +10,5 @@ async def testy(self,channel,nick,msg):
async def init(self): async def init(self):
pass