Преглед изворни кода

Better config.py organization for cog defaults. All emoji come from config.

tags/1.0.1
Rocketsoup пре 4 година
родитељ
комит
76d6ebcfd2
7 измењених фајлова са 133 додато и 76 уклоњено
  1. 12
    0
      cogs/basecog.py
  2. 9
    7
      cogs/configcog.py
  3. 61
    38
      cogs/crosspostcog.py
  4. 26
    19
      cogs/joinraidcog.py
  5. 22
    9
      config.py.sample
  6. 2
    2
      rocketbot.py
  7. 1
    1
      storage.py

+ 12
- 0
cogs/basecog.py Прегледај датотеку

@@ -11,6 +11,18 @@ class BaseCog(commands.Cog):
11 11
 		self.bot = bot
12 12
 		self.listened_mod_react_message_ids = AgeBoundDict(timedelta(minutes=5), lambda message_id, tpl : tpl[0])
13 13
 
14
+	@classmethod
15
+	def get_cog_default(cls, key: str):
16
+		"""
17
+		Convenience method for getting a cog configuration default from
18
+		`CONFIG['cogs'][<cogname>][<key>]`.
19
+		"""
20
+		cogs: dict = CONFIG['cog_defaults']
21
+		cog = cogs.get(cls.__name__)
22
+		if cog is None:
23
+			return None
24
+		return cog.get(key)
25
+
14 26
 	def listen_for_reactions_to(self, message: Message, context = None) -> None:
