MCPcopy
hub / github.com/vasusen-code/SaveRestrictedContentBot / get_link

Function get_link

main/plugins/helpers.py:29–39  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

27#to get the url from event
28
29def get_link(string):
30 regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))"
31 url = re.findall(regex,string)
32 try:
33 link = [x[0] for x in url][0]
34 if link:
35 return link
36 else:
37 return False
38 except Exception:
39 return False
40
41#Screenshot---------------------------------------------------------------------------------------------------------------
42

Callers 2

cloneFunction · 0.90
_batchFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected