-
Notifications
You must be signed in to change notification settings - Fork 0
/
wspr.py
199 lines (184 loc) · 5.86 KB
/
wspr.py
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# Oreo - UserBot
import re
from telethon import Button
from telethon.errors.rpcerrorlist import (
BotInlineDisabledError,
BotResponseTimeoutError,
MessageNotModifiedError,
)
from telethon.tl import types
from telethon.tl.functions.users import GetFullUserRequest as gu
from . import (
HNDLR,
LOGS,
asst,
callback,
get_string,
in_pattern,
inline_mention,
oreo_bot,
oreo_cmd,
)
oro = {}
@oreo_cmd(
pattern="wspr( (.*)|$)",
)
async def _(e):
if e.reply_to_msg_id:
okk = await e.get_reply_message()
put = f"@{okk.sender.username}" if okk.sender.username else okk.sender_id
else:
put = e.pattern_match.group(1).strip()
if put:
try:
results = await e.client.inline_query(asst.me.username, f"msg {put}")
except BotResponseTimeoutError:
return await e.eor(
get_string("help_2").format(HNDLR),
)
except BotInlineDisabledError:
return await e.eor(get_string("help_3"))
await results[0].click(e.chat_id, reply_to=e.reply_to_msg_id, hide_via=True)
return await e.delete()
await e.eor(get_string("wspr_3"))
@in_pattern("wspr", owner=True)
async def _(e):
iuser = e.query.user_id
zzz = e.text.split(maxsplit=2)
try:
query = zzz[1]
if query.isdigit():
query = int(query)
logi = await oreo_bot.get_entity(query)
if not isinstance(logi, types.User):
raise ValueError("Invalid Username.")
except IndexError:
sur = await e.builder.article(
title="Give Username",
description="You Didn't Type Username or id.",
text="You Didn't Type Username or id.",
)
return await e.answer([sur])
except ValueError as er:
LOGS.exception(er)
sur = await e.builder.article(
title="User Not Found",
description="Make sure username or id is correct.",
text="Make sure username or id is correct.",
)
return await e.answer([sur])
try:
desc = zzz[2]
except IndexError:
sur = await e.builder.article(
title="Type ur msg", text="You Didn't Type Your Msg"
)
return await e.answer([sur])
button = [
[
Button.inline("Secret Msg", data=f"dd_{e.id}"),
Button.inline("Delete Msg", data=f"del_{e.id}"),
],
[
Button.switch_inline(
"New", query=f"wspr {logi.username or logi.id}", same_peer=True
)
],
]
us = logi.username or logi.first_name
sur = await e.builder.article(
title=logi.first_name,
description=desc,
text=get_string("wspr_1").format(us),
buttons=button,
)
oro.update({e.id: [logi.id, iuser, desc]})
await e.answer([sur])
@in_pattern("msg", owner=True)
async def _(e):
zzz = e.text.split(maxsplit=1)
desc = "Touch me"
try:
query = zzz[1]
if query.isdigit():
query = int(query)
logi = await oreo_bot(gu(id=query))
user = logi.users[0]
mention = inline_mention(user)
x = user.status
if isinstance(x, types.UserStatusOnline):
status = "Online"
elif isinstance(x, types.UserStatusOffline):
status = "Offline"
elif isinstance(x, types.UserStatusRecently):
status = "Last Seen Recently"
elif isinstance(x, types.UserStatusLastMonth):
status = "Last seen months ago"
elif isinstance(x, types.UserStatusLastWeek):
status = "Last seen weeks ago"
else:
status = "Can't Tell"
text = f"**Name:** `{user.first_name}`\n"
text += f"**Id:** `{user.id}`\n"
if user.username:
text += f"**Username:** `{user.username}`\n"
url = f"https://t.me/{user.username}"
else:
text += f"**Mention:** `{mention}`\n"
url = f"tg://user?id={user.id}"
text += f"**Status:** `{status}`\n"
text += f"**About:** `{logi.full_user.about}`"
button = [
Button.url("Private", url=url),
Button.switch_inline(
"Secret msg",
query=f"wspr {query} Hello 👋",
same_peer=True,
),
]
sur = e.builder.article(
title=user.first_name,
description=desc,
text=text,
buttons=button,
)
except IndexError:
sur = e.builder.article(
title="Give Username",
description="You Didn't Type Username or id.",
text="You Didn't Type Username or id.",
)
except BaseException as er:
LOGS.exception(er)
name = get_string("wspr_4").format(query)
sur = e.builder.article(
title=name,
text=name,
)
await e.answer([sur])
@callback(
re.compile(
"dd_(.*)",
),
)
async def _(e):
ids = int(e.pattern_match.group(1).strip().decode("UTF-8"))
if oro.get(ids):
if e.sender_id in oro[ids]:
await e.answer(oro[ids][-1], alert=True)
else:
await e.answer("Not For You", alert=True)
else:
await e.answer(get_string("wspr_2"), alert=True)
@callback(re.compile("del_(.*)"))
async def _(e):
ids = int(e.pattern_match.group(1).strip().decode("UTF-8"))
if oro.get(ids):
if e.sender_id in oro[ids]:
oro.pop(ids)
try:
await e.edit(get_string("wspr_2"))
except MessageNotModifiedError:
pass
else:
await e.answer(get_string("wspr_5"), alert=True)