Use regex to find the twitter links so it doesnt mess up webarchive links
This commit is contained in:
parent
6a840a1c61
commit
fe4c92c3ea
15
app/bot.py
15
app/bot.py
@ -3,6 +3,7 @@ from discord.ext import commands
|
|||||||
import core_utils
|
import core_utils
|
||||||
import discord
|
import discord
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
@ -27,6 +28,16 @@ requests_cache.install_cache(expire_after=300)
|
|||||||
@bot.event
|
@bot.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print(f"{bot.user.name} has connected to Discord!")
|
print(f"{bot.user.name} has connected to Discord!")
|
||||||
|
for server in bot.guilds:
|
||||||
|
if server.name in [
|
||||||
|
# "no officer it's hi how r u",
|
||||||
|
"Aeturnum",
|
||||||
|
"Naked Knights",
|
||||||
|
"MadsenHouse",
|
||||||
|
"Safety Zone",
|
||||||
|
"R3 Server",
|
||||||
|
]:
|
||||||
|
bot.leave_guild(server)
|
||||||
if os.getenv("DRAGON_ENV") == "prod":
|
if os.getenv("DRAGON_ENV") == "prod":
|
||||||
# await bot.get_channel(152921472304676865).send("I have reconnected")
|
# await bot.get_channel(152921472304676865).send("I have reconnected")
|
||||||
|
|
||||||
@ -124,7 +135,9 @@ async def fix_social_media_links(ctx):
|
|||||||
if ctx.author.id == bot.user.id:
|
if ctx.author.id == bot.user.id:
|
||||||
return
|
return
|
||||||
for k in correct_domains.keys():
|
for k in correct_domains.keys():
|
||||||
if k in ctx.content or "www.%s.com" % k in ctx.content:
|
if re.search(f"^{k}.*", ctx.content) or re.search(
|
||||||
|
f"^www.{k}.com.*", ctx.content
|
||||||
|
):
|
||||||
await ctx.channel.send(
|
await ctx.channel.send(
|
||||||
"%s said:\n%s"
|
"%s said:\n%s"
|
||||||
% (
|
% (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user