-
Notifications
You must be signed in to change notification settings - Fork 2
/
pluginFramework.py
92 lines (67 loc) · 2.39 KB
/
pluginFramework.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import inspect
from attributes import userCommand
from attributes import backgroundLoop
from attributes import afterCheck
import CONFIG
import discord
class pluginShell(object):
def __init__(self, clientInstance):
self.clientInstance = clientInstance
self.userCommands = {}
self.backgroundLoops = []
self.afterChecks = []
#fetch all methods
for name, member in inspect.getmembers(self):
if hasattr(member, "isCommand"):
self.userCommands[member.__name__] = member
if hasattr(member, "isLoop"):
self.backgroundLoops.append(member)
#create loops for all background processses
self.clientInstance.loop.create_task(member())
if hasattr(member, "afterCheck"):
self.afterChecks.append(member)
async def _on_message(self, message):
if message.author != self.clientInstance.user:
command = message.content.split()
commandStr = command[0]
if commandStr.startswith(CONFIG.PREFIX):
commandStr = commandStr.replace(CONFIG.PREFIX, "")
if commandStr in self.userCommands.keys():
await self.userCommands[commandStr](message)
for x in self.afterChecks:
try:
await x(message)
except:
pass
async def on_message(self, message):
pass
async def on_message_edit(self, before, after):
pass
async def on_message_delete(self, message):
pass
async def on_channel_create(self, channel):
pass
async def on_channel_update(self, before, after):
pass
async def on_channel_delete(self, channel):
pass
async def on_member_join(self, member):
pass
async def on_member_remove(self, member):
pass
async def on_member_update(self, before, after):
pass
async def on_server_join(self, server):
pass
async def on_server_update(self, before, after):
pass
async def on_server_role_create(self, server, role):
pass
async def on_server_role_delete(self, server, role):
pass
async def on_server_role_update(self, server, role):
pass
async def on_member_ban(self, member):
pass
async def on_member_unban(self, member):
pass