mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Escape everyone/here mentions
This commit is contained in:
parent
550dfb5875
commit
fc93b02639
@ -1,5 +1,6 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from .utils.chat_formatting import *
|
||||||
from random import randint
|
from random import randint
|
||||||
from random import choice as randchoice
|
from random import choice as randchoice
|
||||||
import datetime
|
import datetime
|
||||||
@ -32,6 +33,7 @@ class General:
|
|||||||
|
|
||||||
To denote multiple choices, you should use double quotes.
|
To denote multiple choices, you should use double quotes.
|
||||||
"""
|
"""
|
||||||
|
choices = [escape_mass_mentions(choice) for choice in choices]
|
||||||
if len(choices) < 2:
|
if len(choices) < 2:
|
||||||
await self.bot.say('Not enough choices to pick from.')
|
await self.bot.say('Not enough choices to pick from.')
|
||||||
else:
|
else:
|
||||||
@ -133,7 +135,7 @@ class General:
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def lmgtfy(self, *, search_terms : str):
|
async def lmgtfy(self, *, search_terms : str):
|
||||||
"""Creates a lmgtfy link"""
|
"""Creates a lmgtfy link"""
|
||||||
search_terms = search_terms.replace(" ", "+")
|
search_terms = escape_mass_mentions(search_terms.replace(" ", "+"))
|
||||||
await self.bot.say("http://lmgtfy.com/?q={}".format(search_terms))
|
await self.bot.say("http://lmgtfy.com/?q={}".format(search_terms))
|
||||||
|
|
||||||
@commands.command(no_pm=True, hidden=True)
|
@commands.command(no_pm=True, hidden=True)
|
||||||
@ -163,7 +165,7 @@ class General:
|
|||||||
roles = [x.name for x in user.roles if x.name != "@everyone"]
|
roles = [x.name for x in user.roles if x.name != "@everyone"]
|
||||||
if not roles: roles = ["None"]
|
if not roles: roles = ["None"]
|
||||||
data = "```python\n"
|
data = "```python\n"
|
||||||
data += "Name: {}\n".format(user)
|
data += "Name: {}\n".format(escape_mass_mentions(str(user)))
|
||||||
data += "ID: {}\n".format(user.id)
|
data += "ID: {}\n".format(user.id)
|
||||||
passed = (ctx.message.timestamp - user.created_at).days
|
passed = (ctx.message.timestamp - user.created_at).days
|
||||||
data += "Created: {} ({} days ago)\n".format(user.created_at, passed)
|
data += "Created: {} ({} days ago)\n".format(user.created_at, passed)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from .utils.dataIO import fileIO
|
from .utils.dataIO import fileIO
|
||||||
|
from .utils.chat_formatting import *
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -24,6 +25,7 @@ class Streams:
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def hitbox(self, stream: str):
|
async def hitbox(self, stream: str):
|
||||||
"""Checks if hitbox stream is online"""
|
"""Checks if hitbox stream is online"""
|
||||||
|
stream = escape_mass_mentions(stream)
|
||||||
online = await self.hitbox_online(stream)
|
online = await self.hitbox_online(stream)
|
||||||
if online is True:
|
if online is True:
|
||||||
await self.bot.say("http://www.hitbox.tv/{}/"
|
await self.bot.say("http://www.hitbox.tv/{}/"
|
||||||
@ -38,6 +40,7 @@ class Streams:
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def twitch(self, stream: str):
|
async def twitch(self, stream: str):
|
||||||
"""Checks if twitch stream is online"""
|
"""Checks if twitch stream is online"""
|
||||||
|
stream = escape_mass_mentions(stream)
|
||||||
online = await self.twitch_online(stream)
|
online = await self.twitch_online(stream)
|
||||||
if online is True:
|
if online is True:
|
||||||
await self.bot.say("http://www.twitch.tv/{} "
|
await self.bot.say("http://www.twitch.tv/{} "
|
||||||
@ -52,6 +55,7 @@ class Streams:
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def beam(self, stream: str):
|
async def beam(self, stream: str):
|
||||||
"""Checks if beam stream is online"""
|
"""Checks if beam stream is online"""
|
||||||
|
stream = escape_mass_mentions(stream)
|
||||||
online = await self.beam_online(stream)
|
online = await self.beam_online(stream)
|
||||||
if online is True:
|
if online is True:
|
||||||
await self.bot.say("https://beam.pro/{} is online!".format(stream))
|
await self.bot.say("https://beam.pro/{} is online!".format(stream))
|
||||||
@ -72,6 +76,7 @@ class Streams:
|
|||||||
@streamalert.command(name="twitch", pass_context=True)
|
@streamalert.command(name="twitch", pass_context=True)
|
||||||
async def twitch_alert(self, ctx, stream: str):
|
async def twitch_alert(self, ctx, stream: str):
|
||||||
"""Adds/removes twitch alerts from the current channel"""
|
"""Adds/removes twitch alerts from the current channel"""
|
||||||
|
stream = escape_mass_mentions(stream)
|
||||||
channel = ctx.message.channel
|
channel = ctx.message.channel
|
||||||
check = await self.twitch_exists(stream)
|
check = await self.twitch_exists(stream)
|
||||||
if check is False:
|
if check is False:
|
||||||
@ -115,6 +120,7 @@ class Streams:
|
|||||||
@streamalert.command(name="hitbox", pass_context=True)
|
@streamalert.command(name="hitbox", pass_context=True)
|
||||||
async def hitbox_alert(self, ctx, stream: str):
|
async def hitbox_alert(self, ctx, stream: str):
|
||||||
"""Adds/removes hitbox alerts from the current channel"""
|
"""Adds/removes hitbox alerts from the current channel"""
|
||||||
|
stream = escape_mass_mentions(stream)
|
||||||
channel = ctx.message.channel
|
channel = ctx.message.channel
|
||||||
check = await self.hitbox_online(stream)
|
check = await self.hitbox_online(stream)
|
||||||
if check is None:
|
if check is None:
|
||||||
@ -158,6 +164,7 @@ class Streams:
|
|||||||
@streamalert.command(name="beam", pass_context=True)
|
@streamalert.command(name="beam", pass_context=True)
|
||||||
async def beam_alert(self, ctx, stream: str):
|
async def beam_alert(self, ctx, stream: str):
|
||||||
"""Adds/removes beam alerts from the current channel"""
|
"""Adds/removes beam alerts from the current channel"""
|
||||||
|
stream = escape_mass_mentions(stream)
|
||||||
channel = ctx.message.channel
|
channel = ctx.message.channel
|
||||||
check = await self.beam_online(stream)
|
check = await self.beam_online(stream)
|
||||||
if check is None:
|
if check is None:
|
||||||
|
|||||||
@ -14,4 +14,13 @@ def box(text):
|
|||||||
return "```"+str(text)+"```"
|
return "```"+str(text)+"```"
|
||||||
|
|
||||||
def inline(text):
|
def inline(text):
|
||||||
return "`"+str(text)+"`"
|
return "`"+str(text)+"`"
|
||||||
|
|
||||||
|
def escape_mass_mentions(text):
|
||||||
|
words = {
|
||||||
|
"@everyone": "@\u200beveryone",
|
||||||
|
"@here": "@\u200bhere"
|
||||||
|
}
|
||||||
|
for k, v in words.items():
|
||||||
|
text = text.replace(k, v)
|
||||||
|
return text
|
||||||
Loading…
x
Reference in New Issue
Block a user