Skip to content

Instantly share code, notes, and snippets.

@garzaa
Created September 2, 2023 21:39
Show Gist options
  • Save garzaa/fe1145f536e23f36d9408e900740f905 to your computer and use it in GitHub Desktop.
Save garzaa/fe1145f536e23f36d9408e900740f905 to your computer and use it in GitHub Desktop.
A Discord bot that you can anonymously confess your sins to. It posts them in a channel of your choice.
import discord
from email.message import Message
import random
import re
from datetime import datetime
TOKEN = "REDACTED_STRING"
confession_channel_id = 000000
url_regex = r"\b((?:https?://)?(?:(?:www\.)?(?:[\da-z\.-]+)\.(?:[a-z]{2,6})|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|(?:(?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(?::[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(?:ffff(?::0{1,4}){0,1}:){0,1}(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])|(?:[0-9a-fA-F]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])))(?::[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])?(?:/[\w\.-]*)*/?)\b"
confession_channel: discord.channel = None
hours_cooldown: int = 1
penances = [
"say three Hail Marys and one Our Father",
"kill yourself in public ritual suicide",
"go out there and make a real difference",
"eat only chips for the next two weeks",
"treat yourself to a little beverage - you've earned it",
"say something nice to Jerry - but not _too_ nice",
"receive the light of Islam and unhesitatingly recite the Shahāda. Truly, there is no god but Allah, and Mohammed is his messenger",
"do a little dance and think about what you've done",
"...hold on, that sounds bad enough that you should see a real priest",
"etch a little cross into a saltine and eat it",
"write 100 times on the chalkboard \"I will not do sins\"",
"I'd tell you to kill yourself but that's also a sin",
"eat more fiber and think positive thoughts",
"download a free online bible TODAY! www.godschildrenbibleschool.com/download/bible-for-beginners",
"give me your social security number and I'll set this right with the man upstairs",
"don't worry about it! It's Hell for you my friend",
"sacrifice two goats and one man at the winter solstice",
"say something nice to people in chat",
"refrain from insulting Jerry for the next 24 hours",
"beat your meat until it falls apart like a brisket",
"dig out your own brain, scoop by scoop, with a little espresso spoon",
"singe your eyebrows with a blowtorch",
"what the fuck is wrong with you? You're a foul creature",
"climb into a hydraulic press and stay there until you've learned your lesson",
"edge for two hours",
"shit your pants",
"spend two hours in the _Wasp Room_",
"treat yourself to a Dobby Pussy Indulgence",
"glue two of your fingers together with Gorilla® Construction Adhesive",
"next time you will start a petty squabble, decide not to instead",
"enlist in the draft",
"learn to eat a disgusting, dirty mouse",
"you have to kill someone",
"give me your spare change! C'mon. Just a dollar or two...cmon😃",
"take a 200mg edible and call your parents to say hi",
"denounce the Anglicans",
"uhhh uhhhhhhhhhhh uhhhh … uhhhhhhhh uhhh uhhhhhh ……… uhhhh uhh.. uhhh h..",
"interrogate and unpack the politics of desire under late capitalism",
"listen to drum and bass",
"GET SCARED",
"go check your ex's social media",
"don't ever have sex",
"spend 20 minutes in the gorilla enclosure at the zoo",
"let me out of this sewer, man I could be your best friend. I could be the best thing thats ever happened to you",
"prepare for infinite agony",
"do half a Xan and pound on your man",
"don't worry about the thing in your house for today",
"go outside, find a bug, and eat it",
"try to become less racist. Just try",
"get pig",
"write in Hillary for 2024",
"you must contract a rare disease",
"gamble with borrowed money",
"drive behind a pig trailer for at least 20 minutes next time you're on the road",
"go out and get the worst haircut of your entire life",
"drink more water and stop listening to fucking Bladee",
"leave the oven on next time you go somewhere. The blessing of the Lord will protect you",
"pay two Etsy witches to curse each other and see who dies first",
"post a meme about **drunk driving** to your _LinkedIn_.",
"change your style in a way that is lovely",
"subscribe to Twitter Blue",
"go outside & kill people & hurt them with knives & cut them & beat them with hammers"
]
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
confession_cooldowns = {}
@client.event
async def on_ready():
print("priestbot online")
# await confession_channel().send("priestbot has restarted")
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.guild:
if was_tagged(message):
await message.reply("in DMs, my child 🙏")
return
print("got dm: "+message.content)
if message.content == "" or message.content.isspace():
await message.reply("I need a real sin, my child.")
return
if len(message.content) > 900:
await message.reply("I need a shorter sin, my child.")
return
if (re.search(url_regex, message.content)):
await message.reply("Hyperlinking is a sin, my child.")
return
now = datetime.now()
if message.author.id in confession_cooldowns and not past_cooldown(now, confession_cooldowns[message.author.id]):
await message.reply("You are confessing too quickly, my child.")
return
await message.reply(make_penance())
await announce_sin(message.content)
if random.randint(0, 100) == 1:
await message.reply("Your message was passed on, but deemed not sinful enough. You may confess again this hour.")
else:
confession_cooldowns[message.author.id] = now
def past_cooldown(now, then) -> bool:
diff = now - then
# one hour, 60s/min -> 60min/hour
cooldown_seconds: int = 60 * 60 * hours_cooldown
return diff.total_seconds() > cooldown_seconds
def make_penance() -> str:
if random.randint(0, 100) <= 2:
return "I can't believe how sick you make me."
else:
s: str = "Thank you, my child. I will relay your message immediately. For your penance, "
s += random.choice(penances) + "."
return s
async def announce_sin(sin: str):
s: str = "_One of our members has sinned. Here is their confession._\n> "
s += sin.replace("\n", "\n> ")
chance = random.randint(0, 100)
if chance <= 2:
# 1 in 100 chance, if judging, to accidentally let slip the gender
if (random.randint(0, 100) == 1):
if (random.randint(0, 1) == 1):
s += "\n_Wow! It's certain damnation for him! I mean them!_"
else:
s += "\n_Wow! It's certain damnation for her! I mean them!_"
else:
s += "\n_Wow! It's certain damnation for them!_"
elif chance <= 4:
s += "\n_That one's good to do, actually. Everyone else, take notes._"
await confession_channel().send(s)
def is_dm(message):
return not message.guild
def was_tagged(message: Message) -> bool:
for member in message.mentions:
if member.id == client.user.id:
return True
return False
def confession_channel():
return client.get_channel(confession_channel_id)
client.run(TOKEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment