big cleanup
This commit is contained in:
parent
e200b9891c
commit
2e0450a206
4 changed files with 53 additions and 115 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
twit_sekrit
|
||||
discord_token
|
||||
.sekrit/
|
||||
__pycache__/
|
||||
*/__pycache__/
|
||||
|
|
163
lulzbot.py
163
lulzbot.py
|
@ -5,17 +5,6 @@ motd ='''
|
|||
| |__| |_| | |___ / /| |_) | |_| | |_
|
||||
|_____\__,_|_____/___|____/ \___/ \__|
|
||||
'''
|
||||
# Discord Bot
|
||||
import discord, datetime, time
|
||||
import numpy as np
|
||||
from fortune import fortune
|
||||
from ligma import ligma
|
||||
from limericks import limerick
|
||||
|
||||
TOKEN = open('discord_token').read()
|
||||
chuck = open('chucknorris').read().split('\n%\n')
|
||||
client = discord.Client(activity=discord.Game(name='with myself'))
|
||||
|
||||
menu = '''```
|
||||
Commands:
|
||||
fortune: tell a fortune
|
||||
|
@ -29,13 +18,41 @@ Commands:
|
|||
Contribute!
|
||||
https://github.com/adoyle0/lulzbot```'''
|
||||
|
||||
# Discord
|
||||
import discord, datetime
|
||||
import numpy as np
|
||||
from fortune import fortune
|
||||
from modules.ligma import ligma
|
||||
from modules.limericks import limerick
|
||||
|
||||
TOKEN = open('.sekrit/discord_token').read()
|
||||
chuck = open('chucknorris').read().split('\n%\n')
|
||||
client = discord.Client(activity=discord.Game(name='with myself'))
|
||||
|
||||
# NLP
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
||||
from transformers.models.auto.modeling_auto import AutoModelForCausalLM
|
||||
import torch
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained('microsoft/DialoGPT-large')
|
||||
model = AutoModelForCausalLM.from_pretrained('../southpark/output-medium')
|
||||
|
||||
# Twitter
|
||||
import tweepy
|
||||
|
||||
twit_sekrit = open('.sekrit/twit_sekrit').read().split('\n')
|
||||
api_key = twit_sekrit[0]
|
||||
api_key_secret = twit_sekrit[1]
|
||||
bearer_token = twit_sekrit[2]
|
||||
access_token = twit_sekrit[3]
|
||||
access_token_secret = twit_sekrit[4]
|
||||
tclient = tweepy.Client(bearer_token,api_key,api_key_secret,access_token,access_token_secret)
|
||||
|
||||
# Functions
|
||||
def user_tweet(twitter):
|
||||
statuses = tclient.get_users_tweets(twitter, exclude=['replies'], max_results=5)
|
||||
return statuses[0][0]
|
||||
|
||||
def cartman_speak(user_message):
|
||||
new_user_input_ids = tokenizer.encode(user_message + tokenizer.eos_token, return_tensors='pt')
|
||||
bot_output = new_user_input_ids
|
||||
|
@ -52,27 +69,31 @@ def cartman_speak(user_message):
|
|||
|
||||
return '{}'.format(tokenizer.decode(bot_output[:,bot_input_ids.shape[-1]:][0], skip_special_tokens=True))
|
||||
|
||||
# Twitter
|
||||
import tweepy
|
||||
def message_handler(message):
|
||||
handler = {'musk': user_tweet(44196397),
|
||||
'lulzbot': menu,
|
||||
'deez': ligma(),
|
||||
'ligma': ligma(),
|
||||
'bofa': ligma(),
|
||||
'bopha': ligma(),
|
||||
'limerick': limerick(),
|
||||
'limrick': limerick(),
|
||||
'prost!': 'https://tenor.com/view/prost-christoph-waltz-django-bier-zum-wohle-gif-11041516',
|
||||
'fortune': fortune(),
|
||||
'chuck': np.random.choice(chuck),
|
||||
}
|
||||
|
||||
twit_sekrit = open('twit_sekrit').read().split('\n')
|
||||
api_key = twit_sekrit[0]
|
||||
api_key_secret = twit_sekrit[1]
|
||||
bearer_token = twit_sekrit[2]
|
||||
access_token = twit_sekrit[3]
|
||||
access_token_secret = twit_sekrit[4]
|
||||
tclient = tweepy.Client(bearer_token,api_key,api_key_secret,access_token,access_token_secret)
|
||||
if message in handler:
|
||||
return handler.get(message)
|
||||
else:
|
||||
return
|
||||
|
||||
def user_tweet(twitter):
|
||||
statuses = tclient.get_users_tweets(twitter, exclude=['replies'], max_results=5)
|
||||
return statuses[0][0]
|
||||
|
||||
# Init
|
||||
# Main
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(motd+'\n'+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')+'\nLogged in as {0.user}'.format(client))
|
||||
return
|
||||
|
||||
# Monitor Incoming
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
username = str(message.author).split('#')[0]
|
||||
|
@ -89,92 +110,8 @@ async def on_message(message):
|
|||
return
|
||||
|
||||
if message.channel.name == 'shitposting':
|
||||
if user_message.lower().count('musk') > 0:
|
||||
await message.channel.send(user_tweet(44196397))
|
||||
return
|
||||
|
||||
elif user_message.lower() == 'lulzbot' or user_message == 'ligmabot' or user_message == 'L1gMaB0t' or user_message == 'help':
|
||||
await message.channel.send(menu)
|
||||
return
|
||||
|
||||
elif user_message.lower().count('deez') > 0 or user_message.lower().count('bofa') > 0 or user_message.lower().count('ligma') > 0 or user_message.lower().count('l1gma') > 0 or user_message.lower().count('l1gm4') > 0 or user_message.lower().count('ligm4') > 0:
|
||||
await message.channel.send(ligma())
|
||||
return
|
||||
|
||||
elif user_message.lower().count('limerick') > 0 or user_message.lower().count('limrick') > 0:
|
||||
await message.channel.send(limerick())
|
||||
return
|
||||
|
||||
elif user_message.lower().count('prost!') > 0:
|
||||
await message.channel.send('https://tenor.com/view/prost-christoph-waltz-django-bier-zum-wohle-gif-11041516')
|
||||
return
|
||||
|
||||
elif user_message.lower() == 'fortune':
|
||||
await message.channel.send(fortune())
|
||||
return
|
||||
|
||||
elif user_message.lower().count('chuck') > 0:
|
||||
await message.channel.send(np.random.choice(chuck))
|
||||
return
|
||||
|
||||
elif user_message.lower().count('lulzbot tell me about yourself') > 0:
|
||||
await message.channel.send(\
|
||||
'In west Philadelphia born and raised\n\
|
||||
On the playground was where I spent most of my days')
|
||||
time.sleep(4.6)
|
||||
await message.channel.send('\
|
||||
Chillin\' out maxin\' relaxin\' all cool\n\
|
||||
And all shooting some b-ball outside of the school')
|
||||
time.sleep(4.6)
|
||||
await message.channel.send('\
|
||||
When a couple of guys who were up to no good\n\
|
||||
Started making trouble in my neighborhood')
|
||||
time.sleep(4.6)
|
||||
await message.channel.send('\
|
||||
I got in one little fight and my mom got scared\n\
|
||||
She said, "You\'re movin\' with your auntie and uncle in Bel-Air"')
|
||||
time.sleep(5)
|
||||
await message.channel.send('\
|
||||
I begged and pleaded with her day after day\n\
|
||||
But she packed my suitcase and sent me on my way')
|
||||
time.sleep(4.6)
|
||||
await message.channel.send('\
|
||||
She gave me a kiss and then she gave me my ticket\n\
|
||||
I put my Walkman on and said\n\
|
||||
"I might as well kick it"')
|
||||
time.sleep(4.5)
|
||||
await message.channel.send('\
|
||||
First class, yo, this is bad\n\
|
||||
Drinking orange juice out of a champagne glass')
|
||||
time.sleep(4.5)
|
||||
await message.channel.send('\
|
||||
Is this what the people of Bel-Air living like?\n\
|
||||
Hmm, this might be alright')
|
||||
time.sleep(4.5)
|
||||
await message.channel.send('\
|
||||
I whistled for a cab and when it came near\n\
|
||||
The license plate said "Fresh" and it had dice in the mirror')
|
||||
time.sleep(4.5)
|
||||
await message.channel.send('\
|
||||
If anything I could say that this cab was rare\n\
|
||||
But I thought, "Nah, forget it"\n\
|
||||
– "Yo, homes to Bel-Air"')
|
||||
time.sleep(4.5)
|
||||
await message.channel.send('\
|
||||
I')
|
||||
time.sleep(.5)
|
||||
await message.channel.send('\
|
||||
pulled')
|
||||
time.sleep(.5)
|
||||
await message.channel.send('\
|
||||
up to the house about 7 or 8\n\
|
||||
And I yelled to the cabbie\n\
|
||||
"Yo homes smell ya later"')
|
||||
time.sleep(4.5)
|
||||
await message.channel.send('\
|
||||
I looked at my kingdom\n\
|
||||
I was finally there\n\
|
||||
To sit on my throne as the Prince of Bel-Air')
|
||||
async with message.channel.typing():
|
||||
await message.channel.send(message_handler(user_message))
|
||||
return
|
||||
|
||||
client.run(TOKEN)
|
||||
|
|
Loading…
Add table
Reference in a new issue