From b284ca1468b19286d79ce5d9b78a95819c272443 Mon Sep 17 00:00:00 2001 From: Xtao_dada Date: Sun, 18 Jul 2021 14:37:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=F0=9F=93=88=20Fix=20the=20problem?= =?UTF-8?q?=20of=20unlimited=20restart.=20(#110)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛📈 修复国内环境关闭用户体验计划后仍然加载失败的问题。 --- pagermaid/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pagermaid/__init__.py b/pagermaid/__init__.py index 03dbb0c..9282d0a 100644 --- a/pagermaid/__init__.py +++ b/pagermaid/__init__.py @@ -43,7 +43,6 @@ module_dir = __path__[0] working_dir = getcwd() config = None help_messages = {} -mp = Mixpanel("7be1833326f803740214fe276f5a5a3d") logs = getLogger(__name__) logging_format = "%(levelname)s [%(asctime)s] [%(name)s] %(message)s" logging_handler = StreamHandler() @@ -91,6 +90,10 @@ def lang(text: str) -> str: return result +if strtobool(config['allow_analytics']): + mp = Mixpanel("7be1833326f803740214fe276f5a5a3d") +else: + mp = None if strtobool(config['debug']): logs.setLevel(DEBUG) else: @@ -203,10 +206,12 @@ async def save_id(): user_id = me.id if me.username is not None: sentry_sdk.set_user({"id": user_id, "name": me.first_name, "username": me.username, "ip_address": "{{auto}}"}) - mp.people_set(str(user_id), {'$first_name': me.first_name, "username": me.username}) + if strtobool(config['allow_analytics']): + mp.people_set(str(user_id), {'$first_name': me.first_name, "username": me.username}) else: sentry_sdk.set_user({"id": user_id, "name": me.first_name, "ip_address": "{{auto}}"}) - mp.people_set(str(user_id), {'$first_name': me.first_name}) + if strtobool(config['allow_analytics']): + mp.people_set(str(user_id), {'$first_name': me.first_name}) logs.info(f"{lang('save_id')} {me.first_name}({user_id})")