Spaces:
Runtime error
Runtime error
KonradSzafer
commited on
Commit
•
f6c81a6
1
Parent(s):
2014dcd
channel ids parsing update
Browse files- discord_bot/client/client.py +13 -1
discord_bot/client/client.py
CHANGED
@@ -46,13 +46,25 @@ class DiscordClient(discord.Client):
|
|
46 |
'The number of last messages in context should be at least 1'
|
47 |
|
48 |
self.qa_engine: QAEngine = qa_engine
|
49 |
-
self.channel_ids: list[int] =
|
50 |
self.num_last_messages: int = num_last_messages
|
51 |
self.use_names_in_context: bool = use_names_in_context
|
52 |
self.enable_commands: bool = enable_commands
|
53 |
self.debug: bool = debug
|
54 |
self.min_messgae_len: int = 1800
|
55 |
self.max_message_len: int = 2000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
|
58 |
async def on_ready(self):
|
|
|
46 |
'The number of last messages in context should be at least 1'
|
47 |
|
48 |
self.qa_engine: QAEngine = qa_engine
|
49 |
+
self.channel_ids: list[int] = DiscordClient._process_channel_ids(channel_ids)
|
50 |
self.num_last_messages: int = num_last_messages
|
51 |
self.use_names_in_context: bool = use_names_in_context
|
52 |
self.enable_commands: bool = enable_commands
|
53 |
self.debug: bool = debug
|
54 |
self.min_messgae_len: int = 1800
|
55 |
self.max_message_len: int = 2000
|
56 |
+
|
57 |
+
|
58 |
+
@staticmethod
|
59 |
+
def _process_channel_ids(channel_ids) -> list[int]:
|
60 |
+
if isinstance(channel_ids, str):
|
61 |
+
return eval(channel_ids)
|
62 |
+
elif isinstance(channel_ids, list):
|
63 |
+
return channel_ids
|
64 |
+
elif isinstance(channel_ids, int):
|
65 |
+
return [channel_ids]
|
66 |
+
else:
|
67 |
+
return []
|
68 |
|
69 |
|
70 |
async def on_ready(self):
|