Moving lewds into its own module and alphabatizing all the if statements in dragon-bot.py
This commit is contained in:
parent
b29da1b857
commit
a101282b62
@ -5,7 +5,7 @@ RUN apk update && apk add --no-cache vim docker
|
||||
RUN pip install requests discord.py docker pybooru pylint
|
||||
ADD app /app
|
||||
|
||||
RUN echo "\nTesting your python code for errors\n" && \
|
||||
RUN printf "\n\nTesting your python code for errors\n\n" && \
|
||||
pylint -E /app/*.py
|
||||
|
||||
RUN printf "\n#########################\nRun dragon bot by typing \npython dragon-bot.py\n#########################\n\n"
|
||||
|
@ -10,6 +10,7 @@ import define_word
|
||||
import help_methods
|
||||
import discord
|
||||
import docker
|
||||
import lewds
|
||||
import wallpaper
|
||||
from pybooru import Danbooru
|
||||
|
||||
@ -46,93 +47,6 @@ async def on_message(message):
|
||||
is the same as the person who initiated the command
|
||||
"""
|
||||
return m.author == message.author
|
||||
def get_from_danbooru():
|
||||
"""
|
||||
get_from_danbooru()
|
||||
|
||||
returns a URL to an image on danbooru that matches a random tag
|
||||
defined in the tag_list list
|
||||
"""
|
||||
booru = Danbooru('danbooru')
|
||||
tag_list = [
|
||||
'1girl',
|
||||
'2girls',
|
||||
'ass_visible_through_thighs',
|
||||
'bare_legs'
|
||||
'bikini',
|
||||
'black_bikini',
|
||||
'black_panties',
|
||||
'blue_eyes',
|
||||
'bra_pull',
|
||||
'bra',
|
||||
'breasts',
|
||||
'cameltoe',
|
||||
'clevage',
|
||||
'condom_in_mouth',
|
||||
'condom',
|
||||
'from_below',
|
||||
'gloves',
|
||||
'highleg_bikini',
|
||||
'highleg',
|
||||
'highres',
|
||||
'horns',
|
||||
'large_breasts',
|
||||
'leash',
|
||||
'medium_breasts'
|
||||
'miniskirt',
|
||||
'nier_automata',
|
||||
'nier',
|
||||
'nipples',
|
||||
'partially_visible_vulva',
|
||||
'pencil_skirt',
|
||||
'pussy_juice',
|
||||
'pussy',
|
||||
'skirt',
|
||||
'small_breasts',
|
||||
'thong_bikini',
|
||||
'topless',
|
||||
'wet_clothes',
|
||||
'wet_panties',
|
||||
'wet',
|
||||
]
|
||||
|
||||
tag = random.choice(tag_list)
|
||||
return "https://danbooru.donmai.us{}".format(
|
||||
random.choice(
|
||||
booru.post_list(
|
||||
limit=500,
|
||||
tags=tag,
|
||||
random=True,
|
||||
)
|
||||
)['large_file_url'])
|
||||
|
||||
def get_from_reddit():
|
||||
"""
|
||||
get_from_reddit()
|
||||
|
||||
returns a URL to an image on reddit from a random board in the boards list
|
||||
as long as it is hosted on one of the domains in the domains list
|
||||
"""
|
||||
boards = [
|
||||
'2Booty',
|
||||
'bakunyuu_hentai',
|
||||
'ecchi',
|
||||
'hentai',
|
||||
'rule34',
|
||||
'WesternHentai',
|
||||
]
|
||||
domains = [
|
||||
'my.mixtape.moe',
|
||||
'i.imgur.com',
|
||||
'i.redd.it',
|
||||
]
|
||||
response = requests.get(
|
||||
"https://reddit.com/r/{}.json?limit=500".format(random.choice(boards)),
|
||||
headers = {'User-agent':'discord dragon-bot'}
|
||||
).json()['data']['children']
|
||||
|
||||
image_urls = list(filter(lambda x: x['data']['domain'] in domains, response))
|
||||
return random.choice(image_urls)['data']['url'].replace('http://', 'https://')
|
||||
|
||||
##### Looks like discord supports mentioning the bot.
|
||||
#### Need to think of something to do here
|
||||
@ -145,23 +59,37 @@ async def on_message(message):
|
||||
eight_ball.check_8ball(message.content)
|
||||
)
|
||||
|
||||
if message.content.startswith('!cleanup') and message.author.id == '144986109804412928':
|
||||
def is_bot(m):
|
||||
return m.author == client.user
|
||||
await client.purge_from(message.channel, limit=100, check=is_bot)
|
||||
|
||||
if message.content.startswith('!decide'):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"{} {}".format(
|
||||
message.author.mention,
|
||||
decide.decide(message.content)
|
||||
)
|
||||
)
|
||||
|
||||
if message.content.startswith('!define'):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
define_word.get_definition(message.content)
|
||||
)
|
||||
|
||||
if message.content.startswith('!excuse'):
|
||||
await client.send_message(message.channel, excuse.get_excuse())
|
||||
|
||||
if message.content.startswith('!help'):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
help_methods.parse_message(message.content)
|
||||
)
|
||||
|
||||
if 'autis' in message.content or message.content.startswith('!triggered'):
|
||||
await client.send_message(message.channel, 'https://i.imgur.com/g6yOJjp.gif')
|
||||
|
||||
if message.content.startswith('!excuse'):
|
||||
await client.send_message(message.channel, excuse.get_excuse())
|
||||
if message.content.startswith('!lewd'):
|
||||
await client.send_message(message.channel, lewds.get_lewd(channel_name=message.channel.name))
|
||||
|
||||
if message.content.startswith('!purge'):
|
||||
num = 20
|
||||
@ -173,23 +101,6 @@ async def on_message(message):
|
||||
await client.send_message(message.channel, "You need to give me a number, you entered {}".format(message.content.split()[1]))
|
||||
return
|
||||
await client.purge_from(message.channel, limit=num, check=is_me)
|
||||
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
|
||||
|
||||
if message.content.startswith('!decide'):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
"{} {}".format(
|
||||
message.author.mention,
|
||||
decide.decide(message.content)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if message.content.startswith('!cleanup') and message.author.id == '144986109804412928':
|
||||
def is_bot(m):
|
||||
return m.author == client.user
|
||||
await client.purge_from(message.channel, limit=100, check=is_bot)
|
||||
# await client.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted)))
|
||||
|
||||
if message.content.startswith('!wallpaper'):
|
||||
await client.send_message(
|
||||
@ -197,22 +108,6 @@ async def on_message(message):
|
||||
wallpaper.get_wall(message.content)
|
||||
)
|
||||
|
||||
###################################
|
||||
###### +-------------------+ ######
|
||||
###### | | ######
|
||||
###### | Lewd Functions | ######
|
||||
###### | | ######
|
||||
###### +-------------------+ ######
|
||||
###################################
|
||||
if message.content.startswith('!lewd'):
|
||||
if 'nsfw' in message.channel.name:
|
||||
if random.randint(0, 100) % 2 == 0:
|
||||
await client.send_message(message.channel, "Heres a random image from reddit\n{}".format(get_from_reddit()))
|
||||
else:
|
||||
await client.send_message(message.channel, "Heres a random image from danbooru\n{}".format(get_from_danbooru()))
|
||||
else:
|
||||
await client.send_message(message.channel, 'You can only use this command in NSFW channels')
|
||||
|
||||
###################################
|
||||
###### +-------------------+ ######
|
||||
###### | | ######
|
||||
|
@ -40,8 +40,6 @@ def get_help_message(method):
|
||||
'Deletes the last 20 messages you sent from the channel you',
|
||||
'typed purge in, unless otherwise specified. eg. !purge 8'
|
||||
],
|
||||
'triggered': [
|
||||
'REEEEEEEEEEEEEEEEEE'],
|
||||
'wallpaper': [
|
||||
'Returns the URL for a 4k wallpaper. You can enter',
|
||||
'a search term as well, for example, !wallpaper, or',
|
||||
|
103
app/lewds.py
Normal file
103
app/lewds.py
Normal file
@ -0,0 +1,103 @@
|
||||
import random
|
||||
import requests
|
||||
|
||||
import help_methods
|
||||
from pybooru import Danbooru
|
||||
|
||||
|
||||
def get_from_danbooru():
|
||||
"""
|
||||
get_from_danbooru()
|
||||
|
||||
returns a URL to an image on danbooru that matches a random tag
|
||||
defined in the tag_list list
|
||||
"""
|
||||
booru = Danbooru('danbooru')
|
||||
tag_list = [
|
||||
'1girl',
|
||||
'2girls',
|
||||
'ass_visible_through_thighs',
|
||||
'bare_legs'
|
||||
'bikini',
|
||||
'black_bikini',
|
||||
'black_panties',
|
||||
'blue_eyes',
|
||||
'bra_pull',
|
||||
'bra',
|
||||
'breasts',
|
||||
'cameltoe',
|
||||
'clevage',
|
||||
'condom_in_mouth',
|
||||
'condom',
|
||||
'from_below',
|
||||
'gloves',
|
||||
'highleg_bikini',
|
||||
'highleg',
|
||||
'highres',
|
||||
'horns',
|
||||
'large_breasts',
|
||||
'leash',
|
||||
'medium_breasts'
|
||||
'miniskirt',
|
||||
'nier_automata',
|
||||
'nier',
|
||||
'nipples',
|
||||
'partially_visible_vulva',
|
||||
'pencil_skirt',
|
||||
'pussy_juice',
|
||||
'pussy',
|
||||
'skirt',
|
||||
'small_breasts',
|
||||
'thong_bikini',
|
||||
'topless',
|
||||
'wet_clothes',
|
||||
'wet_panties',
|
||||
'wet',
|
||||
]
|
||||
|
||||
tag = random.choice(tag_list)
|
||||
return "https://danbooru.donmai.us{}".format(
|
||||
random.choice(
|
||||
booru.post_list(
|
||||
limit=500,
|
||||
tags=tag,
|
||||
random=True,
|
||||
)
|
||||
)['large_file_url'])
|
||||
|
||||
|
||||
def get_from_reddit():
|
||||
"""
|
||||
get_from_reddit()
|
||||
|
||||
returns a URL to an image on reddit from a random board in the boards list
|
||||
as long as it is hosted on one of the domains in the domains list
|
||||
"""
|
||||
boards = [
|
||||
'2Booty',
|
||||
'bakunyuu_hentai',
|
||||
'ecchi',
|
||||
'hentai',
|
||||
'rule34',
|
||||
'WesternHentai',
|
||||
]
|
||||
domains = [
|
||||
'my.mixtape.moe',
|
||||
'i.imgur.com',
|
||||
'imgur.com',
|
||||
'i.redd.it',
|
||||
]
|
||||
response = requests.get(
|
||||
"https://reddit.com/r/{}.json?limit=500".format(random.choice(boards)),
|
||||
headers = {'User-agent':'discord dragon-bot'}
|
||||
).json()['data']['children']
|
||||
|
||||
image_urls = list(filter(lambda x: x['data']['domain'] in domains, response))
|
||||
return random.choice(image_urls)['data']['url'].replace('http://', 'https://')
|
||||
|
||||
|
||||
def get_lewd(channel_name):
|
||||
if 'nsfw' in channel_name:
|
||||
random.choice([get_from_reddit, get_from_danbooru])()
|
||||
else:
|
||||
return 'You can only use this command in NSFW channels'
|
Loading…
x
Reference in New Issue
Block a user