@@ -9,42 +9,47 @@ def init(update, context):
9
9
try :
10
10
raise context .error
11
11
except Unauthorized :
12
- err = '[ERROR] Unauthorized\n '
12
+ err = '<i> [ERROR] Unauthorized</i> \n '
13
13
#error_message(update, context, err)
14
14
# remove update.message.chat_id from conversation list
15
15
except BadRequest :
16
- err = '[ERROR] BadRequest - malformed requests\n '
16
+ err = '<i> [ERROR] BadRequest - malformed requests</i> \n '
17
17
#error_message(update, context, err)
18
18
# handle malformed requests - read more below!
19
19
except TimedOut :
20
- err = '[ERROR] TimedOut - slow connection problems\n '
20
+ err = '<i> [ERROR] TimedOut - slow connection problems</i> \n '
21
21
#error_message(update, context, err)
22
22
# handle slow connection problems
23
23
except NetworkError :
24
- err = '[ERROR] NetworkError - other connection problems\n '
24
+ err = '<i> [ERROR] NetworkError - other connection problems</i> \n '
25
25
#error_message(update, context, err)
26
26
# handle other connection problems
27
27
except ChatMigrated :
28
- err = '[ERROR] ChatMigrated - chat_id not found (maybe group/channel migrated?)\n '
28
+ err = '<i> [ERROR] ChatMigrated - chat_id not found (maybe group/channel migrated?)</i> \n '
29
29
#error_message(update, context, err)
30
30
# the chat_id of a group has changed, use e.new_chat_id instead
31
31
except TelegramError :
32
- err = '[ERROR] TelegramError\n This is a generic error not handled by other handlers, check the console logs for info\n '
32
+ err = '<i> [ERROR] TelegramError\n This is a generic error not handled by other handlers, check the console logs for info</i> \n '
33
33
#error_message(update, context, err)
34
34
# handle all other telegram related errors
35
35
except AttributeError :
36
- err = '[ERROR] AttributeError - bad code'
36
+ err = '<i> [ERROR] AttributeError - bad code</i> '
37
37
except TypeError :
38
38
# err = '[ERROR] TypeError - Unknown'
39
39
# need to fix this...
40
40
err = None
41
41
42
42
if err != None :
43
- error_message (update , context , err , txt )
43
+ nomeutente = update .message .from_user .first_name
44
+ username = "@" + update .message .from_user .username
45
+ id = update .message .from_user .id
46
+ chat_id = update .message .chat_id
47
+ chat_name = update .message .chat .title
48
+ error_message (update , context , err , txt , nomeutente , username , id , chat_id , chat_name )
44
49
45
50
46
51
logging .basicConfig (format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' , level = logging .INFO )
47
52
logger = logging .getLogger (__name__ )
48
- def error_message (update , context , err , txt ):
49
- log = '\n [LOG] errore: {}' .format (context .error )
50
- context .bot .send_message (chat_id = config .log_channel , text = "{} \n \n {}{} " .format (txt , err , log ), parse_mode = 'HTML' )
53
+ def error_message (update , context , err , txt , name , username , id , chatid , chat_name ):
54
+ log = '\n <i> [LOG] errore: {}</i> ' .format (context .error )
55
+ context .bot .send_message (chat_id = config .log_channel , text = "<b>Resoconto errore</b> \n <b>Chat</b>: [{}][{}] \n <b>Utente</b>: [{}][{}][{}] \n <b>Comando/messaggio</b>:{} \n \n <b>Errori rilevati</b>: \n {}{} " .format (chat_name , chatid , id , name , username , txt , err , log ), parse_mode = 'HTML' )
0 commit comments