7 changed files with 298 additions and 12 deletions
@ -0,0 +1,110 @@ |
|||||
|
import discord |
||||
|
from ..exceptions import * |
||||
|
from ..bot import DiscordClient |
||||
|
from ..player import Player |
||||
|
|
||||
|
class Extension: |
||||
|
auth_channel = 960796520247091201 |
||||
|
default_role = 684828780040421388 |
||||
|
def __init__(self, core: DiscordClient, enabled = True): |
||||
|
if not enabled: return None |
||||
|
@core.tree.command(name = "register", description = "Привязать дискорд к стиму") |
||||
|
@discord.app_commands.describe(profile=core.ANY_INPUT) |
||||
|
async def register( |
||||
|
interaction: discord.Interaction, |
||||
|
profile: str |
||||
|
): |
||||
|
await interaction.response.defer(thinking=True) |
||||
|
try: |
||||
|
steam64 = await core.GetSteam64OfDiscord(interaction.user) |
||||
|
return await interaction.followup.send('У тебя уже привязан профиль, стоит его для начала отвязать перед новой привязкой', ephemeral=True) |
||||
|
except: |
||||
|
pass |
||||
|
|
||||
|
try: |
||||
|
profile = await core.GetPlayer(profile, "", True) |
||||
|
except: |
||||
|
return await interaction.followup.send(""" |
||||
|
Невозможно в данный момент времени привязать такой профиль, причины: |
||||
|
1)Ты не играл на наших серверах, поэтому нельзя получить ид стима |
||||
|
2)Если ты кидал ссылку, то твоя ссылка является невалидной, попробуй другой формат |
||||
|
3)Сервисы стим устали |
||||
|
4)Сервисы факты13 устали |
||||
|
|
||||
|
Попробуй по-другому или подожди...""", ephemeral=True) |
||||
|
|
||||
|
profile_discord_id = await profile.GetDiscordId() |
||||
|
if profile_discord_id != 0: |
||||
|
return await interaction.followup.send(f'Профиль {profile.community_url} уже привязан к пользователю <@{profile_discord_id}>, если у тебя угнали профиль, напиши об этом <@142269939783434240>', ephemeral=True) |
||||
|
|
||||
|
result = await profile.CreateDiscordId(interaction.user.id) |
||||
|
if not result: |
||||
|
return await interaction.followup.send('Кароч нельзя привязать профиль(((', ephemeral=True) |
||||
|
|
||||
|
await self.final_stage(interaction.user) |
||||
|
return await interaction.followup.send(f'Ты крут!', ephemeral=True) |
||||
|
|
||||
|
@core.tree.command(name = "unregister", description = "Отвязать профиль") |
||||
|
@discord.app_commands.describe() |
||||
|
async def unregister( |
||||
|
interaction: discord.Interaction |
||||
|
): |
||||
|
await interaction.response.defer(thinking=True) |
||||
|
steam64 = await core.GetSteam64OfDiscord(interaction.user) |
||||
|
player: Player = await core.GetPlayer(steam64, steam64, False) |
||||
|
await player.RemoveDiscordId(interaction.user.id) |
||||
|
await interaction.followup.send(f'Профиль отвязан, друг', ephemeral=True) |
||||
|
await self.remove_role(interaction.user.id) |
||||
|
return |
||||
|
|
||||
|
@core.event |
||||
|
async def on_member_join(member): |
||||
|
if member.guild.id != core.main_server_id: |
||||
|
return |
||||
|
|
||||
|
try: |
||||
|
core.GetSteam64OfDiscord(member, True) |
||||
|
self.final_stage(member) |
||||
|
return |
||||
|
except: |
||||
|
pass |
||||
|
|
||||
|
auth_channel: discord.TextChannel = core.fetch_channel(self.auth_channel) |
||||
|
welcome_message = f"Привет <@{member.id}>!!!\n" + """ |
||||
|
Добро пожаловать на оффициальный сервер дискорда факты 13! |
||||
|
Чтоб войти и получить роль для доступа ко всему, используй команду /register cо своим профилем стима или никнейм из тф. |
||||
|
Например: /register отдыхаем |
||||
|
|
||||
|
Если все правильно, то этот канал для тебя исчезнет и ты получишь доступ ко всем остальным каналам. |
||||
|
> Так-же ты можешь прочитать местные правила <#734497550232453340> Если ты их видишь)) |
||||
|
> Если не получается получить роль через бота пиши <@142269939783434240>""" |
||||
|
return await auth_channel.send(content=welcome_message, delete_after=120) |
||||
|
|
||||
|
@core.event |
||||
|
async def on_message(message: discord.Message): |
||||
|
if message.guild.id != core.main_server_id: |
||||
|
return |
||||
|
|
||||
|
if message.channel.id != self.auth_channel: |
||||
|
return |
||||
|
|
||||
|
if message.author == core.user or message.author.id == 142269939783434240: |
||||
|
return |
||||
|
|
||||
|
try: |
||||
|
await message.delete() |
||||
|
except Exception as err: |
||||
|
print(f"Cannot delete message from auth channel, error: {err}") |
||||
|
return |
||||
|
|
||||
|
async def final_stage(self, user: discord.Member): |
||||
|
try: |
||||
|
await user.add_roles(discord.Role(id=self.default_role)) |
||||
|
except Exception as err: |
||||
|
print(f"Cannot set role({self.default_role}) to {user}, error: {err}") |
||||
|
|
||||
|
async def remove_role(self, user: discord.Member): |
||||
|
try: |
||||
|
await user.remove_roles(discord.Role(id=self.default_role)) |
||||
|
except Exception as err: |
||||
|
print(f"Cannot remove role({self.default_role}) from {user}, error: {err}") |
@ -0,0 +1,51 @@ |
|||||
|
from discord.ext import tasks |
||||
|
import discord |
||||
|
from ..bot import DiscordClient |
||||
|
import re |
||||
|
|
||||
|
class Extension: |
||||
|
allow_domains = ["steamcommunity.com","s.team","tenor.com","tf2.pblr-nyk.pro", "pblr-nyk.pro", "youtu.be", "youtube.com"] |
||||
|
WEB_URL_REGEX = r"""(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])|(?:(?<!@)[a-z0-9]+(?:[.\-][a-z0-9]+)*[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\b/?(?!@)))""" |
||||
|
allow_roles = [744928190895489074, 976924951447736453] |
||||
|
def __init__(self, core: DiscordClient): |
||||
|
@core.event |
||||
|
async def on_message(message: discord.Message): |
||||
|
if not message.guild: |
||||
|
return |
||||
|
|
||||
|
if message.guild.id != core.main_server_id: |
||||
|
return |
||||
|
|
||||
|
if message.author == core.user: |
||||
|
return |
||||
|
|
||||
|
if not message.content: |
||||
|
return |
||||
|
|
||||
|
for maybe_url in reversed(re.findall(self.WEB_URL_REGEX, message.content)): |
||||
|
for rid in self.allow_roles: |
||||
|
if message.author.get_role(rid): |
||||
|
return |
||||
|
|
||||
|
sub_continue = False |
||||
|
for domain in self.allow_domains: |
||||
|
if domain in maybe_url[:26]: |
||||
|
sub_continue = True |
||||
|
break |
||||
|
if sub_continue: |
||||
|
continue |
||||
|
|
||||
|
print(f"Found url from {message.author} with url {maybe_url}") |
||||
|
|
||||
|
try: |
||||
|
await message.reply(f"{message.author.mention} ссылки кидать нельзя!\nhttps://tf2.pblr-nyk.pro/fekalis/nigger_maslo.gif", delete_after = 60) |
||||
|
except Exception as err: |
||||
|
print(f"Cannot send message about delete url, error: {err}") |
||||
|
|
||||
|
try: |
||||
|
await message.delete() |
||||
|
except Exception as err: |
||||
|
print(f"Cannot delete message with url, error: {err}") |
||||
|
return |
||||
|
|
||||
|
return |
@ -0,0 +1,58 @@ |
|||||
|
from discord.ext import tasks |
||||
|
import discord |
||||
|
from ..bot import DiscordClient |
||||
|
|
||||
|
class Extension: |
||||
|
core = None |
||||
|
track_guild_id = 0 |
||||
|
track_channel_id = 712673654487515238 |
||||
|
track_webhook_id = 740681080557797499 |
||||
|
track_role_id = 744928190895489074 |
||||
|
|
||||
|
no_reason = {} |
||||
|
|
||||
|
def __init__(self, core: DiscordClient): |
||||
|
self.core = core |
||||
|
self.track_guild_id = core.main_server_id |
||||
|
|
||||
|
self.webhook_reaction_translate = { |
||||
|
"😘":(self.core.loaded_extensions['ban'], {"profile":"", "reason":"", "minutes":0, "requester":""}), |
||||
|
"🔨":(self.core.loaded_extensions['ban'], {"profile":"", "reason":"", "minutes":30, "requester":""}), |
||||
|
"⚒️":(self.core.loaded_extensions['ban'], {"profile":"", "reason":"", "minutes":120, "requester":""}), |
||||
|
"📨":(self.no_reason, {"requester":""}), |
||||
|
"🦵":"kick {reported_steam}", |
||||
|
"🔇":"mute {reported_steam}", |
||||
|
"😇":"unban {reported_steam}", |
||||
|
"hueglot:713139400028061767":"kick {original_steam}", |
||||
|
"🔍":"{reported_steam}", |
||||
|
"🔎":"{original_steam}" |
||||
|
} |
||||
|
|
||||
|
@core.event |
||||
|
async def on_message(message: discord.Message): |
||||
|
if message.webhook_id != self.track_webhook_id: |
||||
|
return |
||||
|
|
||||
|
for emoji in list(self.webhook_reaction_translate.keys()): |
||||
|
try: |
||||
|
message.add_reaction(emoji=emoji) |
||||
|
except Exception as err: |
||||
|
print(f"Cannot add reaction on webhook") |
||||
|
return |
||||
|
|
||||
|
@core.event |
||||
|
async def on_reaction_add(reaction: discord.Reaction, user: discord.User): |
||||
|
if reaction.message.webhook_id != self.track_webhook_id: |
||||
|
return |
||||
|
|
||||
|
if reaction.me: |
||||
|
return |
||||
|
|
||||
|
if str(reaction.emoji) in self.webhook_reaction_translate.keys(): |
||||
|
executor, kwargs = self.webhook_reaction_translate[str(reaction.emoji)] |
||||
|
if "requester" in kwargs: |
||||
|
kwargs["requester"] = user.id |
||||
|
|
||||
|
|
||||
|
async def null_reason(self, requester): |
||||
|
self.no_reason[requester] = "no reason" |
Loading…
Reference in new issue