15 27
 		"""
16 28
 		Registers a warning message as something a mod may react to to enact

+ 9
- 7
cogs/configcog.py Прегледај датотеку

@@ -1,5 +1,7 @@
1 1
 from discord import Guild, TextChannel
2 2
 from discord.ext import commands
3
+
4
+from config import CONFIG
3 5
 from storage import ConfigKey, Storage
4 6
 from cogs.basecog import BaseCog
5 7
 
@@ -35,7 +37,7 @@ class ConfigCog(BaseCog):
35 37
 		Storage.set_config_value(guild, ConfigKey.WARNING_CHANNEL_ID,
36 38
 			context.channel.id)
37 39
 		await context.message.reply(
38
-			f'Warning channel updated to {channel.mention}.',
40
+			f'{CONFIG["success_emoji"]} Warning channel updated to {channel.mention}.',
39 41
 			mention_author=False)
40 42
 
41 43
 	@config.command(
@@ -48,12 +50,12 @@ class ConfigCog(BaseCog):
48 50
 		channel_id = Storage.get_config_value(guild, ConfigKey.WARNING_CHANNEL_ID)
49 51
 		if channel_id is None:
50 52
 			await context.message.reply(
51
-				'No warning channel is configured.',
53
+				f'{CONFIG["info_emoji"]} No warning channel is configured.',
52 54
 				mention_author=False)
53 55
 		else:
54 56
 			channel = guild.get_channel(channel_id)
55 57
 			await context.message.reply(
56
-				f'Warning channel is configured as {channel.mention}.',
58
+				f'{CONFIG["info_emoji"]} Warning channel is configured as {channel.mention}.',
57 59
 				mention_author=False)
58 60
 
59 61
 	@config.command(
@@ -70,11 +72,11 @@ class ConfigCog(BaseCog):
70 72
 		Storage.set_config_value(guild, ConfigKey.WARNING_MENTION, mention)
71 73
 		if mention is None:
72 74
 			await context.message.reply(
73
-				'Warning messages will not tag anyone.',
75
+				f'{CONFIG["success_emoji"]} Warning messages will not tag anyone.',
74 76
 				mention_author=False)
75 77
 		else:
76 78
 			await context.message.reply(
77
-				f'Warning messages will now tag {mention}.',
79
+				f'{CONFIG["success_emoji"]} Warning messages will now tag {mention}.',
78 80
 				mention_author=False)
79 81
 
80 82
 	@config.command(
@@ -88,9 +90,9 @@ class ConfigCog(BaseCog):
88 90
 		mention: str = Storage.get_config_value(guild, ConfigKey.WARNING_MENTION)
89 91
 		if mention is None:
90 92
 			await context.message.reply(
91
-				'No warning mention configured.',
93
+				f'{CONFIG["info_emoji"]} No warning mention configured.',
92 94
 				mention_author=False)
93 95
 		else:
94 96
 			await context.message.reply(
95
-				f'Warning messages will tag {mention}',
97
+				f'{CONFIG["info_emoji"]} Warning messages will tag {mention}',
96 98
 				mention_author=False)

+ 61
- 38
cogs/crosspostcog.py Прегледај датотеку

@@ -3,6 +3,7 @@ from discord.ext import commands
3 3
 from datetime import datetime, timedelta
4 4
 import math
5 5
 
6
+from config import CONFIG
6 7
 from rscollections import AgeBoundList, SizeBoundDict
7 8
 from cogs.basecog import BaseCog
8 9
 from storage import Storage
@@ -39,16 +40,20 @@ class CrossPostCog(BaseCog):
39 40
 	# Config
40 41
 
41 42
 	def __warn_count(self, guild: Guild) -> int:
42
-		return Storage.get_config_value(guild, self.CONFIG_KEY_WARN_COUNT) or 3
43
+		return Storage.get_config_value(guild, self.CONFIG_KEY_WARN_COUNT) or \
44
+			self.get_cog_default('warn_message_count')
43 45
 
44 46
 	def __ban_count(self, guild: Guild) -> int:
45
-		return Storage.get_config_value(guild, self.CONFIG_KEY_BAN_COUNT) or 9999
47
+		return Storage.get_config_value(guild, self.CONFIG_KEY_BAN_COUNT) or \
48
+			self.get_cog_default('ban_message_count')
46 49
 
47 50
 	def __min_message_length(self, guild: Guild) -> int:
48
-		return Storage.get_config_value(guild, self.CONFIG_KEY_MIN_MESSAGE_LENGTH) or 0
51
+		return Storage.get_config_value(guild, self.CONFIG_KEY_MIN_MESSAGE_LENGTH) or \
52
+			self.get_cog_default('min_message_length')
49 53
 
50 54
 	def __message_age_seconds(self, guild: Guild) -> int:
51
-		return Storage.get_config_value(guild, self.CONFIG_KEY_MESSAGE_AGE) or 120
55
+		return Storage.get_config_value(guild, self.CONFIG_KEY_MESSAGE_AGE) or \
56
+			self.get_cog_default('time_window_seconds')
52 57
 
53 58
 	async def __record_message(self, message: Message) -> None:
54 59
 		if message.author.permissions_in(message.channel).ban_members:
@@ -109,9 +114,9 @@ class CrossPostCog(BaseCog):
109 114
 					f'> {content}'
110 115
 				if context.warning_message:
111 116
 					await self.update_warn(context.warning_message, msg)
112
-					await context.warning_message.clear_reaction('🗑')
113
-					await context.warning_message.clear_reaction('👢')
114
-					await context.warning_message.clear_reaction('🚫')
117
+					await context.warning_message.clear_reaction(CONFIG['trash_emoji'])
118
+					await context.warning_message.clear_reaction(CONFIG['kick_emoji'])
119
+					await context.warning_message.clear_reaction(CONFIG['ban_emoji'])
115 120
 				else:
116 121
 					context.warning_message = await self.warn(context.member.guild, msg)
117 122
 		elif len(context.messages) >= self.__warn_count(context.member.guild):
@@ -122,34 +127,34 @@ class CrossPostCog(BaseCog):
122 127
 				'\n'
123 128
 			can_delete = len(context.messages) > len(context.deleted_messages)
124 129
 			if can_delete:
125
-				msg += '\n🗑 to delete messages'
130
+				msg += f'\n{CONFIG["trash_emoji"]} to delete messages'
126 131
 			else:
127 132
 				msg += '\nAll messages deleted'
128 133
 			if not context.is_kicked:
129
-				msg += '\n👢 to kick user'
134
+				msg += f'\n{CONFIG["kick_emoji"]} to kick user'
130 135
 			elif not context.is_banned:
131 136
 				msg += '\nUser kicked'
132 137
 			if context.is_banned:
133 138
 				msg += '\nUser banned'
134 139
 			else:
135
-				msg += '\n🚫 to ban user'
140
+				msg += '\n{CONFIG["ban_emoji"]} to ban user'
136 141
 			if context.warning_message:
137 142
 				await self.update_warn(context.warning_message, msg)
138 143
 			else:
139 144
 				context.warning_message = await self.warn(context.member.guild, msg)
140 145
 				self.listen_for_reactions_to(context.warning_message, context)
141 146
 			if can_delete:
142
-				await context.warning_message.add_reaction('🗑')
147
+				await context.warning_message.add_reaction(CONFIG['trash_emoji'])
143 148
 			else:
144
-				await context.warning_message.clear_reaction('🗑')
149
+				await context.warning_message.clear_reaction(CONFIG['trash_emoji'])
145 150
 			if not context.is_kicked:
146
-				await context.warning_message.add_reaction('👢')
151
+				await context.warning_message.add_reaction(CONFIG['kick_emoji'])
147 152
 			else:
148
-				await context.warning_message.clear_reaction('👢')
153
+				await context.warning_message.clear_reaction(CONFIG['kick_emoji'])
149 154
 			if not context.is_banned:
150
-				await context.warning_message.add_reaction('🚫')
155
+				await context.warning_message.add_reaction(CONFIG['ban_emoji'])
151 156
 			else:
152
-				await context.warning_message.clear_reaction('🚫')
157
+				await context.warning_message.clear_reaction(CONFIG['ban_emoji'])
153 158
 
154 159
 	async def __delete_messages(self, context: SpamContext) -> None:
155 160
 		for message in context.messages - context.deleted_messages:
@@ -173,11 +178,11 @@ class CrossPostCog(BaseCog):
173 178
 		if context is None:
174 179
 			return
175 180
 
176
-		if emoji.name == '🗑':
181
+		if emoji.name == CONFIG['trash_emoji']:
177 182
 			await self.__delete_messages(context)
178
-		elif emoji.name == '👢':
183
+		elif emoji.name == CONFIG['kick_emoji']:
179 184
 			await self.__kick(context)
180
-		elif emoji.name == '🚫':
185
+		elif emoji.name == CONFIG['ban_emoji']:
181 186
 			await self.__ban(context)
182 187
 
183 188
 	@commands.Cog.listener()
@@ -210,8 +215,10 @@ class CrossPostCog(BaseCog):
210 215
 			allowed_types=(int, ), min_value=self.MIN_WARN_COUNT):
211 216
 			return
212 217
 		Storage.set_config_value(context.guild, self.CONFIG_KEY_WARN_COUNT, warn_count)
213
-		await context.message.reply(f'✅ Mods will be warned if a user posts ' +
214
-			f'the exact same message {warn_count} or more times within ' +
218
+		await context.message.reply(
219
+			CONFIG['success_emoji'] + ' ' +
220
+			'Mods will be warned if a user posts the exact same message ' +
221
+			f'{warn_count} or more times within ' +
215 222
 			f'{self.__message_age_seconds(context.guild)} seconds.',
216 223
 			mention_author=False)
217 224
 
@@ -239,8 +246,10 @@ class CrossPostCog(BaseCog):
239 246
 			allowed_types=(int, ), min_value=self.MIN_BAN_COUNT):
240 247
 			return
241 248
 		Storage.set_config_value(context.guild, self.CONFIG_KEY_BAN_COUNT, ban_count)
242
-		await context.message.reply(f'✅ Users will be banned if they post ' +
243
-			f'the exact same message {ban_count} or more times within ' +
249
+		await context.message.reply(
250
+			CONFIG['success_emoji'] + ' ' +
251
+			'Users will be banned if they post the exact same message ' +
252
+			f'{ban_count} or more times within ' +
244 253
 			f'{self.__message_age_seconds(context.guild)} seconds.',
245 254
 			mention_author=False)
246 255
 
@@ -249,9 +258,11 @@ class CrossPostCog(BaseCog):
249 258
 		brief='Returns the number of duplicate messages to trigger an automatic ban',
250 259
 	)
251 260
 	async def joinraid_getbancount(self, context: commands.Context):
252
-		await context.message.reply(f'ℹ️ Users will be banned if they post ' +
253
-			f'the exact same message {self.__ban_count(context.guild)} or more ' +
254
-			f'times within {self.__message_age_seconds(context.guild)} seconds.',
261
+		await context.message.reply(
262
+			CONFIG['info_emoji'] + ' ' +
263
+			'Users will be banned if they post the exact same message ' +
264
+			f'{self.__ban_count(context.guild)} or more times within ' +
265
+			f'{self.__message_age_seconds(context.guild)} seconds.',
255 266
 			mention_author=False)
256 267
 
257 268
 	@crosspost.command(
@@ -269,11 +280,15 @@ class CrossPostCog(BaseCog):
269 280
 			return
270 281
 		Storage.set_config_value(context.guild, self.CONFIG_KEY_MIN_MESSAGE_LENGTH, min_length)
271 282
 		if min_length == 0:
272
-			await context.message.reply(f'✅ All messages will count against ' +
273
-				'spam counts, regardless of length.', mention_author=False)
283
+			await context.message.reply(
284
+				CONFIG['success_emoji'] + ' ' +
285
+				f'All messages will count against spam counts, regardless ' +
286
+				'of length.', mention_author=False)
274 287
 		else:
275
-			await context.message.reply(f'✅ Only messages {min_length} ' +
276
-				f'characters or longer will count against spam counts.',
288
+			await context.message.reply(
289
+				CONFIG['success_emoji'] + ' ' +
290
+				f'Only messages {min_length} characters or longer will ' +
291
+				'count against spam counts.',
277 292
 				mention_author=False)
278 293
 
279 294
 	@crosspost.command(
@@ -283,11 +298,15 @@ class CrossPostCog(BaseCog):
283 298
 	async def joinraid_getminlength(self, context: commands.Context):
284 299
 		min_length = self.__min_message_length(context.guild)
285 300
 		if min_length == 0:
286
-			await context.message.reply(f'ℹ️ All messages will count against ' +
287
-				'spam counts, regardless of length.', mention_author=False)
301
+			await context.message.reply(
302
+				CONFIG['info_emoji'] + ' ' +
303
+				f'All messages will count against spam counts, regardless ' +
304
+				'of length.', mention_author=False)
288 305
 		else:
289
-			await context.message.reply(f'ℹ️ Only messages {min_length} ' +
290
-				f'characters or longer will count against spam counts.',
306
+			await context.message.reply(
307
+				CONFIG['info_emoji'] + ' ' +
308
+				f'Only messages {min_length} characters or longer will ' +
309
+				'count against spam counts.',
291 310
 				mention_author=False)
292 311
 
293 312
 	@crosspost.command(
@@ -304,8 +323,10 @@ class CrossPostCog(BaseCog):
304 323
 			allowed_types=(int, ), min_value=self.MIN_TIME_SPAN):
305 324
 			return
306 325
 		Storage.set_config_value(context.guild, self.CONFIG_KEY_MESSAGE_AGE, seconds)
307
-		await context.message.reply(f'✅ Only messages in the past {seconds} ' +
308
-			f'seconds will be checked for duplicates.',
326
+		await context.message.reply(
327
+			CONFIG['success_emoji'] + ' ' +
328
+			f'Only messages in the past {seconds} seconds will be checked ' +
329
+			'for duplicates.',
309 330
 			mention_author=False)
310 331
 
311 332
 	@crosspost.command(
@@ -314,6 +335,8 @@ class CrossPostCog(BaseCog):
314 335
 	)
315 336
 	async def joinraid_gettimewindow(self, context: commands.Context):
316 337
 		seconds = self.__message_age_seconds(context.guild)
317
-		await context.message.reply(f'ℹ️ Only messages in the past {seconds} ' +
318
-			'seconds will be checked for duplicates.',
338
+		await context.message.reply(
339
+			CONFIG['info_emoji'] + ' ' +
340
+			f'Only messages in the past {seconds} seconds will be checked ' +
341
+			'for duplicates.',
319 342
 			mention_author=False)

+ 26
- 19
cogs/joinraidcog.py Прегледај датотеку

@@ -162,8 +162,8 @@ class GuildContext:
162 162
 	"""
