merge bot.py from upstream oirc
This commit is contained in:
parent
f67b269b1b
commit
fd3174b1fe
1 changed files with 7 additions and 10 deletions
17
bot.py
17
bot.py
|
@ -7,7 +7,7 @@ from ircrobots import Bot as BaseBot
|
|||
from ircrobots import Server as BaseServer
|
||||
from ircrobots import ConnectionParams, SASLUserPass, SASLSCRAM
|
||||
|
||||
from auth import username, password, channel
|
||||
from auth import username, password
|
||||
import shared
|
||||
|
||||
|
||||
|
@ -19,9 +19,7 @@ def is_admin(func):
|
|||
):
|
||||
await func(self, channel, nick, msg)
|
||||
else:
|
||||
await message(
|
||||
self, "core", channel, "you do not have permission to do that"
|
||||
)
|
||||
await message(self, channel, "you do not have permission to do that")
|
||||
|
||||
return decorator
|
||||
|
||||
|
@ -54,7 +52,7 @@ def rawm(rname):
|
|||
|
||||
|
||||
async def message(self, channel, msg):
|
||||
modname = os.path.splittext(os.path.basename(inspect.stack()[1].filename))[0]
|
||||
modname = os.path.splitext(os.path.basename(inspect.stack()[:2][-1].filename))[0]
|
||||
await self.send(build("PRIVMSG", [channel, f"[\x036{modname}\x0f] {msg}"]))
|
||||
|
||||
|
||||
|
@ -68,10 +66,10 @@ class Server(BaseServer):
|
|||
if listener[0] == line.command:
|
||||
asyncio.create_task(listener[1](self, line))
|
||||
|
||||
def line_preread(self, line: Line):
|
||||
async def line_preread(self, line: Line):
|
||||
print(f"{self.name} < {line.format()}")
|
||||
|
||||
def line_presend(self, line: Line):
|
||||
async def line_presend(self, line: Line):
|
||||
print(f"{self.name} > {line.format()}")
|
||||
|
||||
async def on_001(self, line):
|
||||
|
@ -84,9 +82,9 @@ class Server(BaseServer):
|
|||
asyncio.create_task(m.init(self))
|
||||
shared.modules[i] = m
|
||||
|
||||
# depricated, to support old modules
|
||||
async def message(self, channel, msg):
|
||||
await self.send(build("PRIVMSG", [channel, msg]))
|
||||
modname = os.path.splitext(os.path.basename(inspect.stack()[:2][-1].filename))[0]
|
||||
await self.send(build("PRIVMSG", [channel, f"[\x036{modname}\x0f] {msg}"]))
|
||||
|
||||
async def on_privmsg(self, line):
|
||||
if line.tags and "batch" in line.tags and line.tags["batch"] == "1":
|
||||
|
@ -129,7 +127,6 @@ class Bot(BaseBot):
|
|||
def create_server(self, name: str):
|
||||
return Server(self, name)
|
||||
|
||||
|
||||
async def main():
|
||||
bot = Bot()
|
||||
|
||||
|
|
Loading…
Reference in a new issue