lulzbot/lulzbot.py

117 lines
2.8 KiB
Python
Raw Normal View History

2023-03-03 13:49:19 -05:00
import datetime
import discord
from src.flan import flan_speak
from src.cartman import cartman_speak
from src.twitter import get_tweet
from fortune import fortune
import numpy as np
motd = '''
_ _ ____ ___ _
| | _ _| | ___| __ ) / _ \| |_
| | | | | | | |_ / _ \| | | | __|
| |__| |_| | |___ / /| |_) | |_| | |_
|_____\__,_|_____/___|____/ \___/ \__|
2022-10-03 21:09:32 -04:00
'''
2023-03-03 13:49:19 -05:00
menu = '''```
2022-10-03 21:09:32 -04:00
Commands:
fortune: tell a fortune
chuck: give a Chuck Norris quote
ligma: LIGMA BALLS
bofa: deez
deez: nutz
limerick: tell a limerick
prost!: prost!
Contribute!
https://github.com/adoyle0/lulzbot```'''
2022-10-07 23:12:23 -04:00
2022-10-09 18:25:06 -04:00
chuck_quotes = open('data/chuck_quotes').read().split('\n%\n')
ligma_list = open('data/ligma_list').read().split('\n')
limericks = open('data/limericks').read().split('\n%\n')
2022-11-06 02:55:37 -05:00
aclist = open('data/aclist').read().split('\n')
2022-10-07 23:12:23 -04:00
2023-03-03 13:49:19 -05:00
2022-10-07 23:12:23 -04:00
def show_menu():
return menu
2023-03-03 13:49:19 -05:00
2022-10-07 23:12:23 -04:00
def musk():
return get_tweet(44196397)
2023-03-03 13:49:19 -05:00
2022-10-07 23:12:23 -04:00
def ligma():
return np.random.choice(ligma_list)
2023-03-03 13:49:19 -05:00
2022-10-09 18:25:06 -04:00
def limerick():
return np.random.choice(limericks)
2023-03-03 13:49:19 -05:00
2022-10-07 23:12:23 -04:00
def prost():
return 'https://tenor.com/view/prost-christoph-waltz-django-bier-zum-wohle-gif-11041516'
def chuck():
return np.random.choice(chuck_quotes)
2023-03-03 13:49:19 -05:00
2022-11-06 02:55:37 -05:00
def ac():
return np.random.choice(aclist)
2023-03-03 13:49:19 -05:00
triggers = {'lulzbot': show_menu, # these need to be functions
2022-12-21 15:56:25 -05:00
'musk': musk,
'deez': ligma,
'ligma': ligma,
'bofa': ligma,
'bopha': ligma,
'limerick': limerick,
'limrick': limerick,
'prost!': prost,
'fortune': fortune,
'chuck': chuck,
'ac': ac,
2023-03-03 13:49:19 -05:00
}
2022-10-07 18:51:58 -04:00
TOKEN = open('.sekrit/discord_token').read()
2022-11-06 02:55:37 -05:00
intents = discord.Intents.default()
2023-03-03 13:49:19 -05:00
intents.message_content = True
client = discord.Client(activity=discord.Game(
name='with myself'), intents=intents)
2022-10-07 18:51:58 -04:00
2022-09-29 00:24:13 -04:00
@client.event
async def on_ready():
2023-03-03 13:49:19 -05:00
print(motd+'\n'+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') +
'\nLogged in as {0.user}'.format(client))
2022-10-07 18:51:58 -04:00
return
2022-09-29 00:24:13 -04:00
2023-03-03 13:49:19 -05:00
2022-09-29 00:24:13 -04:00
@client.event
async def on_message(message):
username = str(message.author).split('#')[0]
user_message = str(message.content)
channel = str(message.channel.name)
2022-10-07 23:12:23 -04:00
print(f'{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")} ({channel}) {username}: {user_message}')
2022-09-29 00:24:13 -04:00
if message.author == client.user:
return
2022-10-07 23:12:23 -04:00
elif message.channel.name == 'cartman':
2022-12-21 15:56:25 -05:00
await message.channel.send(cartman_speak(user_message))
2023-03-03 13:49:19 -05:00
# await message.channel.send("I'm broken, come back later.")
2022-12-21 15:56:25 -05:00
elif message.channel.name == 'flan':
2023-03-03 13:49:19 -05:00
await message.channel.send(flan_speak(user_message))
# await message.channel.send('GPU is busy, come back later')
2022-09-29 00:39:28 -04:00
2022-10-07 23:12:23 -04:00
elif message.channel.name == 'shitposting':
2023-03-03 13:49:19 -05:00
if user_message.lower() in triggers:
2022-12-21 15:56:25 -05:00
await message.channel.send(triggers[user_message.lower()]())
2022-10-07 23:12:23 -04:00
return
2022-09-29 00:24:13 -04:00
client.run(TOKEN)