diff --git a/bot.py b/bot.py index a740ac2..b8ce305 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 @@ -15,7 +15,7 @@ def is_admin(func): if nick.lower() in self.users and self.users[nick.lower()].account in self.admins: 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 #def is_chanop(func): @@ -41,7 +41,8 @@ def rawm(rname): -async def message(self,modname,channel,msg): +async def message(self,channel,msg): + modname = os.path.splitext(os.path.basename(inspect.stack()[1].filename))[0] await self.send(build("PRIVMSG",[channel,f'[\x036{modname}\x0f] {msg}'])) diff --git a/modules/drinks.py b/modules/drinks.py index ebcafed..dfcfda9 100644 --- a/modules/drinks.py +++ b/modules/drinks.py @@ -18,11 +18,11 @@ async def coffeeup(self,c,n,m): else: self.coffee.insert(dict(name=c,value=1)) if c=='#CAPS': - await self.message(c, '[\x036drinks\x0f] ・゜゜・。。・゜゜c[~] {} UP!'.format(c[1:].upper()).upper()) + await message(self, c, '・゜゜・。。・゜゜c[~] {} UP!'.format(c[1:].upper()).upper()) else: - await self.message(c, '[\x036drinks\x0f] ・゜゜・。。・゜゜c[~] {} UP!'.format(c[1:].upper())) + await message(self, c, '・゜゜・。。・゜゜c[~] {} UP!'.format(c[1:].upper())) elif "cupcount" in m: - await self.message(c, '[\x036drinks\x0f] {} delicious cups of {}{} served so far!'.format( + await message(self, c, '{} delicious cups of {}{} served so far!'.format( self.coffee.find_one(name=c)['value'], random.choice(self.coffeetypes), c[1:] )) diff --git a/modules/test.py b/modules/test.py index c385223..a10da39 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') async def init(self):