Ejemplo n.º 1
0
    async def on_message(self, message):
        if message.author == self.bot.user or message.author.bot:
            return
        else:
            if 'marry me kamikaze' == message.content.lower():
                if checks.check_owner(message): #if you're mintea:
                    response = random.choice(['F**k off.', 'Shut up you bastard.', 'Kill yourself.', "Why don't you go jerk off to Asanagi, you Kuso."])
                else: #otherwise, if you're not mintea:
                    if random.randint(1, 10000) == 1: #roll 0.01% chance for happy end
                        await self.bot.send_message(message.channel, random.choice('Sure~ <3', 'Ok ///w///'))
                    else: #otherwise, get a response from the accumulated rejection list
                        response_choices = ['No thanks~', 'Eh? uh.. sorry.', 'Marriage? Eh.. sorry.', 'M-Marriage? Uh.. maybe not.',
                            'Marriage? Don\'t you have more important duties to attend to?', 'Maybe when you\'re a little older...',
                            'The age gap though... Sorry.']
                        if message.author.id == '172704013911982080': #if you're Jimmy:
                            more_choices = ['But you have Kawakaze...', 'But you\'re already married to Kongou...', 'If you had a girlfriend, you wouldn\'t need to constantly propose to me.', 'If you had a girlfriend, I wouldn\'t have to constantly reject you.']
                        elif message.author.id == '176610457992429568': #if you're nyanko:
                            more_choices = ['But you have Bep...']
                        try:
                            for x in more_choices:
                                response_choices.append(x)
                        except Exception:
                            pass
                        response = random.choice(response_choices)
                await self.bot.send_message(message.channel, response)

            elif 'shut up kamikaze' in message.content.lower():
                switch = tools.loadPickle('kamikaze_chime.pickle')
                switch[message.server.id] = False
                tools.dumpPickle(switch, 'kamikaze_chime.pickle')
                await self.bot.send_message(message.channel, 'Sorry... ; A ;')

            elif 'sorry kamikaze' in message.content.lower():
                switch = tools.loadPickle('kamikaze_chime.pickle')
                switch[message.server.id] = True
                tools.dumpPickle(switch, 'kamikaze_chime.pickle')
                await self.bot.send_message(message.channel, 'u w u')

            elif 'kamikaze' in message.content.lower():
                switch = tools.loadPickle('kamikaze_chime.pickle')
                try:
                    if switch[message.server.id]:
                        interruption = ['Did someone call me? :D', 'Someone say my name?']
                        await self.bot.send_message(message.channel, random.choice(interruption))
                        msg = await self.bot.wait_for_message(timeout=5, author=message.author, check=lambda x: x.content.lower() in ['yes', 'no', 'help'])
                        try:
                            if 'yes' in msg.content.lower():
                                await self.bot.send_message(message.channel, 'o w o')
                            elif 'no' in msg.content.lower():
                                await self.bot.send_message(message.channel, '> _ <')
                            elif 'help' in msg.content.lower():
                                await self.bot.send_message(message.channel, "Say !k.help for a list of commands = w =")
                        except AttributeError:
                            pass
                except KeyError:
                    await self.bot.send_message(message.channel, "No server info detected. Please run _serverSetup command.")
                except AttributeError:
                    pass
Ejemplo n.º 2
0
 async def notepad(self, ctx, *, content : str=None):
     """Store some text for later viewing. Clear with '!k.notepad clear.'"""
     data = tools.loadPickle('notepad.pickle')
     author = ctx.message.author
     if content is None:
         try:
             title = "{}'s Notepad".format(author.name)
             description = ''
             for x in data[author.id]:
                 description += "{}\n".format(x)
             em = discord.Embed(title=title, description=description, colour=author.colour)
             await self.bot.say(embed=em)
         except KeyError:
             await self.bot.say("You haven't written anything in your notepad... ( ̄~ ̄;)")
     elif content == 'clear':
         data[author.id] = []
         tools.dumpPickle(data, 'notepad.pickle')
         await self.bot.say('Your notepad has been cleared~ ( ^ _ ^ )')
     else:
         try:
             data[author.id].append(content)
             tools.dumpPickle(data, 'notepad.pickle')
             await self.bot.say("Successfully saved to your notepad! \( ̄▽ ̄)/")
         except KeyError: # when it is first time data appending:
             await self.bot.say('Setting up your notepad for the first time~ ( ´ ▽ ` )')
             data[author.id] = []
             data[author.id].append(content)
             tools.dumpPickle(data, 'notepad.pickle')
             await self.bot.say("Successfully saved to your notepad! \( ̄▽ ̄)/")