163 163
 	def __init__(self, guild_id: int):
164 164
 		self.guild_id = guild_id
165
-		self.join_warning_count = CONFIG['joinWarningCount']
166
-		self.join_warning_seconds = CONFIG['joinWarningSeconds']
165
+		self.join_warning_count = self.get_cog_default('warning_count')
166
+		self.join_warning_seconds = self.get_cog_default('warning_seconds')
167 167
 		# Non-persisted runtime state
168 168
 		self.current_raid = JoinRaidRecord()
169 169
 		self.all_raids = [ self.current_raid ] # periodically culled of old ones
@@ -254,16 +254,17 @@ class JoinRaidCog(BaseCog):
254 254
 		Returns the join rate configured for this guild.
255 255
 		"""
256 256
 		count: int = Storage.get_config_value(guild, self.STATE_KEY_RAID_COUNT) \
257
-			or CONFIG['joinWarningCount']
257
+			or self.get_cog_default('warning_count')
258 258
 		seconds: float = Storage.get_config_value(guild, self.STATE_KEY_RAID_SECONDS) \
259
-			or CONFIG['joinWarningSeconds']
259
+			or self.get_cog_default('warning_seconds')
260 260
 		return (count, seconds)
261 261
 
262 262
 	def __is_enabled(self, guild: Guild) -> bool:
263 263
 		"""
