-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserbotjoin.py
138 lines (123 loc) Β· 5.15 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
# AlvinMusicRobot (Telegram bot project )
# Copyright (C) 2021 Inukaasith
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from pyrogram import Client
from pyrogram import filters
from pyrogram.errors import UserAlreadyParticipant
import asyncio
from AlvinMusicRobot.helpers.decorators import authorized_users_only
from AlvinMusicRobot.helpers.decorators import errors
from AlvinMusicRobot.services.callsmusic import client as USER
from AlvinMusicRobot.config import SUDO_USERS
from AlvinMusicRobot.config import ASSISTANT_NAME
@Client.on_message(filters.command(["userbotjoin"]) & ~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>Add me as admin of yor group first</b>",
)
return
try:
user = await USER.get_me()
except:
user.first_name = "AlvinMusicRobot"
try:
await USER.join_chat(invitelink)
await USER.send_message(message.chat.id, "Saya bergabung di sini seperti yang Anda minta")
except UserAlreadyParticipant:
await message.reply_text(
"<b>helper sudah bergabung di obrolan</b>",
)
except Exception as e:
print(e)
await message.reply_text(
f"<b>π Flood Wait Error π \n pengguna {user.first_name} tidak dapat bergabung dengan grup Anda karena permintaan yang banyak untuk bot pengguna! Pastikan pengguna tidak dilarang dalam grup."
f"\n\nAtau tambahkan @{ASSISTANT_NAME} secara manual ke Grup Anda dan coba lagi</b>",
)
return
await message.reply_text(
"<b>helper userbot bergabung obrolan</b>",
)
@USER.on_message(filters.group & filters.command(["userbotleave"]))
@authorized_users_only
async def rem(USER, message):
try:
await USER.leave_chat(message.chat.id)
except:
await message.reply_text(
f"<b>Pengguna tidak dapat meninggalkan grup Anda! Mungkin floodwaits."
"\n\nAtau secara manual kick saya dari ke Grup Anda</b>",
)
return
@Client.on_message(filters.command(["userbotleaveall"]))
async def bye(client, message):
if message.from_user.id in SUDO_USERS:
left=0
failed=0
lol = await message.reply("Assistant meninggalkan semua obrolan")
async for dialog in USER.iter_dialogs():
try:
await USER.leave_chat(dialog.chat.id)
left = left+1
await lol.edit(f"Assistant meninggalkan... keluar: {left} obrolan. gagal: {failed} obrolan.")
except:
failed=failed+1
await lol.edit(f"Assistant meninggalkan... keluar: {left} obrolan. gagal: {failed} obrolan.")
await asyncio.sleep(0.7)
await client.send_message(message.chat.id, f"keluar {left} obrolan. gagal {failed} obrolan.")
@Client.on_message(filters.command(["userbotjoinchannel","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("apakah obrolan tertautkan")
return
chat_id = chid
try:
invitelink = await client.export_chat_invite_link(chid)
except:
await message.reply_text(
"<b>tambahkan saya sebagai admin terlebih dahulu</b>",
)
return
try:
user = await USER.get_me()
except:
user.first_name = "AlvinMusicRobot"
try:
await USER.join_chat(invitelink)
await USER.send_message(message.chat.id, "Saya bergabung di sini seperti yang Anda minta")
except UserAlreadyParticipant:
await message.reply_text(
"<b>helper sudah bergabung obrolan</b>",
)
return
except Exception as e:
print(e)
await message.reply_text(
f"<b>π Flood Wait Error π \n pengguna {user.first_name} tidak dapat bergabung dengan grup Anda karena permintaan yang banyak untuk bot pengguna! Pastikan pengguna tidak dibanned dalam channel."
f"\n\nAtau tambahkan @{ASSISTANT_NAME} secara manual ke Grup Anda dan coba lagi</b>",
)
return
await message.reply_text(
"<b>helper userbot bergabung ke obrolan</b>",
)