json config
This commit is contained in:
parent
ef6205a707
commit
5c63302ca4
27
ticker.py
27
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue