@@ -9,7 +9,7 @@ def __init__(bot):
9
9
join (bot )
10
10
leave (bot )
11
11
on_guild_join (bot )
12
- message_send ( bot )
12
+ # on_message is now handled by event_handler/loader.py
13
13
message_edit (bot )
14
14
message_delete (bot )
15
15
on_command_error (bot )
@@ -51,79 +51,6 @@ async def on_guild_join(ctx):
51
51
if teapot .config .storage_type () == "mysql" :
52
52
teapot .database .create_guild_table (ctx .guild )
53
53
54
-
55
- def message_send (bot ):
56
- @bot .event
57
- async def on_message (message ):
58
- if teapot .config .storage_type () == "mysql" :
59
- try :
60
- database = teapot .database .__init__ ()
61
- db = teapot .database .db (database )
62
- db .execute ("SELECT * FROM `users` WHERE user_id = '" + str (message .author .id ) + "'" )
63
- if db .rowcount == 0 :
64
- db .execute ("INSERT INTO `users`(user_id, user_name, user_display_name) VALUES(%s, %s, %s)" ,
65
- (message .author .id , message .author .name , message .author .display_name ))
66
- database .commit ()
67
-
68
- db .execute ("SELECT * FROM `channels` WHERE channel_id = '" + str (message .channel .id ) + "'" )
69
- if db .rowcount == 0 :
70
- db .execute ("INSERT INTO `channels`(channel_id, channel_name) VALUES(%s, %s)" ,
71
- (message .channel .id , message .channel .name ))
72
- database .commit ()
73
- db .execute (
74
- "INSERT INTO `guild_logs`(timestamp, guild_id, channel_id, message_id, user_id, action_type, message) VALUES(%s, %s, %s, %s, %s, %s, %s)" ,
75
- (teapot .time (), message .guild .id , message .channel .id , message .id , message .author .id ,
76
- "MESSAGE_SEND" , message .content ))
77
- database .commit ()
78
- except Exception as e :
79
- print (e )
80
- await bot .process_commands (message )
81
-
82
- @bot .event
83
- async def on_message (message ):
84
- # SAO Easter Egg
85
- punctuations = '!()-[]{};:\' "\\ ,<>./?@#$%^&*_~'
86
- # remove punctuation from the string
87
- msg = ""
88
- for char in message .content .lower ():
89
- if char not in punctuations :
90
- msg = msg + char
91
-
92
- # profanity check
93
- prob = predict_prob ([msg ])
94
- if prob >= 0.8 :
95
- em = discord .Embed (title = f"AI Analysis Results" , color = 0xC54B4F ) # TODO: this will be replaced with cloud detection soon
96
- em .add_field (name = 'PROFANITY DETECTED! ' , value = str (prob [0 ]))
97
- await message .channel .send (embed = em )
98
-
99
- if msg .startswith ("system call " ):
100
- content = msg [12 :].split (" " )
101
- if content [0 ].lower () == "inspect" :
102
- if content [1 ].lower () == "entire" :
103
- if content [2 ].lower () == "command" :
104
- if content [3 ].lower () == "list" :
105
- em = discord .Embed (title = f"🍢 SAO Command List" , color = 0x7400FF )
106
- em .set_thumbnail (
107
- url = "https://cdn.discordapp.com/attachments/668816286784159763/674285661510959105/Kirito-Sao-Logo-1506655414__76221.1550241566.png" )
108
- em .add_field (name = 'Commands' ,
109
- value = "generate xx element\n generate xx element xx shape\n inspect entire command list" )
110
-
111
- em .set_footer (text = f"{ teapot .copyright ()} | Code licensed under the MIT License" )
112
- await message .channel .send (embed = em )
113
- elif content [0 ].lower () == "generate" :
114
- if content [- 1 ].lower () == "element" :
115
- em = discord .Embed (title = f"✏ Generated { content [1 ].lower ()} element!" ,
116
- color = 0xFF0000 )
117
- await message .channel .send (embed = em )
118
- if content [- 1 ].lower () == "shape" :
119
- if content [2 ].lower () == "element" :
120
- em = discord .Embed (
121
- title = f"✏ Generated { content [- 2 ].lower ()} shaped { content [1 ].lower ()} element!" ,
122
- color = 0xFF0000 )
123
- await message .channel .send (embed = em )
124
- await bot .process_commands (message )
125
-
126
-
127
54
def message_edit (bot ):
128
55
@bot .event
129
56
async def on_raw_message_edit (ctx ):
0 commit comments