Archived
1
0
Fork 0

FUCK YOU GBK

This commit is contained in:
yzhh 2021-08-21 15:45:21 +08:00
parent 0797ea3967
commit 016450340a
6 changed files with 18 additions and 3 deletions

11
bot.py
View file

@ -1,3 +1,4 @@
import sys
import traceback
from init import init_bot
@ -6,6 +7,13 @@ import os
import subprocess
from queue import Queue, Empty
from threading import Thread
import locale
encode = 'UTF-8'
if locale.getdefaultlocale()[1] == 'cp936':
encode = 'GBK'
def enqueue_output(out, queue):
for line in iter(out.readline, b''):
@ -42,8 +50,9 @@ while True:
x.kill()
else:
try:
logging.info(line.decode('utf8')[:-1])
logging.info(line[:-1].decode(encode))
except Exception:
print(line)
traceback.print_exc()
# break when all processes are done.

View file

@ -1,4 +1,5 @@
import asyncio
import logging
import os
from aiogram import types, executor
@ -38,6 +39,7 @@ async def on_startup(dispatcher):
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
await asyncio.gather(*gather_list)
Scheduler.start()
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
if dp:

View file

@ -1,4 +1,5 @@
import asyncio
import logging
import os
import discord
@ -25,6 +26,7 @@ async def on_ready():
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
await asyncio.gather(*gather_list)
Scheduler.start()
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
@client.event

View file

@ -1,4 +1,5 @@
import asyncio
import logging
import os
from graia.application.event.mirai import NewFriendRequestEvent, BotInvitedJoinGroupRequestEvent
@ -54,6 +55,7 @@ async def autorun_handler():
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
await asyncio.gather(*gather_list)
Scheduler.start()
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
if Config('qq_host') and Config('qq_account'):

View file

@ -28,7 +28,7 @@ class Logginglogger(AbstractLogger):
def __init__(self, fmt="[%(asctime)s][%(levelname)s]: %(msg)s", **kwargs):
logging.basicConfig(
format=fmt,
level=logging.INFO if not kwargs.get("debug") else logging.DEBUG,
level=logging.INFO if not kwargs.get("debug") else logging.DEBUG
)
def info(self, msg):

View file

@ -18,4 +18,4 @@ def init_bot():
tag = os.path.abspath('.version_tag')
write_tag = open(tag, 'w')
write_tag.write(os.popen('git tag -l', 'r').read().split('\n')[-2])
write_tag.close()
write_tag.close()