json config

This commit is contained in:
aliasless 2020-04-20 00:26:32 +00:00
parent ef6205a707
commit 5c63302ca4
1 changed files with 15 additions and 12 deletions

View File

@ -6,25 +6,29 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger from apscheduler.triggers.cron import CronTrigger
from random import randint from random import randint
import asyncio import asyncio
import json
import time import time
import hashlib import hashlib
import os.path import os.path
ROOT = "/home/bot/ticker" ROOT = "/home/bot/ticker"
# gulids with open(ROOT + "/config.json") as file:
SEGUIS = 665399296522321942 conf = json.load(file)
GOONS = 369294266905657345
# guilds
SEGUIS = conf['guilds']['seguis']
GOONS = conf['guilds']['goons']
# users # users
MATT = 150791815723876352 MATT = conf['users']['matt']
DAD = 509547108907614208 DAD = conf['users']['dad']
CHEW = 193919775007703040 CHEW = conf['users']['chew']
# channels # channels
SMOKEYS = 673203690672357422 SMOKEYS = conf['channels']['smokeys']
RETARD = 695090043609415740 RETARD = conf['channels']['retard_dimension']
GHETTO = 699505527981473794 GHETTO = conf['channels']['league_ghetto']
client = discord.Client() client = discord.Client()
c = CurrencyRates() c = CurrencyRates()
@ -35,7 +39,7 @@ ticker_queue = asyncio.Queue()
# returns a file path from the cache # returns a file path from the cache
def to_tts(message, lang = 'ja', cache = True): def to_tts(message, lang = 'ja', cache = True):
# the file we save to is based on the hash of the message # the file we save to is based on the hash of the message
file_name = "dqn.mp3" file_name = ROOT + "/dqn.mp3"
if cache: if cache:
message_hash = hashlib.md5(message.encode('utf-8')).hexdigest() message_hash = hashlib.md5(message.encode('utf-8')).hexdigest()
file_name = ROOT + "/cache/" + message_hash + ".mp3" 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に移動しました") file_name = to_tts(member.display_name + "はretard dimensionに移動しました")
await add_event(file_name, before.channel) await add_event(file_name, before.channel)
client.loop.create_task(ticker_update())
# either matts channel, or the most active channel # either matts channel, or the most active channel
def get_best_channel(guild_id): def get_best_channel(guild_id):
guild = client.get_guild(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') + " Administrative action will now be taken against your account.", lang = 'de')
await add_event(file_name, client.get_channel(before_channel), move) 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.add_job(league_ghetto, CronTrigger(minute = '*/5'))
s.start() s.start()