2020-04-05 19:05:07 -04:00
2020-04-24 10:19:54 -04:00
import importlib , time
2020-04-05 19:27:06 -04:00
2020-04-05 19:52:31 -04:00
async def commit ( self , chan , source , msg ) :
await self . quit ( ' {} told me to commit {} ' . format ( source , msg ) )
2020-04-05 19:27:06 -04:00
async def quit ( self , chan , source , msg ) :
await self . quit ( ' {} told me to {} ' . format ( source , msg ) )
2020-04-05 19:52:31 -04:00
2020-04-05 19:27:06 -04:00
async def reloadmods ( self , chan , source , msg ) :
await self . message ( chan , ' reloading modules... ' )
self . cmd = { }
self . raw = { }
self . help = { }
for i in self . modules :
importlib . reload ( self . modules [ i ] )
await self . modules [ i ] . init ( self )
await self . message ( chan , ' done! did something break? if so you might need to restart ' )
2020-04-06 16:32:51 -04:00
2020-04-05 20:21:10 -04:00
async def part ( self , chan , source , msg ) :
await self . message ( chan , ' bye {} ' . format ( msg ) )
await self . part ( msg )
2020-04-05 19:27:06 -04:00
2020-04-05 20:21:10 -04:00
async def join ( self , chan , source , msg ) :
await self . message ( chan , ' joined {} ' . format ( msg ) )
await self . join ( msg )
2020-04-05 19:27:06 -04:00
2020-04-06 16:32:51 -04:00
async def joins ( self , chan , source , msg ) :
for i in self . joins :
await self . join ( i )
2020-04-24 12:13:46 -04:00
async def aexec ( self , code ) :
# Make an async function with the code and `exec` it
exec (
f ' async def __ex(self): ' +
' ' . join ( f ' \n { l } ' for l in code . split ( ' \n ' ) )
)
# Get `__ex` from local variables, call it and return the result
return await locals ( ) [ ' __ex ' ] ( self )
2020-04-06 16:32:51 -04:00
async def ev ( self , chan , source , msg ) :
msg = msg . split ( ' ' )
2020-04-24 12:13:46 -04:00
await aexec ( self , ' ' . join ( msg ) )
2020-04-06 16:32:51 -04:00
await self . message ( chan , ' ok ' )
2020-04-17 16:12:50 -04:00
async def send ( self , c , n , m ) :
msg = m . split ( ' ' )
await self . message ( msg . pop ( 0 ) , ' ' . join ( msg ) )
await self . message ( c , ' ok ' )
2020-04-24 10:19:54 -04:00
async def shut ( self , c , n , m ) :
self . qtime [ c ] = time . time ( ) + ( 60 * 10 )
await self . message ( c , ' Ok, il be back ' )
2020-04-05 19:27:06 -04:00
commands = {
' quit ' : quit ,
2020-04-05 19:52:31 -04:00
' reload ' : reloadmods ,
2020-04-05 20:21:10 -04:00
' commit ' : commit ,
' part ' : part ,
2020-04-06 16:32:51 -04:00
' join ' : join ,
' eval ' : ev ,
2020-04-17 16:12:50 -04:00
' send ' : send ,
2020-04-24 10:19:54 -04:00
' joins ' : joins ,
' shut ' : shut
2020-04-05 19:27:06 -04:00
}
2020-04-05 19:05:07 -04:00
async def adminHandle ( self , chan , source , msg ) :
2020-04-05 19:27:06 -04:00
if await self . is_admin ( source ) :
msg = msg . split ( ' ' )
if len ( msg ) < 1 or not msg [ 0 ] in commands :
await self . message ( chan , ' you press the wrong button on the oven and it burns you ' )
return
2020-04-05 19:52:31 -04:00
print ( ' [ADMIN MODULE] {} told me to {} !!! ' . format ( source , msg [ 0 ] ) )
2020-04-05 19:27:06 -04:00
await commands [ msg . pop ( 0 ) ] ( self , chan , source , ' ' . join ( msg ) )
else :
await self . message ( chan , ' you try to open it, but the oven is locked ' )
2020-04-05 19:05:07 -04:00
async def init ( self ) :
self . cmd [ ' admin ' ] = adminHandle
2020-04-27 10:42:23 -04:00
self . joins = [ " #chaos " , " #lickthecheese " , " #windowsloser " , " #cminecraft " , " #team " , " #clubcraft " , " #rscmakerspace " , " #archlinux " , " #tildetel " , " #one " , " #starlanes " , " #ipd " , " #pinebox " ]
2020-04-06 21:32:57 -04:00
2020-04-17 16:12:50 -04:00
self . help [ ' admin ' ] = [ ' admin - various bot owner commands (more for subcommands) ' , ' sub-commands of admin, for more info do help admin <command>: quit reload commit part join joins eval send ' ]
2020-04-06 21:32:57 -04:00
self . help [ ' admin quit ' ] = [ ' admin quit <message> - make the bot disconnect ' , ' no ' ]
self . help [ ' admin reload ' ] = [ ' admin reload - reload the modules and configs ' , ' nothing to see here ' ]
self . help [ ' admin commit ' ] = [ ' admin commit <action> - oh no (more) ' , ' suggested with <3 by khux ' ]
self . help [ ' admin part ' ] = [ ' admin part <channel> - leave a channel ' , ' :o ' ]
self . help [ ' admin join ' ] = [ ' admin join <channel> - make the bot join a channel ' , ' ... ' ]
self . help [ ' admin joins ' ] = [ ' admin joins - join more channels ' , ' dont reconnect to a bunch of chans when the bots crashing etc ' ]
self . help [ ' admin eval ' ] = [ ' admin eval <command> - absolute power corrupts absolutely ' , ' lmao ' ]
2020-04-17 16:12:50 -04:00
self . help [ ' admin send ' ] = [ ' admin send <channel> <message> - send a message ' , ' lmao ' ]
2020-04-06 16:32:51 -04:00