xteamki commited on
Commit
e8309b3
·
verified ·
1 Parent(s): 427e908

Update plugins/ping.py

Browse files
Files changed (1) hide show
  1. plugins/ping.py +57 -35
plugins/ping.py CHANGED
@@ -5,49 +5,78 @@
5
  # PLease read the GNU Affero General Public License in
6
  # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
 
8
- from . import get_help
9
-
10
- __doc__ = get_help("help_bot")
11
-
12
  import asyncio
13
  import os
14
  import sys
15
  import time
16
- import random
17
- from telethon.errors import FloodWaitError
18
- from telethon import Button
19
- from telethon.errors import RPCError
20
  from telethon import events, TelegramClient
21
  from telethon.tl.functions import PingRequest
22
  from secrets import choice
23
- from telethon.tl.types import (
24
- InputMessagesFilterVideo,
25
- InputMessagesFilterVoice,
26
- InputMessagesFilterPhotos,
27
- )
28
  from xteam._misc import sudoers
 
 
29
  from xteam.fns.custom_markdown import CustomMarkdown
30
  from xteam.fns.helper import download_file, inline_mention
31
  from ._inline import *
32
  from xteam.fns.helper import inline_mention
 
33
  from . import (
34
- OWNER_NAME,
35
- OWNER_ID,
36
- BOT_NAME,
37
- OWNER_USERNAME,
38
- asst,
39
- start_time,
40
- time_formatter,
41
- udB,
42
- ultroid_cmd as xteam_cmd,
43
- get_string,
44
- ultroid_bot,
45
- eor,
46
- ultroid_bot,
47
- call_back,
48
- callback,
49
  )
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  PING = [
52
  [ # First row of buttons (you can have multiple rows)
53
  Button.inline("CLOSE", data="close"),
@@ -67,13 +96,6 @@ async def mention_user(user_id):
67
  print(f"Failed to mention user: {e}")
68
 
69
 
70
- @xteam_cmd(pattern="Cping$", chats=[], type=["official", "assistant"])
71
- async def _(event):
72
- start = time.time()
73
- x = await event.edit("ping")
74
- end = round((time.time() - start) * 1000) # Corrected to milliseconds
75
- uptime = time_formatter((time.time() - start_time) * 1000) # Corrected to milliseconds
76
- await x.edit(f"Pong !! {end}ms\nUptime - {uptime}")
77
 
78
  @xteam_cmd(pattern="ping$", chats=[], type=["official", "assistant"])
79
  async def _(event):
 
5
  # PLease read the GNU Affero General Public License in
6
  # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
 
 
 
 
 
8
  import asyncio
9
  import os
10
  import sys
11
  import time
12
+ import pyrogram
 
 
 
13
  from telethon import events, TelegramClient
14
  from telethon.tl.functions import PingRequest
15
  from secrets import choice
16
+ from telethon import Button
17
+ from telethon.extensions.html import MessageEntityCustomEmoji # Import MessageEntityCustomEmoji from telethon
 
 
 
18
  from xteam._misc import sudoers
19
+ from telethon.tl.types import InputMessagesFilterVideo, InputMessagesFilterVoice
20
+ from telethon.tl.types import InputMessagesFilterPhotos
21
  from xteam.fns.custom_markdown import CustomMarkdown
22
  from xteam.fns.helper import download_file, inline_mention
23
  from ._inline import *
24
  from xteam.fns.helper import inline_mention
25
+ # from pyrogram.types import MessageEntityCustomEmoji # If you're mixing pyrogram and telethon, be careful with duplicate imports
26
  from . import (
27
+ OWNER_NAME,
28
+ OWNER_ID,
29
+ BOT_NAME,
30
+ OWNER_USERNAME,
31
+ asst,
32
+ start_time,
33
+ time_formatter,
34
+ udB,
35
+ ultroid_cmd as xteam_cmd,
36
+ get_string,
37
+ ultroid_bot as client,
38
+ eor,
39
+ ultroid_bot,
40
+ call_back,
41
+ callback,
42
  )
43
 
44
+ @xteam_cmd(pattern="Cping$", chats=[], type=["official", "assistant"])
45
+ async def _(event):
46
+ start = time.time()
47
+ x = await event.reply("Ping")
48
+ end = round((time.time() - start) * 1000)
49
+ uptime = time_formatter((time.time() - start_time) * 1000)
50
+
51
+ # You'll need a custom emoji ID and a document ID for this to work.
52
+ # These typically come from Telegram when you use a custom emoji in a message.
53
+ # Replace these with your actual custom emoji ID and document ID.
54
+ custom_emoji_id_val = 5368324147775073010
55
+ document_id_val = 5368324147775073010
56
+
57
+ # The text we want to send. The '⚡️' character will be linked to the custom emoji.
58
+ message_text = f"⚡️ Pong !! {end}ms\nUptime - {uptime}"
59
+
60
+ # Create the MessageEntityCustomEmoji object
61
+ # offset: The starting position (0-indexed) of the text to which the entity applies.
62
+ # length: The number of characters from the offset that the entity applies to.
63
+ # custom_emoji_id: The ID of the custom emoji.
64
+ # document_id: The document ID associated with the custom emoji.
65
+ entities = [
66
+ MessageEntityCustomEmoji(
67
+ offset=0,
68
+ length=1, # Applies to the first character ('⚡️')
69
+ custom_emoji_id=custom_emoji_id_val,
70
+ document_id=document_id_val,
71
+ )
72
+ ]
73
+
74
+ await x.edit(
75
+ f"<blockquote>{message_text}</blockquote>",
76
+ parse_mode="html", # Keep HTML parse_mode for the <blockquote> tag
77
+ entities=entities # Pass the list of entities directly
78
+ )
79
+
80
  PING = [
81
  [ # First row of buttons (you can have multiple rows)
82
  Button.inline("CLOSE", data="close"),
 
96
  print(f"Failed to mention user: {e}")
97
 
98
 
 
 
 
 
 
 
 
99
 
100
  @xteam_cmd(pattern="ping$", chats=[], type=["official", "assistant"])
101
  async def _(event):