fix path variable #4
This commit is contained in:
parent
ba4d1cf115
commit
3d690379f7
1 changed files with 11 additions and 9 deletions
|
@ -18,6 +18,8 @@ from pathlib import Path
|
||||||
from giphy_client.rest import ApiException
|
from giphy_client.rest import ApiException
|
||||||
from bs4 import BeautifulSoup as bs
|
from bs4 import BeautifulSoup as bs
|
||||||
|
|
||||||
|
here = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
class Mybot(commands.Cog):
|
class Mybot(commands.Cog):
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
@ -40,10 +42,10 @@ class Mybot(commands.Cog):
|
||||||
async def joke(self, ctx, folder=None):
|
async def joke(self, ctx, folder=None):
|
||||||
user = ctx.message.author.name
|
user = ctx.message.author.name
|
||||||
if not folder or not ctx.message.content:
|
if not folder or not ctx.message.content:
|
||||||
audio_file = random.choice([f for f in Path('/home/mika/kabot/kabot/kabot/Audio/').glob('**/*.mp3')])
|
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')])
|
||||||
else:
|
else:
|
||||||
folder = folder.lower()
|
folder = folder.lower()
|
||||||
audio_file = random.choice([f for f in Path('/home/mika/kabot/kabot/kabot/Audio/').glob('**/*.mp3') if folder in str(f).lower()])
|
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3') if folder in str(f).lower()])
|
||||||
self.sounds.append((audio_file,ctx))
|
self.sounds.append((audio_file,ctx))
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -77,10 +79,10 @@ class Mybot(commands.Cog):
|
||||||
user = ctx.message.author.name
|
user = ctx.message.author.name
|
||||||
print(user)
|
print(user)
|
||||||
try:
|
try:
|
||||||
audio_file = random.choice([f for f in os.listdir('/home/mika/kabot/kabot/kabot/Audio/%s/' % user) if f.endswith('.mp3')])
|
audio_file = random.choice([f for f in os.listdir(here + '/Audio/%s/' % user) if f.endswith('.mp3')])
|
||||||
audio_file = '/home/mika/kabot/kabot/kabot/Audio/%s/' % user + audio_file
|
audio_file = here + '/Audio/%s/' % user + audio_file
|
||||||
except:
|
except:
|
||||||
audio_file = random.choice([f for f in Path('/home/mika/kabot/kabot/kabot/Audio/').glob('**/*.mp3')])
|
audio_file = random.choice([f for f in Path(here + '/Audio/').glob('**/*.mp3')])
|
||||||
self.sounds.append((audio_file,ctx))
|
self.sounds.append((audio_file,ctx))
|
||||||
|
|
||||||
@commands.command(help='Update local repo')
|
@commands.command(help='Update local repo')
|
||||||
|
@ -102,7 +104,7 @@ class Mybot(commands.Cog):
|
||||||
|
|
||||||
@commands.command(help='count lines numbers in quote file')
|
@commands.command(help='count lines numbers in quote file')
|
||||||
async def lines(self, ctx):
|
async def lines(self, ctx):
|
||||||
path = '/home/mika/.kabot/%s.log' % ctx.channel
|
path = here + '/' + ctx.channel
|
||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
lines = f.read().splitlines()
|
lines = f.read().splitlines()
|
||||||
nb_lines = len(lines)
|
nb_lines = len(lines)
|
||||||
|
@ -201,7 +203,7 @@ class Mybot(commands.Cog):
|
||||||
@commands.command(help="optionnal args : ")
|
@commands.command(help="optionnal args : ")
|
||||||
async def contrepeterie(self, ctx, *args):
|
async def contrepeterie(self, ctx, *args):
|
||||||
response = None
|
response = None
|
||||||
path = '/home/mika/kabot/kabot/kabot/ressources/contrepeteries.txt'
|
path = here + '/ressources/contrepeteries.txt'
|
||||||
lines = open(path).read().splitlines()
|
lines = open(path).read().splitlines()
|
||||||
myline =random.choice(lines)
|
myline =random.choice(lines)
|
||||||
|
|
||||||
|
@ -336,7 +338,7 @@ class Mybot(commands.Cog):
|
||||||
|
|
||||||
def get_word(word_type):
|
def get_word(word_type):
|
||||||
content = []
|
content = []
|
||||||
with open("/home/mika/kabot/kabot/kabot/ressources/base_kml.xml", "r", encoding="ISO-8859-1") as file:
|
with open(here + "/ressources/base_kml.xml", "r", encoding="ISO-8859-1") as file:
|
||||||
content = file.readlines()
|
content = file.readlines()
|
||||||
content = "".join(content)
|
content = "".join(content)
|
||||||
bs_content = bs(content, 'lxml')
|
bs_content = bs(content, 'lxml')
|
||||||
|
@ -459,7 +461,7 @@ def main():
|
||||||
if bot.user in message.mentions \
|
if bot.user in message.mentions \
|
||||||
and len(message.mentions) < 3 \
|
and len(message.mentions) < 3 \
|
||||||
and len(message.content.splitlines()) == 1:
|
and len(message.content.splitlines()) == 1:
|
||||||
path = '/home/mika/.kabot/%s.log' % message.channel
|
path = '/data/log/%s.log' % message.channel
|
||||||
with open(path, 'r') as f :
|
with open(path, 'r') as f :
|
||||||
lines = f.read().splitlines()
|
lines = f.read().splitlines()
|
||||||
if not message.content in lines:
|
if not message.content in lines:
|
||||||
|
|
Loading…
Reference in a new issue