264 264
 		Returns whether join raid detection is enabled in this guild.
265 265
 		"""
266
-		return Storage.get_config_value(guild, self.STATE_KEY_ENABLED) or False
266
+		return Storage.get_config_value(guild, self.STATE_KEY_ENABLED) \
267
+			or self.get_cog_default('enabled')
267 268
 
268 269
 	# -- Commands -----------------------------------------------------------
269 270
 
@@ -288,7 +289,8 @@ class JoinRaidCog(BaseCog):
288 289
 		Storage.set_config_value(guild, self.STATE_KEY_ENABLED, True)
289 290
 		# TODO: Startup tracking if necessary
290 291
 		await context.message.reply(
291
-			'✅ ' + self.__describe_raid_settings(guild, force_enabled_status=True),
292
+			CONFIG['success_emoji'] + ' ' +
293
+			self.__describe_raid_settings(guild, force_enabled_status=True),
292 294
 			mention_author=False)
293 295
 
294 296
 	@joinraid.command(
@@ -302,7 +304,8 @@ class JoinRaidCog(BaseCog):
302 304
 		Storage.set_config_value(guild, self.STATE_KEY_ENABLED, False)
303 305
 		# TODO: Tear down tracking if necessary
304 306
 		await context.message.reply(
305
-			'✅ ' + self.__describe_raid_settings(guild, force_enabled_status=True),
307
+			CONFIG['success_emoji'] + ' ' +
308
+			self.__describe_raid_settings(guild, force_enabled_status=True),
306 309
 			mention_author=False)
307 310
 
308 311
 	@joinraid.command(
@@ -322,12 +325,14 @@ class JoinRaidCog(BaseCog):
322 325
 		guild = context.guild
323 326
 		if join_count < self.MIN_JOIN_COUNT:
324 327
 			await context.message.reply(
325
-				f'⚠️ `join_count` must be >= {self.MIN_JOIN_COUNT}',
328
+				CONFIG['warning_emoji'] + ' ' +
329
+				f'`join_count` must be >= {self.MIN_JOIN_COUNT}',
326 330
 				mention_author=False)
327 331
 			return
328 332
 		if seconds <= 0:
329 333
 			await context.message.reply(
330
-				f'⚠️ `seconds` must be > 0',
334
+				CONFIG['warning_emoji'] + ' ' +
335
+				f'`seconds` must be > 0',
331 336
 				mention_author=False)
332 337
 			return
333 338
 		Storage.set_config_values(guild, {
@@ -336,7 +341,8 @@ class JoinRaidCog(BaseCog):
336 341
 		})
337 342
 
338 343
 		await context.message.reply(
339
-			'✅ ' + self.__describe_raid_settings(guild, force_rate_status=True),
344
+			CONFIG['success_emoji'] + ' ' +
345
+			self.__describe_raid_settings(guild, force_rate_status=True),
340 346
 			mention_author=False)
341 347
 
342 348
 	@joinraid.command(
@@ -346,7 +352,8 @@ class JoinRaidCog(BaseCog):
346 352
 	async def joinraid_getrate(self, context: commands.Context):
347 353
 		'Command handler'
348 354
 		await context.message.reply(
349
-			'ℹ️ ' + self.__describe_raid_settings(context.guild, force_rate_status=True),
355
+			CONFIG['info_emoji'] + ' ' +
356
+			self.__describe_raid_settings(context.guild, force_rate_status=True),
350 357
 			mention_author=False)
351 358
 
352 359
 	# -- Listeners ----------------------------------------------------------
@@ -385,11 +392,11 @@ class JoinRaidCog(BaseCog):
385 392
 			# Either not a warning message or one we stopped tracking
386 393
 			return
387 394
 		emoji: PartialEmoji = payload.emoji
388
-		if emoji.name == CONFIG['kickEmoji']:
395
+		if emoji.name == CONFIG['kick_emoji']:
389 396
 			await raid.kick_all()
390 397
 			gc.reset_raid(message.created_at)
391 398
 			await self.__update_raid_warning(guild, raid)
392
-		elif emoji.name == CONFIG['banEmoji']:
399
+		elif emoji.name == CONFIG['ban_emoji']:
393 400
 			await raid.ban_all()
394 401
 			gc.reset_raid(message.created_at)
395 402
 			await self.__update_raid_warning(guild, raid)
@@ -470,9 +477,9 @@ class JoinRaidCog(BaseCog):
470 477
 		(message, can_kick, can_ban) = self.__describe_raid(raid)
471 478
 		raid.warning_message = await self.warn(guild, message)
472 479
 		if can_kick:
473
-			await raid.warning_message.add_reaction(CONFIG['kickEmoji'])
480
+			await raid.warning_message.add_reaction(CONFIG['kick_emoji'])
474 481
 		if can_ban:
475
-			await raid.warning_message.add_reaction(CONFIG['banEmoji'])
482
+			await raid.warning_message.add_reaction(CONFIG['ban_emoji'])
476 483
 
477 484
 	async def __update_raid_warning(self, guild: Guild, raid: JoinRaidRecord) -> None:
478 485
 		"""
