mirror of
https://github.com/TotalFreedomMC/TotalFreedomBot.git
synced 2024-12-22 15:44:57 +00:00
Update main.py
This commit is contained in:
parent
591a86b37e
commit
f35422689b
1 changed files with 36 additions and 14 deletions
50
main.py
50
main.py
|
@ -1,15 +1,15 @@
|
||||||
import discord
|
|
||||||
import os
|
import os
|
||||||
import time
|
|
||||||
import logscript
|
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
from unicode import *
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from checks import *
|
|
||||||
from functions import *
|
import logscript
|
||||||
|
from functions import config_entry, get_prefix, hit_endpoint, get_server_status
|
||||||
|
from unicode import clipboard
|
||||||
|
|
||||||
print = logscript.logging.getLogger().critical
|
print = logscript.logging.getLogger().critical
|
||||||
|
|
||||||
|
@ -20,6 +20,28 @@ intents = discord.Intents.all()
|
||||||
bot = commands.Bot(command_prefix=get_prefix, case_insensitive=True, description='TotalFreedom bot help command',
|
bot = commands.Bot(command_prefix=get_prefix, case_insensitive=True, description='TotalFreedom bot help command',
|
||||||
intents=intents)
|
intents=intents)
|
||||||
|
|
||||||
|
bot.server_liaison = config_entry("server_liaison")
|
||||||
|
bot.event_host = config_entry("event_host")
|
||||||
|
bot.server_banned = config_entry("server_banned")
|
||||||
|
bot.senior_admin = config_entry("senior_admin")
|
||||||
|
bot.admin = config_entry("admin")
|
||||||
|
bot.master_builder = config_entry("master_builder")
|
||||||
|
bot.reports_channel_id = config_entry("reports_channel_id")
|
||||||
|
bot.archived_reports_channel_id = config_entry("archived_reports_channel_id")
|
||||||
|
bot.guild_id = config_entry("guild_id")
|
||||||
|
bot.mentions_channel_id = config_entry("mentions_channel_id")
|
||||||
|
bot.discord_admin = config_entry("discord_admin")
|
||||||
|
bot.discord_mod = config_entry("discord_mod")
|
||||||
|
bot.devs = config_entry("devs")
|
||||||
|
bot.bot_logs_channel_id = config_entry("bot_logs_channel_id")
|
||||||
|
bot.executive = config_entry("executive")
|
||||||
|
bot.asst_exec = config_entry("asst_exec")
|
||||||
|
bot.developer = config_entry("developer")
|
||||||
|
bot.creative_designer = config_entry("creative_designer")
|
||||||
|
bot.server_chat = config_entry("server_chat")
|
||||||
|
bot.verification_role = config_entry("verification_role")
|
||||||
|
bot.server_chat_2 = config_entry("server_chat_2")
|
||||||
|
|
||||||
extensions = [
|
extensions = [
|
||||||
"commands.moderation",
|
"commands.moderation",
|
||||||
"commands.server_commands",
|
"commands.server_commands",
|
||||||
|
@ -44,21 +66,21 @@ async def on_message(message):
|
||||||
if isinstance(message.channel, discord.channel.DMChannel):
|
if isinstance(message.channel, discord.channel.DMChannel):
|
||||||
print(f'{message.author} DM: {message.content}')
|
print(f'{message.author} DM: {message.content}')
|
||||||
return
|
return
|
||||||
elif message.guild and message.author is message.guild.me and message.channel.id == reports_channel_id:
|
elif message.guild and message.author is message.guild.me and message.channel.id == bot.reports_channel_id:
|
||||||
await message.add_reaction(clipboard)
|
await message.add_reaction(clipboard)
|
||||||
elif message.type == discord.MessageType.new_member:
|
elif message.type == discord.MessageType.new_member:
|
||||||
if re.search('discord\.gg\/[a-zA-z0-9\-]{1,16}', message.author.name.lower()) or re.search(
|
if re.search('discord\.gg\/[a-zA-z0-9\-]{1,16}', message.author.name.lower()) or re.search(
|
||||||
'discordapp\.com\/invite\/[a-z0-9]+/ig', message.author.name.lower()):
|
'discordapp\.com\/invite\/[a-z0-9]+/ig', message.author.name.lower()):
|
||||||
await message.author.ban(reason="Name is an invite link.")
|
await message.author.ban(reason="Name is an invite link.")
|
||||||
await message.delete()
|
await message.delete()
|
||||||
bypass_roles = [discord_admin, discord_mod]
|
bypass_roles = [bot.discord_admin, bot.discord_mod]
|
||||||
bypass = False
|
bypass = False
|
||||||
if message.author != bot.user:
|
if message.author != bot.user:
|
||||||
for role in message.author.roles:
|
for role in message.author.roles:
|
||||||
if role.id in bypass_roles:
|
if role.id in bypass_roles:
|
||||||
bypass = True
|
bypass = True
|
||||||
else:
|
else:
|
||||||
server_chats = {1: server_chat, 2: server_chat_2}
|
server_chats = {1: bot.server_chat, 2: bot.server_chat_2}
|
||||||
for server in range(1, len(server_chats)):
|
for server in range(1, len(server_chats)):
|
||||||
if message.channel.id == server_chats[server]:
|
if message.channel.id == server_chats[server]:
|
||||||
if not get_server_status(server):
|
if not get_server_status(server):
|
||||||
|
@ -67,8 +89,8 @@ async def on_message(message):
|
||||||
if 'Server has started' in message.content: # Telnet reconnect script
|
if 'Server has started' in message.content: # Telnet reconnect script
|
||||||
try:
|
try:
|
||||||
bot.telnet_object.connect()
|
bot.telnet_object.connect()
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
print(f'Failed to reconnect telnet: {e}')
|
print(f'Failed to reconnect telnet: {err}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
try:
|
try:
|
||||||
bot.telnet_object.connect()
|
bot.telnet_object.connect()
|
||||||
|
@ -77,8 +99,8 @@ async def on_message(message):
|
||||||
f'Second attempt failed to reconnect telnet: {fuckup}')
|
f'Second attempt failed to reconnect telnet: {fuckup}')
|
||||||
try:
|
try:
|
||||||
bot.telnet_object_2.connect()
|
bot.telnet_object_2.connect()
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
print(f'Failed to reconnect telnet 2: {e}')
|
print(f'Failed to reconnect telnet 2: {err}')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
try:
|
try:
|
||||||
bot.telnet_object_2.connect()
|
bot.telnet_object_2.connect()
|
||||||
|
|
Loading…
Reference in a new issue