-
Notifications
You must be signed in to change notification settings - Fork 18
/
main.py
147 lines (124 loc) · 4.56 KB
/
main.py
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import discord
import json
import os
import random
import re
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
global afk_dict
afk_dict = {}
custom_emoji = {}
bot = discord.Bot(intents=intents)
bot.load_extension("fun")
bot.load_extension("utils")
with open('guilds.json') as f:
guilds = json.load(f)
with open('roles.json') as f:
roles = json.load(f)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user} (ID: {bot.user.id if bot.user else None})")
print("------")
async for guild in bot.fetch_guilds(limit=10):
full_guild = bot.get_guild(guild.id)
if full_guild:
for emoji in full_guild.emojis:
custom_emoji[emoji.name] = emoji
game = discord.Game("Happy Pride! 🏳️🌈")
await bot.change_presence(status=discord.Status.online, activity=game)
@bot.event
async def on_message(message: discord.Message):
if bot.user and message.author.id == bot.user.id:
return
if message.guild is None:
return
member = message.guild.get_member(message.author.id)
words = re.split(r"[,:. \"'-]+", message.content.lower())
afk_dict = globals()["afk_dict"]
# AFK Member Handling
if message.author.id in afk_dict:
await message.reply("Welcome back! You are no longer AFK.")
afk_dict.pop(message.author.id)
for member in message.mentions:
if member != message.author and member.id in afk_dict:
await message.reply(
content=
f"{member.mention} is currently AFK: **{afk_dict[member.id]}**",
delete_after=20)
# Pridebot responding to a mention of its name aka 'the hotword'
responses = [
"hey homie", "sup mate?", "why'd you summon me, mate?",
"sorry, im busy atm"
]
if "pridebot" in "".join(words):
await message.reply(responses[random.randint(0, 3)])
# Responding to pride words
pride_words = [
"pride", "proud", "rainbow", "gay", "queer", "lgbt", "love", "june",
"heart"
]
for word in words:
if word in pride_words:
await message.add_reaction("🏳️🌈")
await message.add_reaction(custom_emoji["gaydragon"])
await message.add_reaction(custom_emoji["prideblahaj"])
if (type(message.guild) is discord.Guild
and message.guild.id == guilds["blahajgang"]
and type(member) is discord.Member
and member.get_role(roles["proud_friendo"]) is not None):
await message.add_reaction("🌈")
await message.add_reaction(custom_emoji["rainbowblahaj"])
await message.add_reaction(custom_emoji["partyblahaj"])
# React to different words with custom emoji
word_reacts = {
'yee+t': [custom_emoji["blahajyeet"]],
'mindblowing': ["🤯"],
'that\'scool': ["🤯"],
'holyfruit': [custom_emoji["melonblahaj"]],
'bequiet': ["🤫"],
'shutup': ["🤫"],
'neel': [custom_emoji["spaceblahaj"]],
'tiff': [custom_emoji["royalblahaj"]],
'blahaj': [custom_emoji["justblahaj"]],
'shark': [custom_emoji["justblahaj"]],
'uwu': [custom_emoji["blahajuwu"]],
'sleep': ["🥱", "😴"],
'ping': [custom_emoji["angrypinghaj"]],
'coffee': [custom_emoji["meow_coffee"]],
'clown': [custom_emoji["catclown"]],
'dance': [custom_emoji["blobdance"]],
'code': [custom_emoji["meow_code"]],
'hack': [custom_emoji["meow_code"]],
'cat': [custom_emoji["meow_heart"]],
'kitty': [custom_emoji["meow_heart"]],
'meow': [custom_emoji["meow_heart"]],
'sus': [custom_emoji["susblahaj"]],
}
for regex, reacts in word_reacts.items():
if re.search(regex, "".join(message.content.lower().split())) is not None:
for react in reacts:
await message.add_reaction(react)
# identity-specific react map
identity_reacts = {
'trans': [custom_emoji["pride_heart_trans"]],
'poc': [custom_emoji["pride_heart_pocpride"]],
'pan': [custom_emoji["pride_heart_pan"]],
'nonbinary': [custom_emoji["pride_heart_nonbinary"]],
'nb': [custom_emoji["pride_heart_nonbinary"]],
'lesbian': [custom_emoji["pride_heart_lesbian"]],
'genderqueer': [custom_emoji["pride_heart_genderqueer"]],
'gay': [custom_emoji["pride_heart_gay"]],
'bi': [custom_emoji["pride_heart_bi"]],
'aro': [custom_emoji["pride_heart_aro"]],
'ace': [custom_emoji["pride_heart_ace"]],
'asexual': [custom_emoji["pride_heart_ace"]]
}
for substr, reacts in identity_reacts.items():
if substr in words:
for react in reacts:
await message.add_reaction(react)
token = os.getenv('TOKEN')
bot.run(token)