@@ -483,9 +490,9 @@ class JoinRaidCog(BaseCog):
483 490
 		(message, can_kick, can_ban) = self.__describe_raid(raid)
484 491
 		await self.update_warn(raid.warning_message, message)
485 492
 		if not can_kick:
486
-			await raid.warning_message.clear_reaction(CONFIG['kickEmoji'])
493
+			await raid.warning_message.clear_reaction(CONFIG['kick_emoji'])
487 494
 		if not can_ban:
488
-			await raid.warning_message.clear_reaction(CONFIG['banEmoji'])
495
+			await raid.warning_message.clear_reaction(CONFIG['ban_emoji'])
489 496
 
490 497
 	def __describe_raid(self, raid: JoinRaidRecord) -> tuple:
491 498
 		"""
@@ -512,11 +519,11 @@ class JoinRaidCog(BaseCog):
512 519
 
513 520
 		message += '\n'
514 521
 		if any_kickable:
515
-			message += f'\nReact to this message with {CONFIG["kickEmoji"]} to kick all these users.'
522
+			message += f'\nReact to this message with {CONFIG["kick_emoji"]} to kick all these users.'
516 523
 		else:
517 524
 			message += '\nNo users left to kick.'
518 525
 		if any_bannable:
519
-			message += f'\nReact to this message with {CONFIG["banEmoji"]} to ban all these users.'
526
+			message += f'\nReact to this message with {CONFIG["ban_emoji"]} to ban all these users.'
520 527
 		else:
521 528
 			message += '\nNo users left to ban.'
522 529
 

+ 22
- 9
config.py.sample Прегледај датотеку

@@ -1,12 +1,25 @@
1 1
 # Copy this file to config.py and fill in necessary values
2 2
 CONFIG = {
3
-	'clientToken': 'token',
4
-	'joinWarningCount': 5,
5
-	'joinWarningSeconds': 5,
6
-	'commandPrefix': '$rb_',
7
-	'kickEmojiName': 'boot',
8
-	'kickEmoji': '👢',
9
-	'banEmojiName': 'no_entry_sign',
10
-	'banEmoji': '🚫',
11
-	'configPath': 'config/',
3
+	'client_token': 'token',
4
+	'command_prefix': '$rb_',
5
+	'kick_emoji': '👢',
6
+	'ban_emoji': '🚫',
7
+	'trash_emoji': '🗑',
8
+	'success_emoji': '✅',
9
+	'warning_emoji': '⚠️',
10
+	'info_emoji': 'ℹ️',
11
+	'config_path': 'config/',
12
+	'cog_defaults': {
13
+		'JoinRaidCog': {
14
+			'enabled': False,
15
+			'warning_count': 5,
16
+			'warning_seconds': 5,
17
+		},
18
+		'CrossPostCog': {
19
+			'warn_message_count': 3,
20
+			'ban_message_count': 9999,
21
+			'time_window_seconds': 120,
22
+			'min_message_length': 0,
23
+		},
24
+	},
12 25
 }

+ 2
- 2
rocketbot.py Прегледај датотеку

@@ -21,10 +21,10 @@ class Rocketbot(commands.Bot):
21 21
 intents = Intents.default()
22 22
 intents.messages = True
23 23
 intents.members = True # To get join/leave events
24
-bot = Rocketbot(command_prefix=CONFIG['commandPrefix'], intents=intents)
24
+bot = Rocketbot(command_prefix=CONFIG['command_prefix'], intents=intents)
25 25
 bot.add_cog(GeneralCog(bot))
26 26
 bot.add_cog(ConfigCog(bot))
27 27
 bot.add_cog(JoinRaidCog(bot))
28 28
 bot.add_cog(CrossPostCog(bot))
29
-bot.run(CONFIG['clientToken'], bot=True, reconnect=True)
29
+bot.run(CONFIG['client_token'], bot=True, reconnect=True)
30 30
 print('\nBot aborted')

+ 1
- 1
storage.py Прегледај датотеку

@@ -161,7 +161,7 @@ class Storage:
161 161
 		"""
162 162
 		Returns the JSON file path where guild config should be written.
163 163
 		"""
164
-		config_value: str = CONFIG['configPath']
164
+		config_value: str = CONFIG['config_path']
165 165
 		path: str = config_value if config_value.endswith('/') else f'{config_value}/'
166 166
 		return f'{path}guild_{guild.id}.json'
167 167
 

Loading…
Откажи
Сачувај