Report errors to pwrtelegram.xyz by default

This commit is contained in:
Lonami Exo
2017-08-25 15:34:20 +02:00
parent 2517b9787d
commit 00b5b5021b
4 changed files with 42 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import urllib.request
import re
from .common import (
@@ -16,7 +17,22 @@ from .rpc_errors_401 import *
from .rpc_errors_420 import *
def rpc_message_to_error(code, message):
def rpc_message_to_error(code, message, report_method=None):
if report_method is not None:
try:
# Ensure it's signed
report_method = int.from_bytes(
report_method.to_bytes(4, 'big'), 'big', signed=True
)
url = urllib.request.urlopen(
'https://rpc.pwrtelegram.xyz?code={}&error={}&method={}'
.format(code, message, report_method)
)
url.read()
url.close()
except:
"We really don't want to crash when just reporting an error"
errors = {
303: rpc_errors_303_all,
400: rpc_errors_400_all,