File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 2
2
from discord .ext import commands
3
3
from discord import app_commands
4
4
from settings import MEDIA_CHANNEL_ID , FB_IDEAS_CHANNEL_ID
5
+ from re import sub
5
6
6
7
class AutoThreads (commands .Cog ):
7
8
def __init__ (self , bot ):
@@ -24,7 +25,13 @@ async def auto_threads(self, msg):
24
25
await msg .channel .send (f"{ msg .author .mention } Обсуждайте в ветках!" , delete_after = 3 )
25
26
26
27
async def create_auto_thread (msg ):
27
- thread_name = msg .content [:97 ] if msg .content != "" else f"Обсуждение медиа { msg .author .display_name } "
28
- if len (msg .content ) >= 100 :
28
+ content = sub (r"https?:\/\/\S+" , "" , msg .content )
29
+ thread_name = content [:97 ]
30
+ if len (thread_name ) == 97 :
29
31
thread_name += "..."
30
- await msg .create_thread (name = thread_name )
32
+ try :
33
+ await msg .create_thread (name = thread_name )
34
+ except discord .errors .HTTPException :
35
+ channel_name = sub (r"[^\w-]*" , "" , msg .channel .name )
36
+ await msg .create_thread (name = f"Обсуждение { channel_name } { msg .author .display_name } " )
37
+
You can’t perform that action at this time.
0 commit comments