From 2179c2770ab4dc4ba8d74c4905700897e6fa401b Mon Sep 17 00:00:00 2001 From: xfnw Date: Mon, 27 Sep 2021 15:52:16 -0400 Subject: [PATCH] backport automatic module name detection --- bot.py | 5 +++-- modules/test.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 1ab0f7b..c6d87e0 100755 --- a/bot.py +++ b/bot.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -import asyncio, os, importlib +import asyncio, os, importlib, inspect from irctokens import build, Line from ircrobots import Bot as BaseBot @@ -41,7 +41,8 @@ def rawm(rname): -async def message(self,modname,channel,msg): +async def message(self,channel,msg): + modname = os.path.splittext(os.path.basename(inspect.stack()[1].filename))[0] await self.send(build("PRIVMSG",[channel,f'[\x036{modname}\x0f] {msg}'])) diff --git a/modules/test.py b/modules/test.py index 187911c..90ae106 100644 --- a/modules/test.py +++ b/modules/test.py @@ -5,7 +5,7 @@ import bot @bot.command('test') @bot.is_admin async def testy(self,channel,nick,msg): - await bot.message(self,'test',channel,'hi there') + await bot.message(self,channel,'hi there')