async def on_message(self, message):
streamables = re.compile(r'streamable(\.com)\/([\w-]{2,50})')
if streamables.search(message.content) and message.channel.id == 363835464219754498:
url = message.content
print(url)
我希望它只显示链接,即使它之前或之后有什么东西。我怎么能这样做?
答案 0 :(得分:0)
存储streamables.search(message.content)
的结果以获取匹配对象,然后调用group()
以获取匹配的内容。
async def on_message(self, message):
streamables = re.compile(r'streamable(\.com)\/([\w-]{2,50})')
match = streamables.search(message.content)
if match and message.channel.id == 363835464219754498:
url = match.group()
print(url)