forked from Spyderzz/Userbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
988 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#this module original created by @spechide | ||
|
||
|
||
from telethon.tl import functions, types | ||
from userbot.events import register | ||
from userbot import CMD_HELP | ||
|
||
|
||
@register(outgoing=True, pattern="^.create (b|g|c)(?: |$)(.*)") | ||
async def telegraphs(grop): | ||
""" For .create command, Creating New Group & Channel """ | ||
if not grop.text[0].isalpha() and grop.text[0] not in ("/", "#", "@", "!"): | ||
if grop.fwd_from: | ||
return | ||
type_of_group = grop.pattern_match.group(1) | ||
group_name = grop.pattern_match.group(2) | ||
if type_of_group == "b": | ||
try: | ||
result = await grop.client(functions.messages.CreateChatRequest( # pylint:disable=E0602 | ||
users=["@TheShinChan_Bot"], | ||
# Not enough users (to create a chat, for example) | ||
# Telegram, no longer allows creating a chat with ourselves | ||
title=group_name | ||
)) | ||
created_chat_id = result.chats[0].id | ||
await grop.client(functions.messages.DeleteChatUserRequest( | ||
chat_id=created_chat_id, | ||
user_id="@TheShinChan_Bot" | ||
)) | ||
result = await grop.client(functions.messages.ExportChatInviteRequest( | ||
peer=created_chat_id, | ||
)) | ||
await grop.edit("Your `{}` Group bnadia Sar. Join [{}]({})".format(group_name, group_name, result.link)) | ||
except Exception as e: # pylint:disable=C0103,W0703 | ||
await grop.edit(str(e)) | ||
elif type_of_group == "g" or type_of_group == "c": | ||
try: | ||
r = await grop.client(functions.channels.CreateChannelRequest( # pylint:disable=E0602 | ||
title=group_name, | ||
about="Welcome to this Channel", | ||
megagroup=False if type_of_group == "c" else True | ||
)) | ||
created_chat_id = r.chats[0].id | ||
result = await grop.client(functions.messages.ExportChatInviteRequest( | ||
peer=created_chat_id, | ||
)) | ||
await grop.edit("Aapka `{}` Group/Channel banadiya sar. Join [{}]({})".format(group_name, group_name, result.link)) | ||
except Exception as e: # pylint:disable=C0103,W0703 | ||
await grop.edit(str(e)) | ||
|
||
CMD_HELP.update({ | ||
"create": "\ | ||
Create\ | ||
\nUsage: Create Channel, Group & Group With Bot.\ | ||
\n\n.create g\ | ||
\nUsage: Create a Private Group.\ | ||
\n\n.create b\ | ||
\nUsage: Create a Group with Bot.\ | ||
\n\n.create c\ | ||
\nUsage: Create a Channel.\ | ||
"}) |
Oops, something went wrong.