Passed
Push — master ( e503ca...3cd1a6 )
by Anas
01:52
created

modules.logging.get_chat_info()   A

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
from datetime import datetime
4
import threading
5
import sqlite3
6
import time
7
8
9
def logging_decorator(command_name):
10
    def decorator(func):
11
        def wrapper(update, context, *args, **kwargs):
12
            if not update.message:
13
                return
14
            time1 = time.time()
15
            current_time = datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")
16
            data = func(update, context, *args, **kwargs)
17
            time2 = time.time()
18
            print(
19
                "{} > /{} > {} > {} > {} > {:.0f} ms".format(
20
                    current_time,
21
                    command_name,
22
                    update.message.from_user.username,
23
                    update.message.from_user.id,
24
                    data,
25
                    (time2-time1)*1000
26
                )
27
            )
28
        return wrapper
29
    return decorator
30
31
32
def module_init(gd):
33
    pass
34