This repository was archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
240 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,106 @@ | ||
from discord.ext import commands | ||
from discord import utils | ||
import discord | ||
import sys | ||
|
||
blacklist_servers = [795231055954313236] | ||
# blacklist_servers = [795231055954313236, 773185292211453974] | ||
|
||
class Nqn(commands.Cog, name='Nqn'): | ||
class emoji(commands.Cog): | ||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
def cog_check(self, ctx): | ||
if ctx.guild.id in blacklist_servers: | ||
return | ||
# def cog_check(self, ctx): | ||
# if ctx.guild.id in blacklist_servers: | ||
# return | ||
|
||
async def getemote(self, arg): | ||
emoji = utils.get(self.bot.emojis, name = arg.strip(":")) | ||
async def getemote(self, arg): | ||
emoji = utils.get(self.bot.emojis, name = arg.strip(":")) | ||
|
||
if emoji is not None: | ||
if emoji.animated: | ||
add = "a" | ||
else: | ||
add = "" | ||
return f"<{add}:{emoji.name}:{emoji.id}>" | ||
if emoji is not None: | ||
if emoji.animated: | ||
add = "a" | ||
else: | ||
return None | ||
|
||
async def getinstr(self, content): | ||
ret = [] | ||
|
||
spc = content.split(" ") | ||
cnt = content.split(":") | ||
|
||
if len(cnt) > 1: | ||
for item in spc: | ||
if item.count(":") > 1: | ||
wr = "" | ||
if item.startswith("<") and item.endswith(">"): | ||
ret.append(item) | ||
else: | ||
cnt = 0 | ||
for i in item: | ||
if cnt == 2: | ||
add = "" | ||
return f"<{add}:{emoji.name}:{emoji.id}>" | ||
else: | ||
return None | ||
|
||
async def getinstr(self, content): | ||
ret = [] | ||
spc = content.split(" ") | ||
cnt = content.split(":") | ||
|
||
if len(cnt) > 1: | ||
for item in spc: | ||
if item.count(":") > 1: | ||
wr = "" | ||
if item.startswith("<") and item.endswith(">"): | ||
ret.append(item) | ||
else: | ||
cnt = 0 | ||
for i in item: | ||
if cnt == 2: | ||
aaa = wr.replace(" ", "") | ||
ret.append(aaa) | ||
wr = "" | ||
cnt = 0 | ||
|
||
if i != ":": | ||
wr += i | ||
else: | ||
if wr == "" or cnt == 1: | ||
wr += " : " | ||
cnt += 1 | ||
else: | ||
aaa = wr.replace(" ", "") | ||
ret.append(aaa) | ||
wr = "" | ||
cnt = 0 | ||
wr = ":" | ||
cnt = 1 | ||
|
||
if i != ":": | ||
wr += i | ||
else: | ||
if wr == "" or cnt == 1: | ||
wr += " : " | ||
cnt += 1 | ||
else: | ||
aaa = wr.replace(" ", "") | ||
ret.append(aaa) | ||
wr = ":" | ||
cnt = 1 | ||
|
||
aaa = wr.replace(" ", "") | ||
ret.append(aaa) | ||
else: | ||
ret.append(item) | ||
else: | ||
return content | ||
aaa = wr.replace(" ", "") | ||
ret.append(aaa) | ||
else: | ||
ret.append(item) | ||
else: | ||
return content | ||
|
||
return ret | ||
return ret | ||
|
||
|
||
# i added extra indent by mistake -_- | ||
|
||
@commands.Cog.listener() | ||
async def on_message(self, message): | ||
if message.author.bot: | ||
return | ||
|
||
if ":" in message.content: | ||
msg = await self.getinstr(message.content) | ||
ret = "" | ||
em = False | ||
smth = message.content.split(":") | ||
if len(smth) > 1: | ||
for word in msg: | ||
if word.startswith(":") and word.endswith(":") and len(word) > 1: | ||
emoji = await self.getemote(word) | ||
if emoji is not None: | ||
em = True | ||
ret += f" {emoji}" | ||
else: | ||
ret += f" {word}" | ||
@commands.Cog.listener() | ||
async def on_message(self, message): | ||
if message.author.bot: | ||
return | ||
|
||
if ":" in message.content: | ||
msg = await self.getinstr(message.content) | ||
ret = "" | ||
em = False | ||
smth = message.content.split(":") | ||
if len(smth) > 1: | ||
for word in msg: | ||
if word.startswith(":") and word.endswith(":") and len(word) > 1: | ||
emoji = await self.getemote(word) | ||
if emoji is not None: | ||
em = True | ||
ret += f" {emoji}" | ||
else: | ||
ret += f" {word}" | ||
else: | ||
ret += f" {word}" | ||
|
||
else: | ||
ret += msg | ||
else: | ||
ret += msg | ||
|
||
|
||
if em: | ||
webhooks = await message.channel.webhooks() | ||
webhook = utils.get(webhooks, name = "Imposter NQN") | ||
if webhook is None: | ||
webhook = await message.channel.create_webhook(name = "Imposter NQN") | ||
|
||
await webhook.send(ret, username = message.author.name, avatar_url = message.author.avatar_url) | ||
await message.delete() | ||
if em: | ||
webhooks = await message.channel.webhooks() | ||
webhook = utils.get(webhooks, name = "SPIKE NQN") | ||
if webhook is None: | ||
webhook = await message.channel.create_webhook(name = "SPIKE NQN") | ||
await webhook.send(ret, username = message.author.name, avatar_url = message.author.avatar_url) | ||
await message.delete() | ||
|
||
def setup(Bot): | ||
Bot.add_cog(Nqn(Bot)) | ||
print("Nqn cog is loaded!") | ||
def setup(bot): | ||
bot.add_cog(emoji(bot)) |
Oops, something went wrong.