FUCK YOU GBK
This commit is contained in:
parent
0797ea3967
commit
016450340a
6 changed files with 18 additions and 3 deletions
11
bot.py
11
bot.py
|
@ -1,3 +1,4 @@
|
||||||
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from init import init_bot
|
from init import init_bot
|
||||||
|
@ -6,6 +7,13 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
import locale
|
||||||
|
|
||||||
|
|
||||||
|
encode = 'UTF-8'
|
||||||
|
if locale.getdefaultlocale()[1] == 'cp936':
|
||||||
|
encode = 'GBK'
|
||||||
|
|
||||||
|
|
||||||
def enqueue_output(out, queue):
|
def enqueue_output(out, queue):
|
||||||
for line in iter(out.readline, b''):
|
for line in iter(out.readline, b''):
|
||||||
|
@ -42,8 +50,9 @@ while True:
|
||||||
x.kill()
|
x.kill()
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
logging.info(line.decode('utf8')[:-1])
|
logging.info(line[:-1].decode(encode))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
print(line)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
# break when all processes are done.
|
# break when all processes are done.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from aiogram import types, executor
|
from aiogram import types, executor
|
||||||
|
@ -38,6 +39,7 @@ async def on_startup(dispatcher):
|
||||||
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
|
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
|
||||||
await asyncio.gather(*gather_list)
|
await asyncio.gather(*gather_list)
|
||||||
Scheduler.start()
|
Scheduler.start()
|
||||||
|
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
|
||||||
if dp:
|
if dp:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
@ -25,6 +26,7 @@ async def on_ready():
|
||||||
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
|
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
|
||||||
await asyncio.gather(*gather_list)
|
await asyncio.gather(*gather_list)
|
||||||
Scheduler.start()
|
Scheduler.start()
|
||||||
|
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from graia.application.event.mirai import NewFriendRequestEvent, BotInvitedJoinGroupRequestEvent
|
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)))
|
gather_list.append(asyncio.ensure_future(Modules[x].function(FetchTarget)))
|
||||||
await asyncio.gather(*gather_list)
|
await asyncio.gather(*gather_list)
|
||||||
Scheduler.start()
|
Scheduler.start()
|
||||||
|
logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
|
||||||
if Config('qq_host') and Config('qq_account'):
|
if Config('qq_host') and Config('qq_account'):
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Logginglogger(AbstractLogger):
|
||||||
def __init__(self, fmt="[%(asctime)s][%(levelname)s]: %(msg)s", **kwargs):
|
def __init__(self, fmt="[%(asctime)s][%(levelname)s]: %(msg)s", **kwargs):
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format=fmt,
|
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):
|
def info(self, msg):
|
||||||
|
|
Reference in a new issue