File size: 4,155 Bytes
fefc4fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#Ultroid Plugin @TrueSaiyan
import time
import numpy as np
from dateutil.relativedelta import relativedelta
from datetime import datetime
from telethon import functions
from . import ultroid_cmd, eor
from . import get_help

__doc__ = get_help("help_creationdate")

data = {
    "7117444122": 1723429195,
    "6923006073": 1703439244,
    "6602485156": 1723148395,
    "5396587273": 1648014800,
    "5336336790": 1646368100,
    "4317845111": 1620028800,
    "3318845111": 1618028800,
    "2018845111": 1608028800,
    "1919230638": 1598028800,
    "755000000": 1548028800,
    "782000000": 1546300800,
    "727572658": 1543708800,
    "616816630": 1529625600,
    "391882013": 1509926400,
    "400169472": 1499904000,
    "369669043": 1492214400,
    "234480941": 1464825600,
    "200000000": 1451606400,
    "150000000": 1434326400,
    "10000000": 1413331200,
    "7679610": 1389744000,
    "2768409": 1383264000,
    "1000000": 1380326400,
}

class UserDateEstimator:
    def __init__(self, order=3):
        self.order = order
        self.x, self.y = self._unpack_data()
        self._func = self._fit_data()

    def _unpack_data(self):
        x_data = np.array(list(map(int, data.keys())))
        y_data = np.array(list(data.values()))
        return x_data, y_data

    def _fit_data(self):
        fitted = np.polyfit(self.x, self.y, self.order)
        return np.poly1d(fitted)

    def func(self, tg_id: int):
        # Check if tg_id exists in the data
        if str(tg_id) in data:
            return data[str(tg_id)]  # Return exact value if found
        value = self._func(tg_id)
        if value > time.time():
            value = time.time()
        return value

    def time_format(self, unix_time):
        formatted_date = datetime.utcfromtimestamp(unix_time).strftime("%Y-%m-%d %H:%M:%S")
        d = relativedelta(datetime.now(), datetime.utcfromtimestamp(unix_time))
        age = f"{d.years} year{'s' if d.years != 1 else ''}, {d.months} month{'s' if d.months != 1 else ''}, {d.days} day{'s' if d.days != 1 else ''}"
        return formatted_date, age


interpolation = UserDateEstimator()

@ultroid_cmd(pattern="actime(?: (.*))?$")
async def acc_create_date(event):
    """Ultroid command to get the account creation date."""
    input_str = event.pattern_match.group(1)
    
    if input_str: 
        try:
            if input_str.isdigit():
                tg_id = int(input_str)
            else:
                user = await event.client.get_entity(input_str)
                tg_id = int(user.id)

            unix_time = round(interpolation.func(tg_id))

            date = interpolation.time_format(unix_time=unix_time)
            await event.eor(
                f"**User:** {input_str}\n**Account Creation Date**: {date[0]}\n**Age**: {date[1]}"
            )
        except Exception as e:
            await event.eor(f"Error: {str(e)}")

    elif event.reply_to_msg_id:
        reply = await event.get_reply_message()
        tg_id = int(reply.sender_id)
        try:
            # Use the estimation function
            unix_time = round(interpolation.func(tg_id))

            date = interpolation.time_format(unix_time=unix_time)
            await event.eor(
                f"**Account Creation Date**: {date[0]}\n**Age**: {date[1]}"
            )
        except Exception as e:
            await event.eor(f"Error: {str(e)}")
    else:
        await event.eor("Provide a username, user ID, or reply to a user's message to get the account creation time.")
        
@ultroid_cmd("dc")
async def _(event):
    "To get dc of your bot"
    result = await event.client(functions.help.GetNearestDcRequest())
    result = f"**Dc details of your account:**\
              \n**Country :** {result.country}\
              \n**Current Dc :** {result.this_dc}\
              \n**Nearest Dc :** {result.nearest_dc}\
              \n\n**List Of Telegram Data Centres:**\
              \n**DC1 : **Miami FL, USA\
              \n**DC2 :** Amsterdam, NL\
              \n**DC3 :** Miami FL, USA\
              \n**DC4 :** Amsterdam, NL\
              \n**DC5 : **Singapore, SG\
                "
    await eor(event, result)