Ejemplo n.º 3
0
 async def edit(self, ctx):
     """Edit the countdown target."""
     AUTO_TIMEOUT = 300 # 5 minutes
     if checks.check_moderator(ctx.message):
         info1 = await self.bot.say("Please enter a new target date in format: **DD-MM-YYYY, HH:MM:SS**")
         msg1 = await self.bot.wait_for_message(timeout=AUTO_TIMEOUT, author=ctx.message.author)
         if msg1 is None:
             await tools.inputTimeout(self.bot, ctx, topic="countdown edit")
             return
         else:
             try:
                 newTime = datetime.strptime(msg1.content, '%d-%m-%Y, %H:%M:%S')
             except ValueError:
                 await self.bot.say("Sorry, formatting was incorrect. Remember to include 0s where needed. Try _!k.countdown edit_ again.")
                 return
         info2 = await self.bot.say("Please enter the countdown timer's flavour text:")
         msg2 = await self.bot.wait_for_message(timeout=AUTO_TIMEOUT, author=ctx.message.author)
         if msg2 is None:
             await tools.inputTimeout(self.bot, ctx, topic="countdown edit")
             return
         else:
             text = msg2.content
             countdown_all = tools.loadPickle('countdown_all.pickle')
             countdown_all[ctx.message.server.id] = [newTime, text]
             tools.dumpPickle(countdown_all, 'countdown_all.pickle')
             await self.bot.delete_messages([info1, msg1, info2, msg2])
             await self.bot.say("Successfully updated the server countdown target!")
     else:
         await self.bot.say("You do not have permission to do that.")
         return
Ejemplo n.º 4
0
 async def remove(self, ctx):
     """Remove your IP from the soku IP list."""
     try:
         soku_ip = tools.loadPickle('soku_ip.pickle')
         soku_ip.pop(ctx.message.author.name)
         tools.dumpPickle(soku_ip, 'soku_ip.pickle')
         await self.bot.say("Successfully removed {} from the list".format(
             ctx.message.author.name))
     except KeyError:
         await self.bot.say("You are not in the soku IP list.")
     except Exception as e:
         await self.bot.say("{}: {}".format(type(e).__name__, e))
Ejemplo n.º 5
0
 async def get(self, ctx, *, target: str):
     """Retrieve the target user's IP."""
     soku_ip = tools.loadPickle('soku_ip.pickle')
     # you can only retrieve ips in the soku channel
     if checks.check_soku(ctx.message):
         try:
             soku_ip = tools.loadPickle('soku_ip.pickle')
             try:
                 ip = soku_ip[target[0].upper() + target[1:].lower()]
                 em = tools.createEmbed(
                     title="{}'s Soku IP".format(target[0].upper() +
                                                 target[1:]),
                     description=ip)
                 await self.bot.say(embed=em, delete_after=60)
                 await self.bot.delete_message(ctx.message)
             except KeyError:
                 await self.bot.say(
                     "Unable to find {} in the list.".format(target))
         except Exception as e:
             await self.bot.say("{}: {}".format(type(e).__name__, e))
     else:
         await wrongServerError(self.bot, ctx.message)
Ejemplo n.º 6
0
 async def add(self, ctx, ip: str):
     """Add yourself to the soku IP list."""
     await self.bot.delete_message(ctx.message)
     soku_ip = tools.loadPickle('soku_ip.pickle')
     soku_ip[ctx.message.author.name] = ip
     if ':' not in ip:
         ip += ':10800'
     try:
         tools.dumpPickle(soku_ip, 'soku_ip.pickle')
         await self.bot.say("Successfully added {} to the IP list.".format(
             ctx.message.author.name))
     except Exception as e:
         await self.bot.say('Unable to add to IP list')
Ejemplo n.º 7
0
 async def add_other(self, ctx, target: str, ip: str):
     """Add someone else's IP to the list."""
     if checks.check_admin(ctx.message):
         try:
             await self.bot.delete_message(ctx.message)
             soku_ip = tools.loadPickle('soku_ip.pickle')
             if ':' not in ip:
                 ip += ':10800'
             soku_ip[target[0].upper() + target[1:].lower()] = ip
             tools.dumpPickle(soku_ip, 'soku_ip.pickle')
             await self.bot.say(
                 "Successfully added {}'s IP to the list.".format(target))
         except Exception as e:
             await self.bot.say(
                 "Unable to add {} to the IP list.".format(target))
Ejemplo n.º 8
0
 async def _serverSetup(self, ctx):
     """Setup server specific persistence modules."""
     if checks.check_owner(ctx.message) or checks.check_admin(ctx.message):
         serverID = ctx.message.server.id
         await self.bot.delete_message(ctx.message)
         await self.bot.say("Setting up...", delete_after=12)
         try:
             #kamikaze chime
             kamikaze_chime = tools.loadPickle('kamikaze_chime.pickle')
             kamikaze_chime[serverID] = True
             tools.dumpPickle(kamikaze_chime, 'kamikaze_chime.pickle')
             await self.bot.say("**kamikaze_chime** setup success", delete_after=10)
             # END
             await self.bot.say("Setup successful", delete_after=10)
         except Exception as e:
             await self.bot.say("SETUP FAILED\n{}: {}".format(type(e).__name__, e))
