⬇️ Remove sentry
This commit is contained in:
parent
8ac59c48d6
commit
36f1af2f04
@ -1,15 +1,9 @@
|
|||||||
""" PagerMaid initialization. """
|
""" PagerMaid initialization. """
|
||||||
|
|
||||||
from concurrent.futures import CancelledError
|
|
||||||
|
|
||||||
# Analytics
|
|
||||||
import sentry_sdk
|
|
||||||
from sentry_sdk.integrations.redis import RedisIntegration
|
|
||||||
|
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import time
|
from time import time
|
||||||
from os import getcwd, makedirs, environ, remove
|
from os import getcwd, makedirs, environ
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
from sys import version_info, platform
|
from sys import version_info, platform
|
||||||
from yaml import load, FullLoader
|
from yaml import load, FullLoader
|
||||||
@ -23,24 +17,6 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|||||||
from telethon import TelegramClient
|
from telethon import TelegramClient
|
||||||
from telethon.sessions import StringSession
|
from telethon.sessions import StringSession
|
||||||
|
|
||||||
# Errors
|
|
||||||
from telethon.errors import AuthKeyError
|
|
||||||
from telethon.errors.rpcerrorlist import MessageNotModifiedError, MessageIdInvalidError, ChannelPrivateError, \
|
|
||||||
ChatSendMediaForbiddenError, YouBlockedUserError, FloodWaitError, ChatWriteForbiddenError, \
|
|
||||||
AuthKeyDuplicatedError, ChatSendStickersForbiddenError, SlowModeWaitError, MessageEditTimeExpiredError, \
|
|
||||||
PeerIdInvalidError, AuthKeyUnregisteredError, UserBannedInChannelError, UserDeactivatedBanError, PeerFloodError, \
|
|
||||||
SessionRevokedError
|
|
||||||
from telethon.errors.common import AlreadyInConversationError
|
|
||||||
from requests.exceptions import ChunkedEncodingError
|
|
||||||
from requests.exceptions import ConnectionError as ConnectedError
|
|
||||||
from asyncio import CancelledError as CancelError
|
|
||||||
from asyncio import TimeoutError as AsyncTimeoutError
|
|
||||||
from sqlite3 import OperationalError
|
|
||||||
from http.client import RemoteDisconnected
|
|
||||||
from urllib.error import URLError
|
|
||||||
from concurrent.futures._base import TimeoutError
|
|
||||||
from redis.exceptions import ResponseError
|
|
||||||
|
|
||||||
from languages.languages import Lang
|
from languages.languages import Lang
|
||||||
|
|
||||||
persistent_vars = {}
|
persistent_vars = {}
|
||||||
@ -222,8 +198,6 @@ async def save_id():
|
|||||||
user_id = me.id
|
user_id = me.id
|
||||||
user_bot = me.bot
|
user_bot = me.bot
|
||||||
if me.username is not None:
|
if me.username is not None:
|
||||||
sentry_sdk.set_user({"id": user_id, "name": me.first_name, "username": me.username, "ip_address": "{{auto}}",
|
|
||||||
"bot": f"{user_bot}"})
|
|
||||||
if allow_analytics:
|
if allow_analytics:
|
||||||
analytics.identify(user_id, {
|
analytics.identify(user_id, {
|
||||||
'name': me.first_name,
|
'name': me.first_name,
|
||||||
@ -231,8 +205,6 @@ async def save_id():
|
|||||||
'bot': f"{user_bot}"
|
'bot': f"{user_bot}"
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
sentry_sdk.set_user({"id": user_id, "name": me.first_name, "ip_address": "{{auto}}",
|
|
||||||
"bot": f"{user_bot}"})
|
|
||||||
if allow_analytics:
|
if allow_analytics:
|
||||||
analytics.identify(user_id, {
|
analytics.identify(user_id, {
|
||||||
'name': me.first_name,
|
'name': me.first_name,
|
||||||
@ -243,49 +215,12 @@ async def save_id():
|
|||||||
logs.info(f"{lang('save_id')} {me.first_name}({user_id})")
|
logs.info(f"{lang('save_id')} {me.first_name}({user_id})")
|
||||||
|
|
||||||
|
|
||||||
def before_send(event, hint):
|
|
||||||
global report_time
|
|
||||||
exc_info = hint.get("exc_info")
|
|
||||||
if exc_info and isinstance(exc_info[1], (ConnectionError, CancelledError, MessageNotModifiedError,
|
|
||||||
MessageIdInvalidError, OperationalError, ChannelPrivateError,
|
|
||||||
BufferError, RemoteDisconnected, ChatSendMediaForbiddenError,
|
|
||||||
TypeError, URLError, YouBlockedUserError, FloodWaitError,
|
|
||||||
ChunkedEncodingError, TimeoutError, UnicodeEncodeError,
|
|
||||||
ChatWriteForbiddenError, ChatSendStickersForbiddenError,
|
|
||||||
AlreadyInConversationError, ConnectedError, KeyboardInterrupt,
|
|
||||||
OSError, AuthKeyDuplicatedError, ResponseError, SlowModeWaitError,
|
|
||||||
PeerFloodError, MessageEditTimeExpiredError, PeerIdInvalidError,
|
|
||||||
AuthKeyUnregisteredError, UserBannedInChannelError, AuthKeyError,
|
|
||||||
CancelError, AsyncTimeoutError)):
|
|
||||||
return
|
|
||||||
elif exc_info and isinstance(exc_info[1], (UserDeactivatedBanError, SessionRevokedError)):
|
|
||||||
# The user has been deleted/deactivated or session revoked
|
|
||||||
try:
|
|
||||||
remove('pagermaid.session')
|
|
||||||
except Exception as exc:
|
|
||||||
print(exc)
|
|
||||||
exit(1)
|
|
||||||
if time() <= report_time + 30:
|
|
||||||
report_time = time()
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
report_time = time()
|
|
||||||
return event
|
|
||||||
|
|
||||||
with bot:
|
with bot:
|
||||||
bot.loop.run_until_complete(save_id())
|
bot.loop.run_until_complete(save_id())
|
||||||
|
|
||||||
report_time = time()
|
report_time = time()
|
||||||
start_time = datetime.utcnow()
|
start_time = datetime.utcnow()
|
||||||
git_hash = run("git rev-parse HEAD", stdout=PIPE, shell=True).stdout.decode()
|
git_hash = run("git rev-parse HEAD", stdout=PIPE, shell=True).stdout.decode()
|
||||||
sentry_sdk.init(
|
|
||||||
"https://58c6c9990d5c4d3784aec0aecb7509d3@o416616.ingest.sentry.io/5312335",
|
|
||||||
traces_sample_rate=1.0,
|
|
||||||
release=git_hash,
|
|
||||||
before_send=before_send,
|
|
||||||
environment="production",
|
|
||||||
integrations=[RedisIntegration()]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def redis_status():
|
def redis_status():
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
""" PagerMaid event listener. """
|
""" PagerMaid event listener. """
|
||||||
|
|
||||||
import re
|
|
||||||
import sentry_sdk
|
|
||||||
import sys
|
import sys
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
from time import gmtime, strftime, time
|
from time import gmtime, strftime, time
|
||||||
@ -10,7 +8,6 @@ from traceback import format_exc
|
|||||||
from telethon import events
|
from telethon import events
|
||||||
from telethon.errors import MessageTooLongError
|
from telethon.errors import MessageTooLongError
|
||||||
from telethon.events import StopPropagation
|
from telethon.events import StopPropagation
|
||||||
from telethon.tl.types import PeerUser
|
|
||||||
|
|
||||||
from pagermaid import bot, config, help_messages, logs, user_id, analytics, user_bot
|
from pagermaid import bot, config, help_messages, logs, user_id, analytics, user_bot
|
||||||
from pagermaid.utils import attach_report, lang, alias_command, admin_check
|
from pagermaid.utils import attach_report, lang, alias_command, admin_check
|
||||||
@ -152,16 +149,6 @@ def listener(**args):
|
|||||||
f"# Error: \"{str(exc_info)}\". \n"
|
f"# Error: \"{str(exc_info)}\". \n"
|
||||||
await attach_report(report, f"exception.{time()}.pagermaid", None,
|
await attach_report(report, f"exception.{time()}.pagermaid", None,
|
||||||
"Error report generated.")
|
"Error report generated.")
|
||||||
try:
|
|
||||||
sentry_sdk.set_context("Target",
|
|
||||||
{"ChatID": str(context.chat_id), "UserID": str(context.sender_id),
|
|
||||||
"Msg": context.text})
|
|
||||||
sentry_sdk.set_tag('com', re.findall("\w+", str.lower(context.text.split()[0]))[0])
|
|
||||||
sentry_sdk.capture_exception(e)
|
|
||||||
except:
|
|
||||||
logs.info(
|
|
||||||
lang('report_error')
|
|
||||||
)
|
|
||||||
|
|
||||||
if not ignore_edited:
|
if not ignore_edited:
|
||||||
bot.add_event_handler(handler, events.MessageEdited(**args))
|
bot.add_event_handler(handler, events.MessageEdited(**args))
|
||||||
|
@ -33,7 +33,6 @@ cheroot>=8.5.2
|
|||||||
python-socks[asyncio]>=1.2.4
|
python-socks[asyncio]>=1.2.4
|
||||||
certifi>=2021.5.30
|
certifi>=2021.5.30
|
||||||
magic_google>=0.2.9
|
magic_google>=0.2.9
|
||||||
sentry-sdk>=1.5.2
|
|
||||||
analytics-python>=1.4.0
|
analytics-python>=1.4.0
|
||||||
beautifulsoup4>=4.9.3
|
beautifulsoup4>=4.9.3
|
||||||
apscheduler>=3.8.1
|
apscheduler>=3.8.1
|
||||||
|
Loading…
Reference in New Issue
Block a user