-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathstatus.py
93 lines (85 loc) · 3.01 KB
/
status.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
import os
import urllib
from telethon.tl import functions
from userbot import catub
from userbot.core.managers import edit_delete, edit_or_reply
from userbot.sql_helper.globals import addgvar, gvarstatus
plugin_category = "utils"
OFFLINE_TAG = "[OFFLINE]"
@catub.cat_cmd(
pattern="offline$",
command=("offline", plugin_category),
info={
"header": "To your status as offline",
"description": " it change your pic as offline, and add offline tag in name.",
"usage": "{tr}offline",
},
)
async def pussy(event):
"make yourself offline"
user = await event.client.get_entity("me")
if user.first_name.startswith(OFFLINE_TAG):
return await edit_delete(event, "**Already in Offline Mode.**")
await edit_or_reply(event, "**Changing Profile to Offline...**")
photo = "./temp/donottouch.jpg"
if not os.path.isdir("./temp"):
os.mkdir("./temp")
urllib.request.urlretrieve(
"https://telegra.ph/file/249f27d5b52a87babcb3f.jpg", photo
)
if photo:
file = await event.client.upload_file(photo)
try:
await event.client(functions.photos.UploadProfilePhotoRequest(file))
except Exception as e: # pylint:disable=C0103,W0703
await edit_or_reply(event, str(e))
else:
await edit_or_reply(event, "**Changed profile to OffLine.**")
os.remove(photo)
first_name = user.first_name
addgvar("my_first_name", first_name)
addgvar("my_last_name", "")
if last_name := user.last_name:
addgvar("my_last_name", last_name)
tag_name = OFFLINE_TAG
await event.client(
functions.account.UpdateProfileRequest(
last_name=first_name, first_name=tag_name
)
)
await edit_delete(event, f"**`{tag_name} {first_name}`\nI am Offline now.**")
@catub.cat_cmd(
pattern="online$",
command=("online", plugin_category),
info={
"header": "To your status as online",
"description": " it change your pic back normal, and remove offline tag in name.",
"usage": "{tr}online",
},
)
async def cat(event):
"make yourself online"
user = await event.client.get_entity("me")
if user.first_name.startswith(OFFLINE_TAG):
await edit_or_reply(event, "**Changing Profile to Online...**")
else:
await edit_delete(event, "**Already Online.**")
return
try:
await event.client(
functions.photos.DeletePhotosRequest(
await event.client.get_profile_photos("me", limit=1)
)
)
except Exception as e: # pylint:disable=C0103,W0703
await edit_or_reply(event, str(e))
else:
await edit_or_reply(event, "**Changed profile to Online.**")
first_name = gvarstatus("my_first_name")
last_name = gvarstatus("my_last_name") or ""
await event.client(
functions.account.UpdateProfileRequest(
last_name=last_name, first_name=first_name
)
)
await edit_delete(event, f"**`{first_name} {last_name}`\nI am Online !**")