initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import asyncio
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import os
|
||||
from random import randint
|
||||
|
||||
class Porno(object):
|
||||
"""Porno commando's. Jij weet wat er aan is."""
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.voice_states = {}
|
||||
self.fileIndex = {}
|
||||
def __check(self, ctx): #Todo: Is dit het porno kanaal?
|
||||
return True
|
||||
|
||||
def randomJpgFromFolder(self, dir):
|
||||
if dir not in self.fileIndex.keys():
|
||||
self.fileIndex[dir] = [] #empty list
|
||||
for dirname, dirnames, filenames in os.walk('./'+ dir):
|
||||
for filename in filenames:
|
||||
if filename.endswith('.jpg'):
|
||||
self.fileIndex[dir].append(os.path.join(dirname, filename))
|
||||
#now we should have an index for the selected folder, but it might still be empty (i.e. empty folder given)
|
||||
if self.fileIndex[dir]:
|
||||
return self.fileIndex[dir][randint(0,len(self.fileIndex[dir])-1)] #get a random element from the newly created index
|
||||
else:
|
||||
return 'default file here'
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
@asyncio.coroutine
|
||||
def ancilla(self, ctx):
|
||||
""" :-) """
|
||||
filepath = self.randomJpgFromFolder('ancilla');
|
||||
file = open(filepath, 'rb')
|
||||
yield from self.bot.upload(file, filename = filepath, content='Alsjeblieft!')
|
||||
Reference in New Issue
Block a user