-
Notifications
You must be signed in to change notification settings - Fork 1
/
send.py
51 lines (41 loc) · 1.4 KB
/
send.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
# Copyright (C) 2020-2022 TeamDerUntergang <https://github.com/TeamDerUntergang>
#
# This file is part of TeamDerUntergang project,
# and licensed under GNU Affero General Public License v3.
# See the GNU Affero General Public License for more details.
#
# All rights reserved. See COPYING, AUTHORS.
#
from pyrogram.types import Chat
from .misc import MARKDOWN_FIX_CHAR
def send(client, chat, text, fix_markdown=False, reply_id=None):
if fix_markdown:
text += MARKDOWN_FIX_CHAR
if len(text) < 4096:
if not reply_id:
client.send_message(chat.id if isinstance(chat, Chat) else chat, text)
else:
client.send_message(
chat.id if isinstance(chat, Chat) else chat,
text,
reply_to_message_id=reply_id,
)
return
file = open('temp.txt', 'w+')
file.write(text)
file.close()
send_doc(client, chat, 'temp.txt')
def send_sticker(client, chat, sticker):
try:
client.send_sticker(chat.id if isinstance(chat, Chat) else chat, sticker)
except BaseException:
pass
def send_doc(client, chat, doc, caption='', fix_markdown=False):
try:
if len(caption) > 0 and fix_markdown:
caption += MARKDOWN_FIX_CHAR
client.send_document(
chat.id if isinstance(chat, Chat) else chat, doc, caption=caption
)
except BaseException:
pass