Ejemplo n.º 9
0
 async def ip(self, ctx):
     """View the Soku IP list."""
     if ctx.invoked_subcommand is None:
         soku_ip = tools.loadPickle('soku_ip.pickle')
         try:
             all_ip = ''
             for x in soku_ip:
                 ip = soku_ip[x]
                 for y in range(10):
                     ip = ip.replace(str(y), 'x')
                 ip = soku_ip[x].split('.')[0] + '.' + '.'.join(
                     ip.split('.')[1:])
                 all_ip += '{}: **{}**\n'.format(x, ip)
             await self.bot.say(embed=tools.createEmbed(
                 title="Houraigekisen Soku IP list", description=all_ip))
         except Exception as e:
             await self.bot.say('{}: {}'.format(type(e).__name__, e))
Ejemplo n.º 10
0
    async def countdown(self, ctx):
        """Displays the remaining time until a specified event."""
        # Check if the server is already in the list, if not, add a dummy datetime
        countdown_all = tools.loadPickle('countdown_all.pickle')
        try:
            countdown_server = countdown_all[ctx.message.server.id]
        except KeyError:
            countdown_all[ctx.message.server.id] = [datetime.now(), "remain"]
            tools.dumpPickle(countdown_all, 'countdown_all.pickle')
            countdown_server = countdown_all[ctx.message.server.id]

        if ctx.invoked_subcommand is None:
            if countdown_server[0] > datetime.now():
                tdelta = countdown_server[0] - datetime.now()
                text = countdown_server[1]
            else:
                tdelta = datetime(year=2100, month=10, day=10, hour=10, minute=10, second=10) - datetime.now()
                text = "until nothing happens..."
            #await self.bot.say("`{}` {}".format(removeMicroseconds(tdelta), text))
            #await self.bot.say(embed=tools.createEmbed(title="{} {}".format(removeMicroseconds(tdelta), text)))
            await self.bot.say(embed=tools.createEmbed(title=str(removeMicroseconds(tdelta)), description=text))
Ejemplo n.º 11
0
 async def oasw(self, ctx, *, kanmusu: str):
     """Show the OASW level requirements for a kanmusu."""
     oasw_database = tools.loadPickle('oasw_database.pickle')
     kanmusu = kanmusu.split(' ')[0].lower(
     )  # strip off any unnecessary tags (such as 'kai', 'kai ni', etc.)
     try:
         data = oasw_database[kanmusu]
     except KeyError:
         await self.bot.say(
             "Unable to find **{}'s** data. Remember to use long sounds eg. _Y**uu**dachi_, not _Y**u**dachi_."
             .format(kanmusu[0].upper() + kanmusu[1:]))
         await oaswSuggestions(self.bot, ctx, kanmusu)
         return
     tags = oasw_database[len(oasw_database[kanmusu])]
     title = "{}'s Opening ASW data".format(kanmusu[0].upper() +
                                            kanmusu[1:])
     description = "Assuming highest kai'd form..."
     em = tools.createEmbed(title=title, description=description)
     for x in tags:
         em.add_field(name=x, value=data[tags.index(x)])
     await self.bot.say(embed=em)
Ejemplo n.º 12
0
 async def remove_other(self, ctx, *, target: str):
     """Remove an entry from the soku IP list."""
     if checks.check_admin(ctx.message):
         try:
             soku_ip = tools.loadPickle('soku_ip.pickle')
         except Exception as e:
             await self.bot.say("{}: {}".format(type(e).__name__, e))
         try:
             soku_ip.pop(target)
             await self.bot.say(
                 "{} was removed from the list.".format(target))
             tools.dumpPickle(soku_ip, 'soku_ip.pickle')
         except KeyError:
             try:
                 # retry after applying case sensitive modifications
                 soku_ip.pop(target[0].upper() + target[1:].lower())
                 tools.dumpPickle(soku_ip, 'soku_ip.pickle')
                 await self.bot.say(
                     "{} was removed from the list.".format(target))
             except KeyError:
                 await self.bot.say(
                     "Unable to find {} in the IP list".format(target))
         except Exception as e:
             pass
Ejemplo n.º 13
0
import discord, asyncio
from discord.ext import commands
from cogs.utilities import tools
from apiclient.discovery import build
from apiclient.errors import HttpError

API_KEY = tools.loadPickle('youtube_api_key.pickle')
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"

SELECTION_TIMEOUT = 300  # 5 minutes


def youtube_search(q):
    youtube = build(YOUTUBE_API_SERVICE_NAME,
                    YOUTUBE_API_VERSION,
                    developerKey=API_KEY)
    search_response = youtube.search().list(q=q,
                                            type="video",
                                            part="snippet",
                                            maxResults=9).execute()
    videos = []
    for item in search_response['items']:
        videos.append((item['id']['videoId'], item['snippet']['title']))
    return videos  # returns a list of (ID, VIDEO_TITLE)


async def display_choices(bot, ctx, options, query: str):
    title = "Results for: _{}_".format(query)
    description = "Please select an option:\n\n"
    description += '\n'.join(
Ejemplo n.º 14
0
def get_key():
    creds = tools.loadPickle("crds.pickle")
    with open(creds['keyPath'], "r") as f:
        key = f.read()
    return key