From 5c63302ca41fcd509450c7a2d12d1dc4c1ae3c35 Mon Sep 17 00:00:00 2001 From: aliasless Date: Mon, 20 Apr 2020 00:26:32 +0000 Subject: [PATCH] json config --- ticker.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ticker.py b/ticker.py index 58dfe2a..35b5ddc 100644 --- a/ticker.py +++ b/ticker.py @@ -6,25 +6,29 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.triggers.cron import CronTrigger from random import randint import asyncio +import json import time import hashlib import os.path ROOT = "/home/bot/ticker" -# gulids -SEGUIS = 665399296522321942 -GOONS = 369294266905657345 +with open(ROOT + "/config.json") as file: + conf = json.load(file) + +# guilds +SEGUIS = conf['guilds']['seguis'] +GOONS = conf['guilds']['goons'] # users -MATT = 150791815723876352 -DAD = 509547108907614208 -CHEW = 193919775007703040 +MATT = conf['users']['matt'] +DAD = conf['users']['dad'] +CHEW = conf['users']['chew'] # channels -SMOKEYS = 673203690672357422 -RETARD = 695090043609415740 -GHETTO = 699505527981473794 +SMOKEYS = conf['channels']['smokeys'] +RETARD = conf['channels']['retard_dimension'] +GHETTO = conf['channels']['league_ghetto'] client = discord.Client() c = CurrencyRates() @@ -35,7 +39,7 @@ ticker_queue = asyncio.Queue() # returns a file path from the cache def to_tts(message, lang = 'ja', cache = True): # the file we save to is based on the hash of the message - file_name = "dqn.mp3" + file_name = ROOT + "/dqn.mp3" if cache: message_hash = hashlib.md5(message.encode('utf-8')).hexdigest() file_name = ROOT + "/cache/" + message_hash + ".mp3" @@ -110,8 +114,6 @@ async def on_voice_state_update(member, before, after): file_name = to_tts(member.display_name + "はretard dimensionに移動しました") await add_event(file_name, before.channel) -client.loop.create_task(ticker_update()) - # either matts channel, or the most active channel def get_best_channel(guild_id): guild = client.get_guild(guild_id) @@ -176,6 +178,7 @@ async def league_ghetto(): + " Administrative action will now be taken against your account.", lang = 'de') await add_event(file_name, client.get_channel(before_channel), move) +client.loop.create_task(ticker_update()) s.add_job(league_ghetto, CronTrigger(minute = '*/5')) s.start()