-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
115 lines (99 loc) · 4.7 KB
/
main.py
File metadata and controls
115 lines (99 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from dotenv import load_dotenv
load_dotenv()
import os
from datetime import datetime
import discord
from discord.ext import commands
from discord.gateway import DiscordWebSocket
import wavelink
import sys
import asyncio
from request_listener import serve, register_bot
from level_insult import get_prefix, insult_user, earn_xp
from gde_hall_of_fame import main_gde, main_rob
from c_ai_discord import c_ai
from custom_status import silly_activities, phone_status
from music import setup_hook_music
from util_message import message_snitcher
discord.utils.setup_logging()
intents = discord.Intents.default()
intents.message_content = True
# intents.presences = True
intents.members = True
mentions = discord.AllowedMentions(everyone=False, users=True, roles=True, replied_user=True)
DiscordWebSocket.identify = phone_status
if sys.platform == 'win32': asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
noobgpt_modules = [
"c_ai_discord", "stablehorde", "gpt4free", "perplexity", "openai_", "googleai", # "petals",
"tictactoe", "aki", "hangman", "quiz", "wordle_", "rps_game",
"gelbooru", "deeznuts", "sflix", "ytdlp_", "magick_pillow", "min_music", # "kiss_api", "hianime_api", "cobalt", "kissasian",
"animepahe", "manganato", "mangadex", # "gogoanime",
"custom_status", "level_insult", "respond_mode", "quoteport", "help", # "weather",
"util_discord", "util_member", "util_message", # "util_geometryjump",
"mister_squid", "roshidere", "util_channel", # squid + zero modules
]
moosic_modules = ["util_discord", "youtubeplayer", "music"]
# zero_modules = noobgpt_modules + ["util_channel"]
# squid_modules = ["util_discord", "mister_squid", "roshidere"]
exclude_bots = ["MOOSIC", "SQUID"]
class NoobGPT(commands.Bot):
def __init__(self, identifier, modules):
self.identifier = identifier
self.token = os.getenv(identifier)
self.modules = modules
self.node_ids = []
super().__init__(
command_prefix = get_prefix, intents = intents, help_command = None, allowed_mentions = mentions
)
async def on_ready(self):
print(f"{self.identifier} (c) {datetime.now().year} The Karakters Kompany. All rights reserved.")
print("Running for the following servers:")
for number, guild in enumerate(self.guilds, 1):
print(f"{number}. {guild} ({guild.id})")
print(":)")
async def on_guild_join(self, guild: discord.Guild):
print(f"{self.identifier}: Joined {guild.name} ({guild.id})")
async def on_guild_remove(self, guild: discord.Guild):
print(f"{self.identifier}: Left {guild.name} ({guild.id})")
async def on_message(self, message: discord.Message):
if self.identifier not in exclude_bots:
# self.loop.create_task(main_styx(self, message))
self.loop.create_task(c_ai(self, message))
self.loop.create_task(insult_user(self, message))
self.loop.create_task(earn_xp(self, message))
await self.process_commands(message)
async def on_message_edit(self, before: discord.Message, after: discord.Message):
if self.identifier in exclude_bots: return
self.loop.create_task(
message_snitcher(before, after,"Message updated", f"#{before.channel}", 0x00ff00)
)
async def on_message_delete(self, message: discord.Message):
if self.identifier in exclude_bots: return
self.loop.create_task(
message_snitcher(message, None, "Message deleted", f"#{message.channel}", 0xff0000)
)
async def on_wavelink_node_ready(self, payload: wavelink.NodeReadyEventPayload):
print(f"{self.identifier}: {payload.node} | Resumed: {payload.resumed}")
async def setup_hook(self):
self.loop.create_task(silly_activities(self))
self.loop.create_task(setup_hook_music(self))
if self.identifier == "NOOBGPT":
self.loop.create_task(main_gde(self))
self.loop.create_task(main_rob(self))
for module in self.modules:
exclude = ["custom_status"]
if self.identifier != "NOOBGPT" and module in exclude: continue
await self.load_extension(module)
async def start_bot(bot: NoobGPT):
register_bot(bot.identifier, bot)
await bot.start(bot.token)
async def main():
await asyncio.gather(
start_bot(NoobGPT("NOOBGPT", noobgpt_modules)),
start_bot(NoobGPT("MOOSIC", moosic_modules)),
start_bot(NoobGPT("KAGURA", noobgpt_modules)),
# start_bot(NoobGPT("ZERO", zero_modules)),
# start_bot(NoobGPT("SQUID", squid_modules)),
serve(),
)
asyncio.run(main())