@@ -259,7 +259,7 @@ Module.FixServices = {
259259 [" pixiv.net" ] = " ppxiv.net" ,
260260 [" reddit.com" ] = " rxddit.com" ,
261261 -- Currently broken
262- -- ["threads.net"] = "vxthreads .net",
262+ [" threads.net" ] = " fixthreads .net" ,
263263 [" tiktok.com" ] = " tnktok.com" ,
264264 [" tumblr.com" ] = " tpmblr.com" ,
265265 [" twitch.tv" ] = " fxtwitch.tv" ,
@@ -412,11 +412,10 @@ function Module:Replacer(match, config, data)
412412 -- end
413413 -- end
414414
415- for service , fix in pairs (self .FixServices ) do
416- if host :match (service ) then
417- local newHost = host :gsub (service , fix )
418- return protocol .. newHost .. path .. queryString
419- end
415+ if self .FixServices [host ] then
416+ local fix = self .FixServices [host ]
417+ local newHost = host :gsub (host , fix )
418+ return protocol .. newHost .. path .. queryString
420419 end
421420
422421 if not queryString or # queryString == 0 or queryString == " ?" then
490489--- @type table<string , table<string , table>>
491490local _attachments = {}
492491
492+ local ansiColoursForeground = {
493+ black = 30 ,
494+ red = 31 ,
495+ green = 32 ,
496+ yellow = 33 ,
497+ blue = 34 ,
498+ magenta = 35 ,
499+ cyan = 36 ,
500+ white = 37 ,
501+ }
502+
503+ --- @param rule string
504+ --- @return string
505+ local function formatRule (rule )
506+ local splitRule = rule :split (" @" )
507+
508+ if not splitRule [2 ] then
509+ return string.format (" \x1b [%dm%s\x1b [0m" , ansiColoursForeground .green , splitRule [1 ])
510+ end
511+
512+ local colour = splitRule [1 ] == " *" and ansiColoursForeground .cyan or ansiColoursForeground .green
513+
514+ local splitted = splitRule [2 ]:split (" %." )
515+
516+ return string.format (" \x1b [%dm%s\x1b [0m\x1b [%dm@\x1b [0m\x1b [%dm%s\x1b [0m\x1b [%dm.\x1b [0m\x1b [%dm%s\x1b [0m" , colour ,
517+ splitRule [1 ], ansiColoursForeground .magenta , ansiColoursForeground .yellow , splitted [1 ],
518+ ansiColoursForeground .blue ,
519+ ansiColoursForeground .red , splitted [2 ])
520+ end
521+
493522function Module :OnLoaded ()
494523 self :CreateRules ()
495524
@@ -595,10 +624,10 @@ function Module:OnLoaded()
595624 return cmd :reply (Bot :Format (cmd .guild , ' CLEAN_URLS_NO_RULES' ))
596625 end
597626
598- local result = string.format (" ## %s\n ```yaml \n " , Bot :Format (cmd .guild , ' CLEAN_URLS_RULES_HEADER' ))
627+ local result = string.format (" ## %s\n ```ansi \n " , Bot :Format (cmd .guild , ' CLEAN_URLS_RULES_HEADER' ))
599628
600629 for i , rule in ipairs (rules ) do
601- result = result .. i .. " . " .. rule .. " \n "
630+ result = result .. i .. " . " .. formatRule ( rule ) .. " \n "
602631 end
603632
604633 result = result .. " ```"
@@ -719,15 +748,13 @@ function Module:OnMessageCreate(message)
719748
720749 local deleteTimeout = (config .ButtonTimeout or 10000 )
721750
722- setTimeout (deleteTimeout , function ()
723- wrap (function ()
724- if self .UsersHanging [message .author .id ] then
725- client ._api :editWebhookMessage (webhook .id , webhook .token , msg .id , {
726- components = {}
727- }, { thread_id = threadId })
728- self .UsersHanging [message .author .id ] = nil
729- end
730- end )()
751+ Bot :ScheduleAction (os.time () + deleteTimeout , function ()
752+ if self .UsersHanging [message .author .id ] then
753+ client ._api :editWebhookMessage (webhook .id , webhook .token , msg .id , {
754+ components = {}
755+ }, { thread_id = threadId })
756+ self .UsersHanging [message .author .id ] = nil
757+ end
731758 end )
732759end
733760
@@ -758,7 +785,7 @@ function Module:OnInteractionCreate(interaction)
758785
759786 local interactionAuthorId = interaction .member .user .id
760787
761- if authorId ~= interactionAuthorId then
788+ if authorId ~= interactionAuthorId and not interaction . member : hasPermission ( interaction . channel , ' manageMessages ' ) then
762789 return interaction :respond ({
763790 type = enums .interactionResponseType .channelMessageWithSource ,
764791 data = {
0 commit comments