Skip to content

Instantly share code, notes, and snippets.

@leduyquang753
Last active August 20, 2022 14:48
Show Gist options
  • Save leduyquang753/b46632809ac095fc10ddc4860e340a3f to your computer and use it in GitHub Desktop.
Save leduyquang753/b46632809ac095fc10ddc4860e340a3f to your computer and use it in GitHub Desktop.
A Discord bot that explains the most common chat acronyms.
import discord
from discord.ext import commands
import asyncio
enabled = True
Slang = {
"RN": "Right now",
"BTW": "By the way",
"AAF": "Always a friend",
"AAK": "Asleep at keyboard",
"AFK": "Away from keyboard",
"BRB": "Be right back",
"AAMOF": "As a matter of fact",
"FAQ": "Frequently asked questions",
"B2K": "Back to keyboard",
"BTK": "Back to keyboard",
"DIY": "Do it yourself",
"FACK": "Full acknowledge",
"AKA": "Also known as",
"FKA": "Formely known as",
"FYI": "For your information",
"HF": "Have fun",
"GL": "Good luck",
"HTH": "Hope this helps",
"IDK": "I don't know",
"IOW": "In mother words",
"LOL": "Laughing out loud",
"IMO": "In my opinion",
"IMHO": "In my humble opinion",
"N/A": "Not available/applicable",
"NNTR": "No need to reply",
"NRN": "No reply necessary",
"ROFL": "Rolling on floor laughing",
"ROTFL": "Rolling on the floor laughing",
"TBC": "To be continued",
"TIA": "Thanks in advance",
"TGIF": "Thanks God it's Friday",
"TQ": "Thank you",
"TY": "Thank you",
"TQVM": "Thank you very much",
"TYT": "Take your time",
"TTYL": "Talk to you later",
"L8R": "Later",
"WFM": "Works for me",
"WRT": "With regard to",
"WTH": "What the hell",
"WTF": "What the f*ck",
"YMMD": "You made my day",
"ICYMI": "In case you missed it",
"LMAO": "Laughing my ass off",
"OMG": "Oh my God",
"OMFG": "Oh my f*cking God",
"WOL": "Wake on LAN",
"FPS": "Frames per seconds",
"CPS": "Clicks per seconds",
"DOS": "Disk operating system",
"DDOS": "Distributed Denial of Service",
"ILY": "I love you",
"GTG": "Got to go",
"BBL": "Be back later",
# You can add more here
}
special_chars = "~`!@#$%^&******()_-+=|\\{}[]:;\"\'<>,.?/"
bot = commands.Bot(command_prefix='&')
@bot.command()
async def list():
"""Lists every word the bot can explain."""
i = 0
msg = ""
for word in Slang:
if i > 40:
await bot.say(msg)
i = 0
msg = ""
msg += "\n" + word.upper() + ": " + Slang.get(word.upper(), "ERROR!")
i+=1
await bot.say(msg)
await bot.say("------------------")
await bot.say(str(len(Slang)) + " words")
@bot.command()
async def status():
"""Checks the status of the bot."""
await bot.say("Slang It bot info:")
await bot.say("Bot name: " + bot.user.name)
await bot.say("Bot ID: " + str(bot.user.id))
if enabled:
await bot.say("The bot is enabled.")
else:
await bot.say("The bot is disabled.")
@bot.command()
async def toggle():
"""Toggles if the bot is allowed to explain the stuff."""
global enabled
enabled = not enabled
if enabled:
await bot.say("The bot is now enabled.")
else:
await bot.say("The bot is now disabled.")
def ctain(s):
if s == '':
return false
return s in special_chars
def cutString(str):
res = str
while ctain(res[0]):
res = res[1:]
while ctain(res[len(res)-1]):
res = res[:(len(res)-1)]
return res
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.event
async def on_message(message):
await bot.process_commands(message)
if message.author.id == bot.user.id:
return
if not enabled:
return
words = message.content.split()
for word in words:
word = cutString(word)
if word.upper() in Slang:
await bot.send_message(message.channel, word.upper() + ": " + Slang.get(word.upper(), "ERROR!"))
# vvv Insert the bot token below before running.
bot.run('Bot token HERE')
@leduyquang753
Copy link
Author

Are you the maintainer? Is the current source code published?

I made the bot myself, and no the current code has not yet been shown.

@ReenigneArcher
Copy link

Okay, I was interested in contributing as I found the current bot does not work in threads, nor does it use slash commands.

@leduyquang753
Copy link
Author

Yeah the code was rewritten before threads and slash commands came into life and I stopped caring about it since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment