forked from dwiantoni/veezmusic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuserbotjoin.py
142 lines (126 loc) · 4.31 KB
/
userbotjoin.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
import asyncio
from pyrogram import Client, filters
from pyrogram.errors import UserAlreadyParticipant
from callsmusic.callsmusic import client as USER
from config import BOT_USERNAME, SUDO_USERS
from helpers.decorators import authorized_users_only, errors
from helpers.filters import command
@Client.on_message(
command(["join", f"join@{BOT_USERNAME}"])
& ~filters.private
& ~filters.bot
)
@authorized_users_only
@errors
async def addchannel(client, message):
chid = message.chat.id
try:
invitelink = await client.export_chat_invite_link(chid)
except:
await message.reply_text(
"<b>• **i'm not have permission:**\n\n» ❌ __Add Users__</b>",
)
return
try:
user = await USER.get_me()
except:
user.first_name = "music assistant"
try:
await USER.join_chat(invitelink)
await USER.send_message(
message.chat.id, "🤖: i'm joined here for playing music on voice chat"
)
except UserAlreadyParticipant:
await message.reply_text(
f"<b>✅ userbot already joined chat</b>",
)
except Exception as e:
print(e)
await message.reply_text(
f"<b>🛑 Flood Wait Error 🛑 \n\n User {user.first_name} couldn't join your group due to heavy join requests for userbot."
"\n\nor manually add assistant to your Group and try again</b>",
)
return
await message.reply_text(
f"<b>✅ userbot successfully joined chat</b>",
)
@Client.on_message(
command(["leave", f"leave@{BOT_USERNAME}"])
& filters.group
& ~filters.edited
)
@authorized_users_only
async def rem(client, message):
try:
await USER.send_message(message.chat.id, "✅ userbot successfully left chat")
await USER.leave_chat(message.chat.id)
except:
await message.reply_text(
"<b>user couldn't leave your group, may be floodwaits.\n\nor manually kick me from your group</b>"
)
return
@Client.on_message(command(["leaveall", f"leaveall@{BOT_USERNAME}"]))
async def bye(client, message):
if message.from_user.id not in SUDO_USERS:
return
left = 0
failed = 0
lol = await message.reply("🔄 **userbot** leaving all chats !")
async for dialog in USER.iter_dialogs():
try:
await USER.leave_chat(dialog.chat.id)
left += 1
await lol.edit(
f"Userbot leaving all group...\n\nLeft: {left} chats.\nFailed: {failed} chats."
)
except:
failed += 1
await lol.edit(
f"Userbot leaving...\n\nLeft: {left} chats.\nFailed: {failed} chats."
)
await asyncio.sleep(0.7)
await client.send_message(
message.chat.id, f"Left {left} chats.\nFailed {failed} chats."
)
@Client.on_message(
command(["joinchannel", "ubjoinc"]) & ~filters.private & ~filters.bot
)
@authorized_users_only
@errors
async def addcchannel(client, message):
try:
conchat = await client.get_chat(message.chat.id)
conid = conchat.linked_chat.id
chid = conid
except:
await message.reply("❌ `NOT_LINKED`\n\n• **The userbot could not play music, due to group not linked to channel yet.**")
return
try:
invitelink = await client.export_chat_invite_link(chid)
except:
await message.reply_text(
"<b>• **i'm not have permission:**\n\n» ❌ __Add Users__</b>",
)
return
try:
user = await USER.get_me()
except:
user.first_name = "helper"
try:
await USER.join_chat(invitelink)
await USER.send_message(message.chat.id, "🤖: i'm joined here for playing music on vc")
except UserAlreadyParticipant:
await message.reply_text(
"<b>✅ userbot already joined channel</b>",
)
return
except Exception as e:
print(e)
await message.reply_text(
f"<b>🛑 Flood Wait Error 🛑\n\n**userbot couldn't join to channel** due to heavy join requests for userbot, make sure userbot is not banned in channel."
f"\n\nor manually add @{ASSISTANT_NAME} to your channel and try again</b>",
)
return
await message.reply_text(
"<b>✅ userbot successfully joined channel</b>",
)