From 2a1a1aa395c623f7c18c1591902c877028710060 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 16 Dec 2020 16:39:55 +0530 Subject: changed how the bot handles commands, it only supports fetching the title for now --- bot.py | 93 ++++++-------------------------------------------------- help_message.txt | 7 ----- henti.py | 2 +- 3 files changed, 11 insertions(+), 91 deletions(-) delete mode 100644 help_message.txt diff --git a/bot.py b/bot.py index b234774..3b1e971 100644 --- a/bot.py +++ b/bot.py @@ -1,93 +1,20 @@ -import discord import os -from dotenv import load_dotenv -import random -import math -import henti as H # the good stuff - -greetings = ["Greetings.", "Hello.", "Hey!", "Yahallo!", "Namaskar,", "Konnichiwa,", "Yo!"] -def get_info(): - info_messages = [random.choice(greetings) + " I'm a Discord bot created by Vidhu Kant Sharma", "This bot is pog"] - return random.choice(info_messages) - -bad_words = ['fuck', 'shit', 'bitch', 'cunt', 'sex']#, '', '', '', '', '', '', '', '', '', '', '', '') - -# z!help -def show_help(): - help = open('help_message.txt', 'r') - help_message = help.read() - return help_message - - -CALL = "z!" - -HELP_MESSAGE = '```Every command should be prefixed with "' + CALL + '".\n\nsay repeats your previous message\ninfo displays info about the bot and the creator\nhelp shows this message```' - - - - - - - - - - - - - +from dotenv import load_dotenv +from discord.ext import commands +import henti as H load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') -# frontend stuff -client = discord.Client() - -# events -@client.event -async def on_ready(): - print(f'{client.user} has connected to Discord!') - await client.change_presence(activity=discord.Game('Guess you are my little pogchamp')) - - - -@client.event -async def on_message(message): - # ignore if sent by itself - if message.author == client.user: - return - - # say something - if message.content[0:len(CALL) + 4] == CALL + 'say ': - response = message.content[5:] # users message with the command removed - - # check if the user said a bad word - if response[1:] in bad_words: # for some reason the first character is always a space - await message.channel.send('THIS IS A FAMILY FRIENDLY DISCORD SERVER') - await message.channel.send('NO ONE WILL FUCKING CURSE') - else: - await message.channel.send(response) +bot = commands.Bot(command_prefix='z!') - # send info message - if message.content == CALL + 'info': - response = get_info() - await message.channel.send(response) - - if message.content == CALL + 'repo': - response = 'My source code: https://github.com/MikunoNaka/ZeHenti-bot.git' - await message.channel.send(response) - - # send help message - if message.content == CALL + 'help': - response = show_help() - await message.channel.send(response) - - # cultured stuff - if message.content.split()[0] == CALL + 'find': # find title of henti - sauce = (''.join(message.content.split()[1:])) - response = H.find_title(sauce) - await message.channel.send(response) +# get title of henti +@bot.command(name='title', help='Get the title of doujin using the holy numbers') +async def nine_nine(ctx, sauce): + r = H.get_title(sauce) + await ctx.send(r) +bot.run(TOKEN) -client.run(TOKEN) diff --git a/help_message.txt b/help_message.txt deleted file mode 100644 index 2eba79a..0000000 --- a/help_message.txt +++ /dev/null @@ -1,7 +0,0 @@ -``` -Every command should be prefixed with "' + CALL + '". -say repeats your previous message -info displays info about the bot and the creator -help shows this message -``` - diff --git a/henti.py b/henti.py index ae341d3..4d9a629 100644 --- a/henti.py +++ b/henti.py @@ -1,7 +1,7 @@ from hentai import Hentai from hentai import Format -def find_title(sauce): +def get_title(sauce): # get hentai title in readable format henti_title = str(Hentai(sauce).title(Format.Pretty)) return henti_title -- cgit v1.2.3