Devesh Pal Amit Sharma xditya Dark buddhhu Kaif 1Danish-00 TechiError Dark commited on
Commit
d9d0ab6
·
1 Parent(s): e0aff0e

Update Ultroid v0.8

Browse files

---------

Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: Aditya <[email protected]>
Co-authored-by: Dark <[email protected]>
Co-authored-by: buddhhu <[email protected]>
Co-authored-by: Kaif <[email protected]>
Co-authored-by: 1Danish-00 <[email protected]>
Co-authored-by: TechiError <[email protected]>
Co-authored-by: Dark <[email protected]>

This view is limited to 50 files because it contains too many changes.   See raw diff
.github/workflows/autotranslate.yml DELETED
@@ -1,33 +0,0 @@
1
- name: Strings Translation
2
-
3
- on:
4
- workflow_dispatch:
5
- push:
6
- branches: [ dev ]
7
- paths:
8
- - strings/strings/en.yml
9
-
10
- env:
11
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12
-
13
- jobs:
14
- analyze:
15
- name: Checkout Strings
16
- runs-on: ubuntu-latest
17
- steps:
18
- - uses: actions/checkout@v2
19
- - name: Setup Python
20
- uses: actions/setup-python@v2
21
- with:
22
- python-version: 3.9.x
23
- - name: Update Translations
24
- run: |
25
- git config --global user.email "[email protected]"
26
- git config --global user.name "New-Dev0"
27
- git branch translation && git checkout translation
28
- pip install pyyaml requests telethon
29
- wget -O run.py https://gist.githubusercontent.com/New-dev0/c7d0d1eb514d311e8e3b687ae5cbe5f3/raw/350cc6d451a02a4b07d0f9bbc27b0e7c9465d3d4/updater.py
30
- python3 run.py
31
- rm run.py
32
- git add . && git commit -m "[Auto] Translate" && git push --set-upstream origin translation
33
- gh pr create --title "[Auto] Translation" -B dev --body "Update Translation"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/pylint.yaml CHANGED
@@ -13,6 +13,7 @@ jobs:
13
  uses: actions/setup-python@v1
14
  with:
15
  python-version: 3.8
 
16
  - name: Install Python lint libraries
17
  run: pip install autopep8 autoflake isort black
18
  - name: Check for showstoppers
 
13
  uses: actions/setup-python@v1
14
  with:
15
  python-version: 3.8
16
+ cache: "pip"
17
  - name: Install Python lint libraries
18
  run: pip install autopep8 autoflake isort black
19
  - name: Check for showstoppers
.gitignore CHANGED
@@ -8,12 +8,14 @@ test*
8
  *.webp
9
  *.mp4
10
  *.tgs
 
11
  /*.jpg
12
  /*.png
13
  /*.mp4
14
  *.log
15
  target/npmlist.json
16
  package-lock.json
 
17
  resources/extras/thumbnail.jpg
18
 
19
  # Directories
 
8
  *.webp
9
  *.mp4
10
  *.tgs
11
+ *.txt
12
  /*.jpg
13
  /*.png
14
  /*.mp4
15
  *.log
16
  target/npmlist.json
17
  package-lock.json
18
+ ultroid.json
19
  resources/extras/thumbnail.jpg
20
 
21
  # Directories
README.md CHANGED
@@ -7,7 +7,7 @@
7
 
8
  <b>A stable pluggable Telegram userbot + Voice & Video Call music bot, based on Telethon.</b>
9
 
10
- [![](https://img.shields.io/badge/Ultroid-v0.7-darkgreen)](#)
11
  [![Stars](https://img.shields.io/github/stars/TeamUltroid/Ultroid?style=flat-square&color=yellow)](https://github.com/TeamUltroid/Ultroid/stargazers)
12
  [![Forks](https://img.shields.io/github/forks/TeamUltroid/Ultroid?style=flat-square&color=orange)](https://github.com/TeamUltroid/Ultroid/fork)
13
  [![Size](https://img.shields.io/github/repo-size/TeamUltroid/Ultroid?style=flat-square&color=green)](https://github.com/TeamUltroid/Ultroid/)
@@ -84,20 +84,6 @@ Get the [Necessary Variables](#Necessary-Variables) and then click the button be
84
  `bash startup`
85
  - Windows Users:
86
  `python(3) -m pyUltroid`
87
- <details>
88
- <summary><h3>[OUTDATED] Ultroid CLI</h3></summary>
89
-
90
- [Ultroid CLI](https://github.com/BLUE-DEVIL1134/UltroidCli) is a command-line interface for deploying Ultroid.
91
-
92
- - **Installing** -
93
- Run the following code on a terminal, with curl installed.
94
- `ver=$(curl https://raw.githubusercontent.com/BLUE-DEVIL1134/UltroidCli/main/version.txt) && curl -L -o ultroid https://github.com/BLUE-DEVIL1134/UltroidCli/releases/download/$ver/ultroid.exe`
95
- OR
96
- Go to [UltroidCli](https://github.com/BLUE-DEVIL1134/UltroidCli) and install the version release from the Github Releases. Add the executable to your system path as specified in the [Readme](https://github.com/BLUE-DEVIL1134/UltroidCli#how-to-use-ultroidcli-).
97
-
98
- - **Documentation** -
99
- Take a look at the [`docs`](https://blue-devil1134.github.io/UltroidCli/) for more detailed information.
100
- </details>
101
 
102
  ---
103
  ## Necessary Variables
 
7
 
8
  <b>A stable pluggable Telegram userbot + Voice & Video Call music bot, based on Telethon.</b>
9
 
10
+ [![](https://img.shields.io/badge/Ultroid-v0.8-crimson)](#)
11
  [![Stars](https://img.shields.io/github/stars/TeamUltroid/Ultroid?style=flat-square&color=yellow)](https://github.com/TeamUltroid/Ultroid/stargazers)
12
  [![Forks](https://img.shields.io/github/forks/TeamUltroid/Ultroid?style=flat-square&color=orange)](https://github.com/TeamUltroid/Ultroid/fork)
13
  [![Size](https://img.shields.io/github/repo-size/TeamUltroid/Ultroid?style=flat-square&color=green)](https://github.com/TeamUltroid/Ultroid/)
 
84
  `bash startup`
85
  - Windows Users:
86
  `python(3) -m pyUltroid`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  ---
89
  ## Necessary Variables
app.json CHANGED
@@ -50,7 +50,7 @@
50
  "formation": {
51
  "ultroid": {
52
  "quantity": 1,
53
- "size": "free"
54
  }
55
  }
56
  }
 
50
  "formation": {
51
  "ultroid": {
52
  "quantity": 1,
53
+ "size": "eco"
54
  }
55
  }
56
  }
assistant/__init__.py CHANGED
@@ -25,7 +25,8 @@ AST_PLUGINS = {}
25
  async def setit(event, name, value):
26
  try:
27
  udB.set_key(name, value)
28
- except BaseException:
 
29
  return await event.edit("`Something Went Wrong`")
30
 
31
 
 
25
  async def setit(event, name, value):
26
  try:
27
  udB.set_key(name, value)
28
+ except BaseException as er:
29
+ LOGS.exception(er)
30
  return await event.edit("`Something Went Wrong`")
31
 
32
 
assistant/callbackstuffs.py CHANGED
@@ -5,7 +5,7 @@
5
  # PLease read the GNU Affero General Public License in
6
  # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
 
8
-
9
  import asyncio
10
  import re
11
  import sys
@@ -426,9 +426,12 @@ async def convo_handler(event: events.CallbackQuery):
426
  back = get_["back"]
427
  async with event.client.conversation(event.sender_id) as conv:
428
  await conv.send_message(get_["text"])
429
- response = conv.wait_event(events.NewMessage(chats=event.sender_id))
430
- response = await response
431
- themssg = response.message.message
 
 
 
432
  if themssg == "/cancel":
433
  return await conv.send_message(
434
  "Cancelled!!",
@@ -1182,7 +1185,7 @@ async def name(event):
1182
  async def chon(event):
1183
  var = "PMBOT"
1184
  await setit(event, var, "True")
1185
- Loader(path="assistant/pmbot.py", key="PM Bot").load_single()
1186
  if AST_PLUGINS.get("pmbot"):
1187
  for i, e in AST_PLUGINS["pmbot"]:
1188
  event.client.remove_event_handler(i)
 
5
  # PLease read the GNU Affero General Public License in
6
  # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
 
8
+ import ast
9
  import asyncio
10
  import re
11
  import sys
 
426
  back = get_["back"]
427
  async with event.client.conversation(event.sender_id) as conv:
428
  await conv.send_message(get_["text"])
429
+ response = await conv.get_response()
430
+ themssg = response.message
431
+ try:
432
+ themssg = ast.literal_eval(themssg)
433
+ except Exception:
434
+ pass
435
  if themssg == "/cancel":
436
  return await conv.send_message(
437
  "Cancelled!!",
 
1185
  async def chon(event):
1186
  var = "PMBOT"
1187
  await setit(event, var, "True")
1188
+ Loader(path="assistant/pmbot.py", key="PM Bot").load()
1189
  if AST_PLUGINS.get("pmbot"):
1190
  for i, e in AST_PLUGINS["pmbot"]:
1191
  event.client.remove_event_handler(i)
assistant/pmbot.py CHANGED
@@ -18,12 +18,13 @@ from telethon.tl.functions.messages import GetFullChatRequest
18
  from telethon.tl.types import Channel, Chat
19
  from telethon.utils import get_display_name
20
 
21
- from pyUltroid.dB.asst_fns import *
22
  from pyUltroid.dB.botchat_db import *
23
  from pyUltroid.fns.helper import inline_mention
24
 
25
  from . import *
26
 
 
27
  FSUB = udB.get_key("PMBOT_FSUB")
28
  CACHE = {}
29
  # --------------------------------------- Incoming -------------------------------------------- #
@@ -32,7 +33,7 @@ CACHE = {}
32
  @asst_cmd(
33
  load=AST_PLUGINS,
34
  incoming=True,
35
- func=lambda e: e.is_private and not is_blacklisted(e.sender_id),
36
  )
37
  async def on_new_mssg(event):
38
  who = event.sender_id
@@ -49,6 +50,7 @@ async def on_new_mssg(event):
49
  if not MSG:
50
  MSG += get_string("pmbot_1")
51
  try:
 
52
  TAHC_ = await event.client.get_entity(chat)
53
  if hasattr(TAHC_, "username") and TAHC_.username:
54
  uri = f"t.me/{TAHC_.username}"
@@ -119,10 +121,10 @@ async def banhammer(event):
119
  if not event.is_reply:
120
  return await event.reply(get_string("pmbot_2"))
121
  target = get_who(event.reply_to_msg_id)
122
- if is_blacklisted(target):
123
  return await event.reply(get_string("pmbot_3"))
124
 
125
- blacklist_user(target)
126
  await event.reply(f"#BAN\nUser : {target}")
127
  await asst.send_message(target, get_string("pmbot_4"))
128
 
@@ -137,10 +139,10 @@ async def unbanhammer(event):
137
  if not event.is_reply:
138
  return await event.reply(get_string("pmbot_5"))
139
  target = get_who(event.reply_to_msg_id)
140
- if not is_blacklisted(target):
141
  return await event.reply(get_string("pmbot_6"))
142
 
143
- rem_blacklist(target)
144
  await event.reply(f"#UNBAN\nUser : {target}")
145
  await asst.send_message(target, get_string("pmbot_7"))
146
 
 
18
  from telethon.tl.types import Channel, Chat
19
  from telethon.utils import get_display_name
20
 
21
+ from pyUltroid.dB.base import KeyManager
22
  from pyUltroid.dB.botchat_db import *
23
  from pyUltroid.fns.helper import inline_mention
24
 
25
  from . import *
26
 
27
+ botb = KeyManager("BOTBLS", cast=list)
28
  FSUB = udB.get_key("PMBOT_FSUB")
29
  CACHE = {}
30
  # --------------------------------------- Incoming -------------------------------------------- #
 
33
  @asst_cmd(
34
  load=AST_PLUGINS,
35
  incoming=True,
36
+ func=lambda e: e.is_private and not botb.contains(e.sender_id),
37
  )
38
  async def on_new_mssg(event):
39
  who = event.sender_id
 
50
  if not MSG:
51
  MSG += get_string("pmbot_1")
52
  try:
53
+ uri = ""
54
  TAHC_ = await event.client.get_entity(chat)
55
  if hasattr(TAHC_, "username") and TAHC_.username:
56
  uri = f"t.me/{TAHC_.username}"
 
121
  if not event.is_reply:
122
  return await event.reply(get_string("pmbot_2"))
123
  target = get_who(event.reply_to_msg_id)
124
+ if botb.contains(target):
125
  return await event.reply(get_string("pmbot_3"))
126
 
127
+ botb.add(target)
128
  await event.reply(f"#BAN\nUser : {target}")
129
  await asst.send_message(target, get_string("pmbot_4"))
130
 
 
139
  if not event.is_reply:
140
  return await event.reply(get_string("pmbot_5"))
141
  target = get_who(event.reply_to_msg_id)
142
+ if not botb.contains(target):
143
  return await event.reply(get_string("pmbot_6"))
144
 
145
+ botb.remove(target)
146
  await event.reply(f"#UNBAN\nUser : {target}")
147
  await asst.send_message(target, get_string("pmbot_7"))
148
 
assistant/start.py CHANGED
@@ -13,7 +13,7 @@ from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
13
  from telethon.utils import get_display_name
14
 
15
  from pyUltroid._misc import SUDO_M, owner_and_sudos
16
- from pyUltroid.dB.asst_fns import *
17
  from pyUltroid.fns.helper import inline_mention
18
  from strings import get_string
19
 
@@ -87,8 +87,9 @@ async def closet(lol):
87
  @asst_cmd(pattern="start( (.*)|$)", forwards=False, func=lambda x: not x.is_group)
88
  async def ultroid(event):
89
  args = event.pattern_match.group(1).strip()
90
- if not is_added(event.sender_id) and event.sender_id not in owner_and_sudos():
91
- add_user(event.sender_id)
 
92
  kak_uiw = udB.get_key("OFF_START_LOG")
93
  if not kak_uiw or kak_uiw != True:
94
  msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})."
@@ -158,7 +159,7 @@ async def ultroid(event):
158
 
159
  @callback("stat", owner=True)
160
  async def botstat(event):
161
- ok = len(get_all_users("BOT_USERS"))
162
  msg = """Ultroid Assistant - Stats
163
  Total Users - {}""".format(
164
  ok,
@@ -168,8 +169,9 @@ Total Users - {}""".format(
168
 
169
  @callback("bcast", owner=True)
170
  async def bdcast(event):
171
- ok = get_all_users("BOT_USERS")
172
- await event.edit(f"• Broadcast to {len(ok)} users.")
 
173
  async with event.client.conversation(OWNER_ID) as conv:
174
  await conv.send_message(
175
  "Enter your broadcast message.\nUse /cancel to stop the broadcast.",
@@ -179,9 +181,9 @@ async def bdcast(event):
179
  return await conv.send_message("Cancelled!!")
180
  success = 0
181
  fail = 0
182
- await conv.send_message(f"Starting a broadcast to {len(ok)} users...")
183
  start = datetime.now()
184
- for i in ok:
185
  try:
186
  await asst.send_message(int(i), response)
187
  success += 1
@@ -192,7 +194,7 @@ async def bdcast(event):
192
  await conv.send_message(
193
  f"""
194
  **Broadcast completed in {time_taken} seconds.**
195
- Total Users in Bot - {len(ok)}
196
  **Sent to** : `{success} users.`
197
  **Failed for** : `{fail} user(s).`""",
198
  )
 
13
  from telethon.utils import get_display_name
14
 
15
  from pyUltroid._misc import SUDO_M, owner_and_sudos
16
+ from pyUltroid.dB.base import KeyManager
17
  from pyUltroid.fns.helper import inline_mention
18
  from strings import get_string
19
 
 
87
  @asst_cmd(pattern="start( (.*)|$)", forwards=False, func=lambda x: not x.is_group)
88
  async def ultroid(event):
89
  args = event.pattern_match.group(1).strip()
90
+ keym = KeyManager("BOT_USERS", cast=list)
91
+ if not keym.contains(event.sender_id) and event.sender_id not in owner_and_sudos():
92
+ keym.add(event.sender_id)
93
  kak_uiw = udB.get_key("OFF_START_LOG")
94
  if not kak_uiw or kak_uiw != True:
95
  msg = f"{inline_mention(event.sender)} `[{event.sender_id}]` started your [Assistant bot](@{asst.me.username})."
 
159
 
160
  @callback("stat", owner=True)
161
  async def botstat(event):
162
+ ok = len(udB.get_key("BOT_USERS") or [])
163
  msg = """Ultroid Assistant - Stats
164
  Total Users - {}""".format(
165
  ok,
 
169
 
170
  @callback("bcast", owner=True)
171
  async def bdcast(event):
172
+ keym = KeyManager("BOT_USERS", cast=list)
173
+ total = keym.count()
174
+ await event.edit(f"• Broadcast to {total} users.")
175
  async with event.client.conversation(OWNER_ID) as conv:
176
  await conv.send_message(
177
  "Enter your broadcast message.\nUse /cancel to stop the broadcast.",
 
181
  return await conv.send_message("Cancelled!!")
182
  success = 0
183
  fail = 0
184
+ await conv.send_message(f"Starting a broadcast to {total} users...")
185
  start = datetime.now()
186
+ for i in keym.get():
187
  try:
188
  await asst.send_message(int(i), response)
189
  success += 1
 
194
  await conv.send_message(
195
  f"""
196
  **Broadcast completed in {time_taken} seconds.**
197
+ Total Users in Bot - {total}
198
  **Sent to** : `{success} users.`
199
  **Failed for** : `{fail} user(s).`""",
200
  )
installer.sh CHANGED
@@ -1,99 +1,241 @@
1
  #!/usr/bin/env bash
2
 
3
  REPO="https://github.com/TeamUltroid/Ultroid.git"
 
 
4
  DIR="/root/TeamUltroid"
5
 
6
- spinner(){
7
- local pid=$!
8
- while [ "$(ps a | awk '{print $1}' | grep $pid)" ];
9
- do
10
- for i in "Ooooo" "oOooo" "ooOoo" "oooOo" "ooooO" "oooOo" "ooOoo" "oOooo" "Ooooo"
11
- do
12
- echo -ne "\r• $i"
13
- sleep 0.2
14
- done
15
- done
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
 
18
- clone_repo(){
19
- if [ ! $BRANCH ]
20
- then export BRANCH="main"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  fi
22
- if [ -d $DIR ]
23
- then
24
- echo -e $DIR "Already exists.."
 
 
 
 
 
25
  cd $DIR
26
  git pull
27
  currentbranch="$(git rev-parse --abbrev-ref HEAD)"
28
- if [ currentbranch != $BRANCH ]
29
- then
30
- git checkout $BRANCH
31
  fi
32
- if [ -d "addons" ]
33
- then
34
- cd addons
35
- git pull
36
- fi
37
- return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  fi
39
- echo -e "Cloning Ultroid ${BRANCH}... "
40
- git clone -b $BRANCH $REPO $DIR
41
  }
42
 
43
- install_requirements(){
44
- pip install --upgrade pip
45
  echo -e "\n\nInstalling requirements... "
46
  pip3 install -q --no-cache-dir -r $DIR/requirements.txt
47
  pip3 install -q -r $DIR/resources/startup/optional-requirements.txt
48
  }
49
 
50
- railways_dep(){
51
- if [ $RAILWAY_STATIC_URL ]
52
- then
53
- echo -e "Installing YouTube dependency... "
54
- pip3 install -q yt-dlp
55
  fi
56
  }
57
 
58
- misc_install(){
59
- if [ $OKTETO_TOKEN ]
60
- then
61
- echo -e "Installing Okteto-CLI... "
62
- curl https://get.okteto.com -sSfL | sh
63
- elif [ $VCBOT ]
64
- then
65
- if [ -d $DIR/vcbot ]
66
- then
67
- cd $DIR/vcbot
68
- git pull
69
- else
70
- echo -e "Cloning VCBOT.."
71
- git clone https://github.com/TeamUltroid/VcBot $DIR/vcbot
72
- fi
73
- pip3 install pytgcalls>=3.0.0.dev21 && pip3 install av -q --no-binary av
 
 
 
74
  fi
75
  }
76
 
77
- dep_install(){
78
  echo -e "\n\nInstalling DB Requirement..."
79
- if [ $MONGO_URI ]
80
- then
81
- pip3 install -q pymongo[srv]
82
- elif [ $DATABASE_URL ]
83
- then
84
- pip3 install -q psycopg2-binary
85
- elif [ $REDIS_URI ]
86
- then
87
- pip3 install -q redis hiredis
88
  fi
89
  }
90
 
91
- main(){
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  (clone_repo)
93
  (install_requirements)
94
  (railways_dep)
95
  (dep_install)
96
  (misc_install)
 
97
  }
98
 
99
- main
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #!/usr/bin/env bash
2
 
3
  REPO="https://github.com/TeamUltroid/Ultroid.git"
4
+ CURRENT_DIR="$(pwd)"
5
+ ENV_FILE_PATH=".env"
6
  DIR="/root/TeamUltroid"
7
 
8
+ while [ $# -gt 0 ]; do
9
+ case "$1" in
10
+ --dir=*)
11
+ DIR="${1#*=}" || DIR="/root/TeamUltroid"
12
+ ;;
13
+ --branch=*)
14
+ BRANCH="${1#*=}" || BRANCH="main"
15
+ ;;
16
+ --env-file=*)
17
+ ENV_FILE_PATH="${1#*=}" || ENV_FILE_PATH=".env"
18
+ ;;
19
+ --no-root)
20
+ NO_ROOT=true
21
+ ;;
22
+ *)
23
+ echo "Unknown parameter passed: $1"
24
+ exit 1
25
+ ;;
26
+ esac
27
+ shift
28
+ done
29
+
30
+ check_dependencies() {
31
+ # check if debian
32
+ echo "Checking dependencies..."
33
+ # read file with root access
34
+ if ! [[ $(ls -l "/etc/sudoers" | cut -d " " -f1) =~ "r" ]]; then
35
+ # check dependencies if installed
36
+ echo -e "Root access not found. Checking if dependencies are installed." >&2
37
+ if ! [ -x "$(command -v python3)" ] || ! [ -x "$(command -v python)" ]; then
38
+ echo -e "Python3 isn't installed. Please install python3.8 or higher to run this bot." >&2
39
+ exit 1
40
+ fi
41
+ if [ $(python3 -c "import sys; print(sys.version_info[1])") -lt 8 ] || [ $(python -c "import sys; print(sys.version_info[1])") -lt 8 ]; then
42
+ echo -e "Python 3.8 or higher is required to run this bot." >&2
43
+ exit 1
44
+ fi
45
+ # check if any of ffmpeg, mediainfo, neofetch, git is not installed
46
+ if ! command -v ffmpeg &>/dev/null || ! command -v mediainfo &>/dev/null || ! command -v neofetch &>/dev/null || ! command -v git &>/dev/null; then
47
+ echo -e "Some dependencies aren't installed. Please install ffmpeg, mediainfo, neofetch and git to run this bot." >&2
48
+ exit 1
49
+ fi
50
+ fi
51
+ if [ -x "$(command -v apt-get)" ]; then
52
+ echo -e "Installing dependencies..."
53
+ # check if any of ffmpeg, mediainfo, neofetch, git is not installed via dpkg
54
+ if dpkg -l | grep -q ffmpeg || dpkg -l | grep -q mediainfo || dpkg -l | grep -q neofetch || dpkg -l | grep -q git; then
55
+ sudo apt-get -qq -o=Dpkg::Use-Pty=0 update
56
+ sudo apt-get install -qq -o=Dpkg::Use-Pty=0 python3 python3-pip ffmpeg mediainfo neofetch git -y
57
+ fi
58
+ elif [ -x "$(command -v pacman)" ]; then
59
+ echo -e "Installing dependencies..."
60
+ if pacman -Q | grep -q ffmpeg || pacman -Q | grep -q mediainfo || pacman -Q | grep -q neofetch || pacman -Q | grep -q git; then
61
+ sudo pacman -Sy python python-pip git ffmpeg mediainfo neofetch --noconfirm
62
+ fi
63
+ else
64
+ echo -e "Unknown OS. Checking if dependecies are installed" >&2
65
+ if ! [ -x "$(command -v python3)" ] || ! [ -x "$(command -v python)" ]; then
66
+ echo -e "Python3 isn't installed. Please install python3.8 or higher to run this bot." >&2
67
+ exit 1
68
+ fi
69
+ if [ $(python3 -c "import sys; print(sys.version_info[1])") -lt 8 ] || [ $(python -c "import sys; print(sys.version_info[1])") -lt 8 ]; then
70
+ echo -e "Python 3.8 or higher is required to run this bot." >&2
71
+ exit 1
72
+ fi
73
+ if ! command -v ffmpeg &>/dev/null || ! command -v mediainfo &>/dev/null || ! command -v neofetch &>/dev/null || ! command -v git &>/dev/null; then
74
+ echo -e "Some dependencies aren't installed. Please install ffmpeg, mediainfo, neofetch and git to run this bot." >&2
75
+ exit 1
76
+ fi
77
+ fi
78
  }
79
 
80
+ check_python() {
81
+ # check if python is installed
82
+ if ! command -v python3 &>/dev/null; then
83
+ echo -e "Python3 isn't installed. Please install python3.8 or higher to run this bot."
84
+ exit 1
85
+ elif ! command -v python &>/dev/null; then
86
+ echo -e "Python3 isn't installed. Please install python3.8 or higher to run this bot."
87
+ exit 1
88
+ fi
89
+ if [ $(python3 -c "import sys; print(sys.version_info[1])") -lt 8 ]; then
90
+ echo -e "Python 3.8 or higher is required to run this bot."
91
+ exit 1
92
+ elif [ $(python -c "import sys; print(sys.version_info[1])") -lt 3 ]; then
93
+ if [ $(python -c "import sys; print(sys.version_info[1])") -lt 8 ]; then
94
+ echo -e "Python 3.8 or higher is required to run this bot."
95
+ exit 1
96
+ fi
97
  fi
98
+ }
99
+
100
+ clone_repo() {
101
+ # check if pyultroid, startup, plugins folders exist
102
+ cd $DIR
103
+ if [ -d $DIR ]; then
104
+ if [ -d $DIR/.git ]; then
105
+ echo -e "Updating Ultroid ${BRANCH}... "
106
  cd $DIR
107
  git pull
108
  currentbranch="$(git rev-parse --abbrev-ref HEAD)"
109
+ if [ ! $BRANCH ]; then
110
+ export BRANCH=$currentbranch
 
111
  fi
112
+ case $currentbranch in
113
+ $BRANCH)
114
+ # do nothing
115
+ ;;
116
+ *)
117
+ echo -e "Switching to branch ${BRANCH}... "
118
+ echo -e $currentbranch
119
+ git checkout $BRANCH
120
+ ;;
121
+ esac
122
+ else
123
+ rm -rf $DIR
124
+ exit 1
125
+ fi
126
+ if [ -d "addons" ]; then
127
+ cd addons
128
+ git pull
129
+ fi
130
+ return
131
+ else
132
+ if [ ! $BRANCH ]; then
133
+ export BRANCH="main"
134
+ fi
135
+ mkdir -p $DIR
136
+ echo -e "Cloning Ultroid ${BRANCH}... "
137
+ git clone -b $BRANCH $REPO $DIR
138
  fi
 
 
139
  }
140
 
141
+ install_requirements() {
142
+ pip3 install -q --upgrade pip
143
  echo -e "\n\nInstalling requirements... "
144
  pip3 install -q --no-cache-dir -r $DIR/requirements.txt
145
  pip3 install -q -r $DIR/resources/startup/optional-requirements.txt
146
  }
147
 
148
+ railways_dep() {
149
+ if [ $RAILWAY_STATIC_URL ]; then
150
+ echo -e "Installing YouTube dependency... "
151
+ pip3 install -q yt-dlp
 
152
  fi
153
  }
154
 
155
+ misc_install() {
156
+ if [ $SETUP_PLAYWRIGHT ]
157
+ then
158
+ echo -e "Installing playwright."
159
+ pip3 install playwright
160
+ playwright install
161
+ fi
162
+ if [ $OKTETO_TOKEN ]; then
163
+ echo -e "Installing Okteto-CLI... "
164
+ curl https://get.okteto.com -sSfL | sh
165
+ elif [ $VCBOT ]; then
166
+ if [ -d $DIR/vcbot ]; then
167
+ cd $DIR/vcbot
168
+ git pull
169
+ else
170
+ echo -e "Cloning VCBOT.."
171
+ git clone https://github.com/TeamUltroid/VcBot $DIR/vcbot
172
+ fi
173
+ pip3 install pytgcalls==3.0.0.dev23 && pip3 install av -q --no-binary av
174
  fi
175
  }
176
 
177
+ dep_install() {
178
  echo -e "\n\nInstalling DB Requirement..."
179
+ if [ $MONGO_URI ]; then
180
+ echo -e " Installing MongoDB Requirements..."
181
+ pip3 install -q pymongo[srv]
182
+ elif [ $DATABASE_URL ]; then
183
+ echo -e " Installing PostgreSQL Requirements..."
184
+ pip3 install -q psycopg2-binary
185
+ elif [ $REDIS_URI ]; then
186
+ echo -e " Installing Redis Requirements..."
187
+ pip3 install -q redis hiredis
188
  fi
189
  }
190
 
191
+ main() {
192
+ echo -e "Starting Ultroid Setup..."
193
+ if [ -d "pyUltroid" ] && [ -d "resources" ] && [ -d "plugins" ]; then
194
+ DIR=$CURRENT_DIR
195
+ fi
196
+ if [ -f $ENV_FILE_PATH ]
197
+ then
198
+ set -a
199
+ source <(cat $ENV_FILE_PATH | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g")
200
+ set +a
201
+ cp $ENV_FILE_PATH .env
202
+ fi
203
+ (check_dependencies)
204
+ (check_python)
205
  (clone_repo)
206
  (install_requirements)
207
  (railways_dep)
208
  (dep_install)
209
  (misc_install)
210
+ echo -e "\n\nSetup Completed."
211
  }
212
 
213
+ if [ $NO_ROOT ]; then
214
+ echo -e "Running with non root"
215
+ main
216
+ return 0
217
+ elif [ -t 0 ]; then
218
+ unameOut="$(uname -s)"
219
+ case "${unameOut}" in
220
+ Linux*) machine=Linux;;
221
+ Darwin*) machine=Mac;;
222
+ CYGWIN*) machine=Cygwin;;
223
+ MINGW*) machine=MinGw;;
224
+ *) machine="UNKNOWN:${unameOut}"
225
+ esac
226
+ if machine != "Linux"; then
227
+ echo -e "This script is only for Linux. Please use the Windows installer."
228
+ exit 1
229
+ fi
230
+ # check if sudo is installed
231
+ if ! command -v sudo &>/dev/null; then
232
+ echo -e "Sudo isn't installed. Please install sudo to run this bot."
233
+ exit 1
234
+ fi
235
+ sudo echo "Sudo permission granted."
236
+ main
237
+ else
238
+ echo "Not an interactive terminal, skipping sudo."
239
+ # run main function
240
+ main
241
+ fi
plugins/__init__.py CHANGED
@@ -20,18 +20,23 @@ from pyUltroid._misc._decorators import ultroid_cmd
20
  from pyUltroid._misc._wrappers import eod, eor
21
  from pyUltroid.dB import DEVLIST, ULTROID_IMAGES
22
  from pyUltroid.fns.helper import *
23
- from pyUltroid.fns.info import *
24
  from pyUltroid.fns.misc import *
25
  from pyUltroid.fns.tools import *
 
26
  from pyUltroid.version import __version__, ultroid_version
27
  from strings import get_help, get_string
28
 
 
 
29
  Redis = udB.get_key
30
  con = TgConverter
31
  quotly = Quotly()
32
  OWNER_NAME = ultroid_bot.full_name
33
  OWNER_ID = ultroid_bot.uid
34
 
 
 
 
35
  LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
36
 
37
 
 
20
  from pyUltroid._misc._wrappers import eod, eor
21
  from pyUltroid.dB import DEVLIST, ULTROID_IMAGES
22
  from pyUltroid.fns.helper import *
 
23
  from pyUltroid.fns.misc import *
24
  from pyUltroid.fns.tools import *
25
+ from pyUltroid.startup._database import _BaseDatabase as Database
26
  from pyUltroid.version import __version__, ultroid_version
27
  from strings import get_help, get_string
28
 
29
+ udB: Database
30
+
31
  Redis = udB.get_key
32
  con = TgConverter
33
  quotly = Quotly()
34
  OWNER_NAME = ultroid_bot.full_name
35
  OWNER_ID = ultroid_bot.uid
36
 
37
+ ultroid_bot: UltroidClient
38
+ asst: UltroidClient
39
+
40
  LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
41
 
42
 
plugins/_chatactions.py CHANGED
@@ -13,6 +13,7 @@ from telethon.tl.functions.channels import GetParticipantRequest
13
  from telethon.utils import get_display_name
14
 
15
  from pyUltroid.dB import stickers
 
16
  from pyUltroid.dB.forcesub_db import get_forcesetting
17
  from pyUltroid.dB.gban_mute_db import is_gbanned
18
  from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank
@@ -90,8 +91,7 @@ async def DummyHandler(ult):
90
  user.id,
91
  view_messages=False,
92
  )
93
- await ult.client.send_message(
94
- chat.id,
95
  f'**@UltroidBans:** Banned user detected and banned!\n`{str(is_banned)}`.\nBan reason: {is_banned["reason"]}',
96
  )
97
 
@@ -196,8 +196,13 @@ async def DummyHandler(ult):
196
  @ultroid_bot.on(events.NewMessage(incoming=True))
197
  async def chatBot_replies(e):
198
  sender = await e.get_sender()
199
- if not isinstance(sender, types.User):
200
  return
 
 
 
 
 
201
  key = udB.get_key("CHATBOT_USERS") or {}
202
  if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]:
203
  msg = await get_chatbot_reply(e.message.message)
@@ -206,12 +211,10 @@ async def chatBot_replies(e):
206
  await asyncio.sleep(sleep)
207
  await e.reply(msg)
208
  chat = await e.get_chat()
209
- if e.is_group and not sender.bot:
210
- if sender.username:
211
- await uname_stuff(e.sender_id, sender.username, sender.first_name)
212
- elif e.is_private and not sender.bot:
213
- if chat.username:
214
- await uname_stuff(e.sender_id, chat.username, chat.first_name)
215
  if detector and is_profan(e.chat_id) and e.text:
216
  x, y = detector(e.text)
217
  if y:
@@ -220,7 +223,7 @@ async def chatBot_replies(e):
220
 
221
  @ultroid_bot.on(events.Raw(types.UpdateUserName))
222
  async def uname_change(e):
223
- await uname_stuff(e.user_id, e.username, e.first_name)
224
 
225
 
226
  async def uname_stuff(id, uname, name):
 
13
  from telethon.utils import get_display_name
14
 
15
  from pyUltroid.dB import stickers
16
+ from pyUltroid.dB.echo_db import check_echo
17
  from pyUltroid.dB.forcesub_db import get_forcesetting
18
  from pyUltroid.dB.gban_mute_db import is_gbanned
19
  from pyUltroid.dB.greetings_db import get_goodbye, get_welcome, must_thank
 
91
  user.id,
92
  view_messages=False,
93
  )
94
+ await ult.respond(
 
95
  f'**@UltroidBans:** Banned user detected and banned!\n`{str(is_banned)}`.\nBan reason: {is_banned["reason"]}',
96
  )
97
 
 
196
  @ultroid_bot.on(events.NewMessage(incoming=True))
197
  async def chatBot_replies(e):
198
  sender = await e.get_sender()
199
+ if not isinstance(sender, types.User) or sender.bot:
200
  return
201
+ if check_echo(e.chat_id, e.sender_id):
202
+ try:
203
+ await e.respond(e)
204
+ except Exception as er:
205
+ LOGS.exception(er)
206
  key = udB.get_key("CHATBOT_USERS") or {}
207
  if e.text and key.get(e.chat_id) and sender.id in key[e.chat_id]:
208
  msg = await get_chatbot_reply(e.message.message)
 
211
  await asyncio.sleep(sleep)
212
  await e.reply(msg)
213
  chat = await e.get_chat()
214
+ if e.is_group and sender.username:
215
+ await uname_stuff(e.sender_id, sender.username, sender.first_name)
216
+ elif e.is_private and chat.username:
217
+ await uname_stuff(e.sender_id, chat.username, chat.first_name)
 
 
218
  if detector and is_profan(e.chat_id) and e.text:
219
  x, y = detector(e.text)
220
  if y:
 
223
 
224
  @ultroid_bot.on(events.Raw(types.UpdateUserName))
225
  async def uname_change(e):
226
+ await uname_stuff(e.user_id, e.usernames[0] if e.usernames else None, e.first_name)
227
 
228
 
229
  async def uname_stuff(id, uname, name):
plugins/_userlogs.py CHANGED
@@ -51,10 +51,7 @@ async def all_messages_catcher(e):
51
  return
52
  if not udB.get_key("TAG_LOG"):
53
  return
54
- try:
55
- NEEDTOLOG = int(udB.get_key("TAG_LOG"))
56
- except Exception:
57
- return LOGS.info(get_string("userlogs_1"))
58
  buttons = await parse_buttons(e)
59
  try:
60
  sent = await asst.send_message(NEEDTOLOG, e.message, buttons=buttons)
@@ -63,7 +60,8 @@ async def all_messages_catcher(e):
63
  else:
64
  TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
65
  tag_add(sent.id, e.chat_id, e.id)
66
- except MediaEmptyError:
 
67
  try:
68
  msg = await asst.get_messages(e.chat_id, ids=e.id)
69
  sent = await asst.send_message(NEEDTOLOG, msg, buttons=buttons)
@@ -89,7 +87,8 @@ async def all_messages_catcher(e):
89
  except Exception as er:
90
  LOGS.exception(er)
91
  await asst.send_message(NEEDTOLOG, get_string("com_4"), buttons=buttons)
92
- except (PeerIdInvalidError, ValueError):
 
93
  try:
94
  CACHE_SPAM[NEEDTOLOG]
95
  except KeyError:
@@ -225,7 +224,7 @@ async def when_added_or_joined(event):
225
  text = f"#APPROVAL_LOG\n\n{inline_mention(user)} just got Chat Join Approval to {chat}."
226
  else:
227
  text = f"#JOIN_LOG\n\n{inline_mention(user)} just joined {chat}."
228
- await asst.send_message(int(udB.get_key("LOG_CHANNEL")), text, buttons=buttons)
229
 
230
 
231
  asst.add_event_handler(
 
51
  return
52
  if not udB.get_key("TAG_LOG"):
53
  return
54
+ NEEDTOLOG = udB.get_key("TAG_LOG")
 
 
 
55
  buttons = await parse_buttons(e)
56
  try:
57
  sent = await asst.send_message(NEEDTOLOG, e.message, buttons=buttons)
 
60
  else:
61
  TAG_EDITS.update({e.chat_id: {e.id: {"id": sent.id, "msg": e}}})
62
  tag_add(sent.id, e.chat_id, e.id)
63
+ except MediaEmptyError as er:
64
+ LOGS.debug(f"handling {er}.")
65
  try:
66
  msg = await asst.get_messages(e.chat_id, ids=e.id)
67
  sent = await asst.send_message(NEEDTOLOG, msg, buttons=buttons)
 
87
  except Exception as er:
88
  LOGS.exception(er)
89
  await asst.send_message(NEEDTOLOG, get_string("com_4"), buttons=buttons)
90
+ except (PeerIdInvalidError, ValueError) as er:
91
+ LOGS.exception(er)
92
  try:
93
  CACHE_SPAM[NEEDTOLOG]
94
  except KeyError:
 
224
  text = f"#APPROVAL_LOG\n\n{inline_mention(user)} just got Chat Join Approval to {chat}."
225
  else:
226
  text = f"#JOIN_LOG\n\n{inline_mention(user)} just joined {chat}."
227
+ await asst.send_message(udB.get_key("LOG_CHANNEL"), text, buttons=buttons)
228
 
229
 
230
  asst.add_event_handler(
plugins/_wspr.py CHANGED
@@ -66,7 +66,7 @@ async def _(e):
66
  if not isinstance(logi, types.User):
67
  raise ValueError("Invalid Username.")
68
  except IndexError:
69
- sur = e.builder.article(
70
  title="Give Username",
71
  description="You Didn't Type Username or id.",
72
  text="You Didn't Type Username or id.",
@@ -74,7 +74,7 @@ async def _(e):
74
  return await e.answer([sur])
75
  except ValueError as er:
76
  LOGS.exception(er)
77
- sur = e.builder.article(
78
  title="User Not Found",
79
  description="Make sure username or id is correct.",
80
  text="Make sure username or id is correct.",
@@ -83,14 +83,23 @@ async def _(e):
83
  try:
84
  desc = zzz[2]
85
  except IndexError:
86
- sur = e.builder.article(title="Type ur msg", text="You Didn't Type Your Msg")
 
 
87
  return await e.answer([sur])
88
  button = [
89
- Button.inline("Secret Msg", data=f"dd_{e.id}"),
90
- Button.inline("Delete Msg", data=f"del_{e.id}"),
 
 
 
 
 
 
 
91
  ]
92
  us = logi.username or logi.first_name
93
- sur = e.builder.article(
94
  title=logi.first_name,
95
  description=desc,
96
  text=get_string("wspr_1").format(us),
 
66
  if not isinstance(logi, types.User):
67
  raise ValueError("Invalid Username.")
68
  except IndexError:
69
+ sur = await e.builder.article(
70
  title="Give Username",
71
  description="You Didn't Type Username or id.",
72
  text="You Didn't Type Username or id.",
 
74
  return await e.answer([sur])
75
  except ValueError as er:
76
  LOGS.exception(er)
77
+ sur = await e.builder.article(
78
  title="User Not Found",
79
  description="Make sure username or id is correct.",
80
  text="Make sure username or id is correct.",
 
83
  try:
84
  desc = zzz[2]
85
  except IndexError:
86
+ sur = await e.builder.article(
87
+ title="Type ur msg", text="You Didn't Type Your Msg"
88
+ )
89
  return await e.answer([sur])
90
  button = [
91
+ [
92
+ Button.inline("Secret Msg", data=f"dd_{e.id}"),
93
+ Button.inline("Delete Msg", data=f"del_{e.id}"),
94
+ ],
95
+ [
96
+ Button.switch_inline(
97
+ "New", query=f"wspr {logi.username or logi.id}", same_peer=True
98
+ )
99
+ ],
100
  ]
101
  us = logi.username or logi.first_name
102
+ sur = await e.builder.article(
103
  title=logi.first_name,
104
  description=desc,
105
  text=get_string("wspr_1").format(us),
plugins/admintools.py CHANGED
@@ -20,18 +20,9 @@ from telethon.utils import get_display_name
20
 
21
  from pyUltroid.dB import DEVLIST
22
  from pyUltroid.fns.admins import ban_time
 
23
 
24
- from . import (
25
- HNDLR,
26
- LOGS,
27
- eod,
28
- eor,
29
- get_string,
30
- get_uinfo,
31
- inline_mention,
32
- types,
33
- ultroid_cmd,
34
- )
35
 
36
 
37
  @ultroid_cmd(
 
20
 
21
  from pyUltroid.dB import DEVLIST
22
  from pyUltroid.fns.admins import ban_time
23
+ from pyUltroid.fns.info import get_uinfo
24
 
25
+ from . import HNDLR, LOGS, eod, eor, get_string, inline_mention, types, ultroid_cmd
 
 
 
 
 
 
 
 
 
 
26
 
27
 
28
  @ultroid_cmd(
plugins/afk.py CHANGED
@@ -16,7 +16,7 @@ from telegraph import upload_file as uf
16
  from telethon import events
17
 
18
  from pyUltroid.dB.afk_db import add_afk, del_afk, is_afk
19
- from pyUltroid.dB.pmpermit_db import is_approved
20
 
21
  from . import (
22
  LOG_CHANNEL,
@@ -32,6 +32,8 @@ from . import (
32
 
33
  old_afk_msg = []
34
 
 
 
35
 
36
  @ultroid_cmd(pattern="afk( (.*)|$)", owner_only=True)
37
  async def set_afk(event):
 
16
  from telethon import events
17
 
18
  from pyUltroid.dB.afk_db import add_afk, del_afk, is_afk
19
+ from pyUltroid.dB.base import KeyManager
20
 
21
  from . import (
22
  LOG_CHANNEL,
 
32
 
33
  old_afk_msg = []
34
 
35
+ is_approved = KeyManager("PMPERMIT", cast=list).contains
36
+
37
 
38
  @ultroid_cmd(pattern="afk( (.*)|$)", owner_only=True)
39
  async def set_afk(event):
plugins/audiotools.py CHANGED
@@ -151,12 +151,10 @@ async def ex_aud(e):
151
 
152
  except FileNotFoundError:
153
  return await eor(msg, get_string("audiotools_9"))
154
- await e.client.send_file(
155
- e.chat_id,
156
- fo,
157
- caption=get_string("audiotools_10"),
158
  thumb=ULTConfig.thumb,
159
  attributes=attributes,
160
- reply_to=e.reply_to_msg_id,
161
  )
162
  await msg.delete()
 
151
 
152
  except FileNotFoundError:
153
  return await eor(msg, get_string("audiotools_9"))
154
+ await e.reply(
155
+ get_string("audiotools_10"),
156
+ file=fo,
 
157
  thumb=ULTConfig.thumb,
158
  attributes=attributes,
 
159
  )
160
  await msg.delete()
plugins/autoban.py CHANGED
@@ -10,43 +10,26 @@ from . import get_help
10
  __doc__ = get_help("help_autoban")
11
 
12
  from telethon import events
13
- from telethon.tl.types import Channel
14
 
15
- from pyUltroid.dB import autoban_db, dnd_db
16
- from pyUltroid.fns.admins import get_update_linked_chat
17
 
18
- from . import LOGS, asst, get_string, inline_mention, ultroid_bot, ultroid_cmd
19
 
 
20
 
21
- async def dnd_func(event):
22
- if event.chat_id in dnd_db.get_dnd_chats():
23
- for user in event.users:
24
- try:
25
- await (
26
- await event.client.kick_participant(event.chat_id, user)
27
- ).delete()
28
- except Exception as ex:
29
- LOGS.error("Error in DND:")
30
- LOGS.exception(ex)
31
- await event.delete()
32
 
33
 
34
- async def channel_del(event):
35
- if not autoban_db.is_autoban_enabled(event.chat_id):
36
- return
37
- if autoban_db.is_whitelisted(event.chat_id, event.sender_id):
38
- return
39
- linked = await get_update_linked_chat(event)
40
- if linked == event.sender.id:
41
- return
42
- if event.chat.creator or event.chat.admin_rights.ban_users:
43
  try:
44
- await event.client.edit_permissions(
45
- event.chat_id, event.sender_id, view_messages=False
46
- )
47
- except Exception as er:
48
- LOGS.exception(er)
49
- await event.try_delete()
50
 
51
 
52
  @ultroid_cmd(
@@ -59,84 +42,18 @@ async def channel_del(event):
59
  async def _(event):
60
  match = event.pattern_match.group(1)
61
  if match == "on":
62
- if dnd_db.chat_in_dnd(event.chat_id):
63
  return await event.eor("`Chat already in do not disturb mode.`", time=3)
64
- dnd_db.add_dnd(event.chat_id)
65
- event.client.add_handler(
66
- dnd_func, events.ChatAction(func=lambda x: x.user_joined)
67
- )
68
  await event.eor("`Do not disturb mode activated for this chat.`", time=3)
69
  elif match == "off":
70
- if not dnd_db.chat_in_dnd(event.chat_id):
71
  return await event.eor("`Chat is not in do not disturb mode.`", time=3)
72
- dnd_db.del_dnd(event.chat_id)
73
  await event.eor("`Do not disturb mode deactivated for this chat.`", time=3)
74
 
75
 
76
- @ultroid_cmd(pattern="cban$", admins_only=True)
77
- async def ban_cha(ult):
78
- if autoban_db.is_autoban_enabled(ult.chat_id):
79
- autoban_db.del_channel(ult.chat_id)
80
- return await ult.eor("`Disabled Auto ChannelBan...`")
81
- if not (
82
- ult.chat.creator
83
- or (ult.chat.admin_rights.delete_messages or ult.chat.admin_rights.ban_users)
84
- ):
85
- return await ult.eor(
86
- "You are missing required admin rights!\nYou can't use ChannelBan without Ban/del privilege..`"
87
- )
88
- autoban_db.add_channel(ult.chat_id)
89
- await ult.eor("`Enabled Auto ChannelBan Successfully!`")
90
- ult.client.add_handler(
91
- channel_del,
92
- events.NewMessage(
93
- func=lambda x: not x.is_private and isinstance(x.sender, Channel)
94
- ),
95
- )
96
-
97
-
98
- @ultroid_cmd(pattern="(list|add|rem)wl( (.*)|$)")
99
- async def do_magic(event):
100
- match = event.pattern_match.group(1)
101
- msg = await event.eor(get_string("com_1"))
102
- if match == "list":
103
- cha = autoban_db.get_whitelisted_channels(event.chat_id)
104
- if not cha:
105
- return await msg.edit("`No Whitelisted channels for current chat.`")
106
- Msg = "**Whitelist Channels in Current Chat**\n\n"
107
- for ch in cha:
108
- Msg += f"(`{ch}`) "
109
- try:
110
- Msg += inline_mention(await event.client.get_entity(ch))
111
- except Exception:
112
- Msg += "\n"
113
- return await msg.edit(Msg)
114
- usea = event.pattern_match.group(2).strip()
115
- if not usea:
116
- return await Msg.edit(
117
- "`Please provide a channel username/id to add/remove to/from whitelist..`"
118
- )
119
- try:
120
- u_id = await event.client.parse_id(usea)
121
- cha = await event.client.get_entity(u_id)
122
- except Exception as er:
123
- LOGS.exception(er)
124
- return await msg.edit(f"Error Broke Out!\n`{er}`")
125
- if match == "add":
126
- autoban_db.add_to_whitelist(event.chat_id, u_id)
127
- return await msg.edit(f"`Added` {inline_mention(cha)} `to WhiteList..`")
128
- autoban_db.del_from_whitelist(event.chat_id, u_id)
129
- await msg.edit(f"`Removed` {inline_mention(cha)} `from WhiteList.`")
130
-
131
-
132
- if dnd_db.get_dnd_chats():
133
- ultroid_bot.add_handler(dnd_func, events.ChatAction(func=lambda x: x.user_joined))
134
- asst.add_handler(dnd_func, events.ChatAction(func=lambda x: x.user_joined))
135
-
136
- if autoban_db.get_all_channels():
137
- ultroid_bot.add_handler(
138
- channel_del,
139
- events.NewMessage(
140
- func=lambda x: not x.is_private and isinstance(x.sender, Channel)
141
- ),
142
- )
 
10
  __doc__ = get_help("help_autoban")
11
 
12
  from telethon import events
 
13
 
14
+ from pyUltroid.dB.base import KeyManager
 
15
 
16
+ from . import LOGS, asst, ultroid_bot, ultroid_cmd
17
 
18
+ Keym = KeyManager("DND_CHATS", cast=list)
19
 
20
+
21
+ def join_func(e):
22
+ return e.user_joined and Keym.contains(e.chat_id)
 
 
 
 
 
 
 
 
23
 
24
 
25
+ async def dnd_func(event):
26
+ for user in event.users:
 
 
 
 
 
 
 
27
  try:
28
+ await (await event.client.kick_participant(event.chat_id, user)).delete()
29
+ except Exception as ex:
30
+ LOGS.error("Error in DND:")
31
+ LOGS.exception(ex)
32
+ await event.delete()
 
33
 
34
 
35
  @ultroid_cmd(
 
42
  async def _(event):
43
  match = event.pattern_match.group(1)
44
  if match == "on":
45
+ if Keym.contains(event.chat_id):
46
  return await event.eor("`Chat already in do not disturb mode.`", time=3)
47
+ Keym.add(event.chat_id)
48
+ event.client.add_handler(dnd_func, events.ChatAction(func=join_func))
 
 
49
  await event.eor("`Do not disturb mode activated for this chat.`", time=3)
50
  elif match == "off":
51
+ if not Keym.contains(event.chat_id):
52
  return await event.eor("`Chat is not in do not disturb mode.`", time=3)
53
+ Keym.remove(event.chat_id)
54
  await event.eor("`Do not disturb mode deactivated for this chat.`", time=3)
55
 
56
 
57
+ if Keym.get():
58
+ ultroid_bot.add_handler(dnd_func, events.ChatAction(func=join_func))
59
+ asst.add_handler(dnd_func, events.ChatAction(func=join_func))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plugins/autopic.py CHANGED
@@ -9,12 +9,12 @@
9
  import asyncio
10
  import os
11
  import random
12
- from glob import glob
13
  from random import shuffle
14
 
15
  from telethon.tl.functions.photos import UploadProfilePhotoRequest
16
 
17
- from pyUltroid.fns.google_image import googleimagesdownload
 
18
 
19
  from . import LOGS, get_help, get_string, udB, ultroid_bot, ultroid_cmd
20
 
@@ -59,35 +59,20 @@ async def autopic(e):
59
 
60
 
61
  if search := udB.get_key("AUTOPIC"):
62
- gi = googleimagesdownload()
63
- args = {
64
- "keywords": search,
65
- "limit": 50,
66
- "format": "jpg",
67
- "output_directory": "./resources/downloads/",
68
- }
69
- images = []
70
- if os.path.exists(f"./resources/downloads/{search}"):
71
- images = glob(f"resources/downloads/{search}/*")
72
  sleep = udB.get_key("SLEEP_TIME") or 1221
73
 
74
  async def autopic_func():
75
- if udB.get_key("AUTOPIC") != search:
 
 
 
76
  return
77
- if not images:
78
- try:
79
- pth = await gi.download(args)
80
- ok = pth[0][search]
81
- images.extend(ok)
82
- except Exception as er:
83
- LOGS.exception(er)
84
- return
85
- else:
86
- ok = images
87
- img = random.choice(ok)
88
- file = await ultroid_bot.upload_file(img)
89
  await ultroid_bot(UploadProfilePhotoRequest(file))
90
- shuffle(ok)
91
 
92
  try:
93
  from apscheduler.schedulers.asyncio import AsyncIOScheduler
 
9
  import asyncio
10
  import os
11
  import random
 
12
  from random import shuffle
13
 
14
  from telethon.tl.functions.photos import UploadProfilePhotoRequest
15
 
16
+ from pyUltroid.fns.helper import download_file
17
+ from pyUltroid.fns.tools import get_google_images
18
 
19
  from . import LOGS, get_help, get_string, udB, ultroid_bot, ultroid_cmd
20
 
 
59
 
60
 
61
  if search := udB.get_key("AUTOPIC"):
62
+ images = {}
 
 
 
 
 
 
 
 
 
63
  sleep = udB.get_key("SLEEP_TIME") or 1221
64
 
65
  async def autopic_func():
66
+ search = udB.get_key("AUTOPIC")
67
+ if images.get(search) is None:
68
+ images[search] = await get_google_images(search)
69
+ if not images.get(search):
70
  return
71
+ img = random.choice(images[search])
72
+ filee = await download_file(img["original"], "resources/downloads/autopic.jpg")
73
+ file = await ultroid_bot.upload_file(filee)
 
 
 
 
 
 
 
 
 
74
  await ultroid_bot(UploadProfilePhotoRequest(file))
75
+ os.remove(filee)
76
 
77
  try:
78
  from apscheduler.schedulers.asyncio import AsyncIOScheduler
plugins/beautify.py CHANGED
@@ -10,11 +10,12 @@ from . import get_help
10
  __doc__ = get_help("help_beautify")
11
 
12
 
 
13
  import random
14
 
15
  from telethon.utils import get_display_name
16
 
17
- from . import Carbon, eor, get_string, inline_mention, os, ultroid_cmd
18
 
19
  _colorspath = "resources/colorlist.txt"
20
 
@@ -28,7 +29,7 @@ else:
28
  @ultroid_cmd(
29
  pattern="(rc|c)arbon",
30
  )
31
- async def crbn(event):
32
  xxxx = await event.eor(get_string("com_1"))
33
  te = event.pattern_match.group(1)
34
  col = random.choice(all_col) if te[0] == "r" else "White"
@@ -45,8 +46,11 @@ async def crbn(event):
45
  try:
46
  code = event.text.split(" ", maxsplit=1)[1]
47
  except IndexError:
48
- return await eor(xxxx, get_string("carbon_2"))
49
  xx = await Carbon(code=code, file_name="ultroid_carbon", backgroundColor=col)
 
 
 
50
  await xxxx.delete()
51
  await event.reply(
52
  f"Carbonised by {inline_mention(event.sender)}",
@@ -77,7 +81,7 @@ async def crbn(event):
77
  code = match[1]
78
  match = match[0]
79
  except IndexError:
80
- return await eor(msg, get_string("carbon_2"))
81
  xx = await Carbon(code=code, backgroundColor=match)
82
  await msg.delete()
83
  await event.reply(
@@ -125,7 +129,7 @@ async def pass_on(ult):
125
  theme = random.choice(RaySoTheme)
126
  if ult.is_reply:
127
  msg = await ult.get_reply_message()
128
- text = msg.text
129
  title = get_display_name(msg.sender)
130
  await ult.reply(
131
  file=await Carbon(text, rayso=True, title=title, theme=theme, darkMode=dark)
 
10
  __doc__ = get_help("help_beautify")
11
 
12
 
13
+ import os
14
  import random
15
 
16
  from telethon.utils import get_display_name
17
 
18
+ from . import Carbon, ultroid_cmd, get_string, inline_mention
19
 
20
  _colorspath = "resources/colorlist.txt"
21
 
 
29
  @ultroid_cmd(
30
  pattern="(rc|c)arbon",
31
  )
32
+ async def cr_bn(event):
33
  xxxx = await event.eor(get_string("com_1"))
34
  te = event.pattern_match.group(1)
35
  col = random.choice(all_col) if te[0] == "r" else "White"
 
46
  try:
47
  code = event.text.split(" ", maxsplit=1)[1]
48
  except IndexError:
49
+ return await xxxx.eor(get_string("carbon_2"))
50
  xx = await Carbon(code=code, file_name="ultroid_carbon", backgroundColor=col)
51
+ if isinstance(xx, dict):
52
+ await xxxx.edit(f"`{xx}`")
53
+ return
54
  await xxxx.delete()
55
  await event.reply(
56
  f"Carbonised by {inline_mention(event.sender)}",
 
81
  code = match[1]
82
  match = match[0]
83
  except IndexError:
84
+ return await msg.eor(get_string("carbon_2"))
85
  xx = await Carbon(code=code, backgroundColor=match)
86
  await msg.delete()
87
  await event.reply(
 
129
  theme = random.choice(RaySoTheme)
130
  if ult.is_reply:
131
  msg = await ult.get_reply_message()
132
+ text = msg.message
133
  title = get_display_name(msg.sender)
134
  await ult.reply(
135
  file=await Carbon(text, rayso=True, title=title, theme=theme, darkMode=dark)
plugins/blacklist.py CHANGED
@@ -57,14 +57,12 @@ async def lsnote(e):
57
 
58
  async def blacklist(e):
59
  if x := get_blacklist(e.chat_id):
60
- for z in e.text.lower().split():
61
- for zz in x:
62
- if z == zz:
63
- try:
64
- await e.delete()
65
- break
66
- except BaseException:
67
- break
68
 
69
 
70
  if udB.get_key("BLACKLIST_DB"):
 
57
 
58
  async def blacklist(e):
59
  if x := get_blacklist(e.chat_id):
60
+ text = e.text.lower().split()
61
+ if any((z in text) for z in x):
62
+ try:
63
+ await e.delete()
64
+ except BaseException:
65
+ pass
 
 
66
 
67
 
68
  if udB.get_key("BLACKLIST_DB"):
plugins/bot.py CHANGED
@@ -84,7 +84,7 @@ The Ultroid Userbot
84
  ◍ Telethon - {}
85
  """
86
 
87
- in_alive = "{}\n\n🌀 <b>Ultroid Version -><b> <code>{}</code>\n🌀 <b>PyUltroid -></b> <code>{}</code>\n🌀 <b>Python -></b> <code>{}</code>\n🌀 <b>Uptime -></b> <code>{}</code>\n🌀 <b>Branch -></b> [ {} ]\n\n• <b>Join @TeamUltroid</b>"
88
 
89
 
90
  @callback("alive")
@@ -243,6 +243,9 @@ async def _(event):
243
  code=code,
244
  backgroundColor=choice(ATRA_COL),
245
  )
 
 
 
246
  await event.reply("**Ultroid Logs.**", file=file)
247
  elif opt == "open":
248
  with open("ultroid.log", "r") as f:
@@ -296,7 +299,7 @@ async def inline_alive(ult):
296
  ]
297
  return await ult.answer(results)
298
  except BaseException as er:
299
- LOGS.info(er)
300
  result = [
301
  await builder.article(
302
  "Alive", text=als, parse_mode="html", link_preview=False, buttons=buttons
 
84
  ◍ Telethon - {}
85
  """
86
 
87
+ in_alive = "{}\n\n🌀 <b>Ultroid Version -><b> <code>{}</code>\n🌀 <b>PyUltroid -></b> <code>{}</code>\n🌀 <b>Python -></b> <code>{}</code>\n🌀 <b>Uptime -></b> <code>{}</code>\n🌀 <b>Branch -></b>[ {} ]\n\n• <b>Join @TeamUltroid</b>"
88
 
89
 
90
  @callback("alive")
 
243
  code=code,
244
  backgroundColor=choice(ATRA_COL),
245
  )
246
+ if isinstance(file, dict):
247
+ await event.eor(f"`{file}`")
248
+ return
249
  await event.reply("**Ultroid Logs.**", file=file)
250
  elif opt == "open":
251
  with open("ultroid.log", "r") as f:
 
299
  ]
300
  return await ult.answer(results)
301
  except BaseException as er:
302
+ LOGS.exception(er)
303
  result = [
304
  await builder.article(
305
  "Alive", text=als, parse_mode="html", link_preview=False, buttons=buttons
plugins/broadcast.py CHANGED
@@ -15,10 +15,12 @@ import io
15
 
16
  from telethon.utils import get_display_name
17
 
18
- from pyUltroid.dB.broadcast_db import *
19
 
20
  from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
21
 
 
 
22
 
23
  @ultroid_cmd(
24
  pattern="addch( (.*)|$)",
@@ -40,14 +42,14 @@ async def broadcast_adder(event):
40
  if (
41
  i.broadcast
42
  and (i.creator or i.admin_rights)
43
- and not is_channel_added(i.id)
44
  ):
45
  new += 1
46
  cid = f"-100{i.id}"
47
- add_channel(int(cid))
48
  except Exception as Ex:
49
  LOGS.exception(Ex)
50
- await x.edit(get_string("bd_3").format(get_no_channels(), new))
51
  return
52
  if event.reply_to_msg_id:
53
  previous_message = await event.get_reply_message()
@@ -56,8 +58,8 @@ async def broadcast_adder(event):
56
  length = len(lines)
57
  for line_number in range(1, length - 2):
58
  channel_id = lines[line_number][4:-1]
59
- if not is_channel_added(channel_id):
60
- add_channel(channel_id)
61
  await x.edit(get_string("bd_4"))
62
  await asyncio.sleep(3)
63
  await event.delete()
@@ -65,9 +67,9 @@ async def broadcast_adder(event):
65
  chat_id = event.chat_id
66
  if chat_id == udB.get_key("LOG_CHANNEL"):
67
  return
68
- if is_channel_added(chat_id):
69
  await x.edit(get_string("bd_6"))
70
- elif xx := add_channel(chat_id):
71
  await x.edit(get_string("bd_5"))
72
  else:
73
  await x.edit(get_string("sf_8"))
@@ -87,8 +89,8 @@ async def broadcast_remover(event):
87
  udB.del_key("BROADCAST")
88
  await x.edit("Database cleared.")
89
  return
90
- if is_channel_added(chat_id):
91
- rem_channel(chat_id)
92
  await x.edit(get_string("bd_7"))
93
  else:
94
  await x.edit(get_string("bd_9"))
@@ -101,8 +103,8 @@ async def broadcast_remover(event):
101
  )
102
  async def list_all(event):
103
  x = await event.eor(get_string("com_1"))
104
- channels = get_channels()
105
- num = len(channels)
106
  if not channels:
107
  return await eor(x, "No chats were added.", time=5)
108
  msg = "Channels in database:\n"
@@ -137,14 +139,13 @@ async def forw(event):
137
  if not event.is_reply:
138
  return await event.eor(get_string("ex_1"))
139
  ultroid_bot = event.client
140
- channels = get_channels()
141
  x = await event.eor("Sending...")
142
  if not channels:
143
  return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
144
  error_count = 0
145
  sent_count = 0
146
- if event.reply_to_msg_id:
147
- previous_message = await event.get_reply_message()
148
  error_count = 0
149
  for channel in channels:
150
  try:
@@ -156,7 +157,7 @@ async def forw(event):
156
  except Exception:
157
  try:
158
  await ultroid_bot.send_message(
159
- int(udB.get_key("LOG_CHANNEL")),
160
  f"Error in sending at {channel}.",
161
  )
162
  except Exception as Em:
@@ -168,7 +169,7 @@ async def forw(event):
168
  await x.edit(f"{sent_count} messages sent with {error_count} errors.")
169
  if error_count > 0:
170
  await ultroid_bot.send_message(
171
- int(udB.get_key("LOG_CHANNEL")), f"{error_count} Errors"
172
  )
173
 
174
 
@@ -180,7 +181,7 @@ async def sending(event):
180
  x = await event.eor(get_string("com_1"))
181
  if not event.is_reply:
182
  return await x.edit(get_string("ex_1"))
183
- channels = get_channels()
184
  if not channels:
185
  return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
186
  await x.edit("Sending....")
@@ -199,7 +200,6 @@ async def sending(event):
199
  f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
200
  )
201
  except Exception as error:
202
-
203
  await ultroid_bot.send_message(
204
  udB.get_key("LOG_CHANNEL"),
205
  f"Error in sending at {channel}.\n\n{error}",
@@ -211,6 +211,6 @@ async def sending(event):
211
  await x.edit(f"{sent_count} messages sent with {error_count} errors.")
212
  if error_count > 0:
213
  await ultroid_bot.send_message(
214
- int(udB.get_key("LOG_CHANNEL")),
215
  f"{error_count} Errors",
216
  )
 
15
 
16
  from telethon.utils import get_display_name
17
 
18
+ from pyUltroid.dB.base import KeyManager
19
 
20
  from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd
21
 
22
+ KeyM = KeyManager("BROADCAST", cast=list)
23
+
24
 
25
  @ultroid_cmd(
26
  pattern="addch( (.*)|$)",
 
42
  if (
43
  i.broadcast
44
  and (i.creator or i.admin_rights)
45
+ and not KeyM.contains(i.id)
46
  ):
47
  new += 1
48
  cid = f"-100{i.id}"
49
+ KeyM.add(int(cid))
50
  except Exception as Ex:
51
  LOGS.exception(Ex)
52
+ await x.edit(get_string("bd_3").format(KeyM.count(), new))
53
  return
54
  if event.reply_to_msg_id:
55
  previous_message = await event.get_reply_message()
 
58
  length = len(lines)
59
  for line_number in range(1, length - 2):
60
  channel_id = lines[line_number][4:-1]
61
+ if not KeyM.contains(channel_id):
62
+ KeyM.add(channel_id)
63
  await x.edit(get_string("bd_4"))
64
  await asyncio.sleep(3)
65
  await event.delete()
 
67
  chat_id = event.chat_id
68
  if chat_id == udB.get_key("LOG_CHANNEL"):
69
  return
70
+ if KeyM.contains(chat_id):
71
  await x.edit(get_string("bd_6"))
72
+ elif xx := KeyM.add(chat_id):
73
  await x.edit(get_string("bd_5"))
74
  else:
75
  await x.edit(get_string("sf_8"))
 
89
  udB.del_key("BROADCAST")
90
  await x.edit("Database cleared.")
91
  return
92
+ if KeyM.contains(chat_id):
93
+ KeyM.remove(chat_id)
94
  await x.edit(get_string("bd_7"))
95
  else:
96
  await x.edit(get_string("bd_9"))
 
103
  )
104
  async def list_all(event):
105
  x = await event.eor(get_string("com_1"))
106
+ channels = KeyM.get()
107
+ num = KeyM.count()
108
  if not channels:
109
  return await eor(x, "No chats were added.", time=5)
110
  msg = "Channels in database:\n"
 
139
  if not event.is_reply:
140
  return await event.eor(get_string("ex_1"))
141
  ultroid_bot = event.client
142
+ channels = KeyM.get()
143
  x = await event.eor("Sending...")
144
  if not channels:
145
  return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
146
  error_count = 0
147
  sent_count = 0
148
+ previous_message = await event.get_reply_message()
 
149
  error_count = 0
150
  for channel in channels:
151
  try:
 
157
  except Exception:
158
  try:
159
  await ultroid_bot.send_message(
160
+ udB.get_key("LOG_CHANNEL"),
161
  f"Error in sending at {channel}.",
162
  )
163
  except Exception as Em:
 
169
  await x.edit(f"{sent_count} messages sent with {error_count} errors.")
170
  if error_count > 0:
171
  await ultroid_bot.send_message(
172
+ udB.get_key("LOG_CHANNEL"), f"{error_count} Errors"
173
  )
174
 
175
 
 
181
  x = await event.eor(get_string("com_1"))
182
  if not event.is_reply:
183
  return await x.edit(get_string("ex_1"))
184
+ channels = KeyM.get()
185
  if not channels:
186
  return await x.edit(f"Please add channels by using `{HNDLR}add` in them.")
187
  await x.edit("Sending....")
 
200
  f"Sent : {sent_count}\nError : {error_count}\nTotal : {len(channels)}",
201
  )
202
  except Exception as error:
 
203
  await ultroid_bot.send_message(
204
  udB.get_key("LOG_CHANNEL"),
205
  f"Error in sending at {channel}.\n\n{error}",
 
211
  await x.edit(f"{sent_count} messages sent with {error_count} errors.")
212
  if error_count > 0:
213
  await ultroid_bot.send_message(
214
+ udB.get_key("LOG_CHANNEL"),
215
  f"{error_count} Errors",
216
  )
plugins/channelhacks.py CHANGED
@@ -15,32 +15,23 @@ import io
15
  from telethon.errors.rpcerrorlist import FloodWaitError
16
  from telethon.utils import get_display_name, get_peer_id
17
 
18
- from pyUltroid.dB.ch_db import (
19
- add_destination,
20
- add_source_channel,
21
- get_destinations,
22
- get_no_destinations,
23
- get_no_source_channels,
24
- get_source_channels,
25
- is_destination_added,
26
- is_source_channel_added,
27
- rem_destination,
28
- rem_source_channel,
29
- )
30
 
31
  from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
32
 
33
  ERROR = {}
 
 
34
 
35
 
36
  async def autopost_func(e):
37
  if not udB.get_key("AUTOPOST"):
38
  return
39
- x = get_source_channels()
40
  th = await e.get_chat()
41
  if get_peer_id(th) not in x:
42
  return
43
- y = get_destinations()
44
  for ys in y:
45
  try:
46
  await e.client.send_message(int(ys), e.message)
@@ -91,11 +82,11 @@ async def source(e):
91
  return
92
  else:
93
  y = e.chat_id
94
- if not is_source_channel_added(y):
95
- add_source_channel(y)
96
  await e.eor(get_string("cha_2"))
97
  ultroid_bot.add_handler(autopost_func, events.NewMessage())
98
- elif is_source_channel_added(y):
99
  await e.eor(get_string("cha_3"))
100
 
101
 
@@ -116,24 +107,21 @@ async def dd(event):
116
  return
117
  else:
118
  y = event.chat_id
119
- if is_source_channel_added(y):
120
- rem_source_channel(y)
121
- await eor(x, get_string("cha_5"), time=3)
122
- elif is_source_channel_added(y):
123
- rem_source_channel(y)
124
  await eor(x, get_string("cha_5"), time=5)
125
- elif not is_source_channel_added(y):
126
  await eor(x, "Source channel is already removed from database. ", time=3)
127
 
128
 
129
  @ultroid_cmd(pattern="listsource")
130
  async def list_all(event):
131
  x = await event.eor(get_string("com_1"))
132
- num = get_no_source_channels()
133
  if not num:
134
  return await eor(x, "No chats were added.", time=5)
135
  msg = get_string("cha_8")
136
- channels = get_source_channels()
137
  for channel in channels:
138
  name = ""
139
  try:
@@ -141,18 +129,16 @@ async def list_all(event):
141
  except BaseException:
142
  name = ""
143
  msg += f"\n=> **{name}** [`{channel}`]"
144
- msg += f"\nTotal {get_no_source_channels()} channels."
145
  if len(msg) > 4096:
146
  MSG = msg.replace("*", "").replace("`", "")
147
  with io.BytesIO(str.encode(MSG)) as out_file:
148
  out_file.name = "channels.txt"
149
- await event.client.send_file(
150
- event.chat_id,
151
- out_file,
152
  force_document=True,
153
  allow_cache=False,
154
- caption="Channels in database",
155
- reply_to=event,
156
  )
157
  await x.delete()
158
  else:
@@ -169,10 +155,10 @@ async def destination(e):
169
  return
170
  else:
171
  y = e.chat_id
172
- if not is_destination_added(y):
173
- add_destination(y)
174
  await e.eor("Destination added succesfully")
175
- elif is_destination_added(y):
176
  await e.eor("Destination channel already added")
177
 
178
 
@@ -193,13 +179,10 @@ async def dd(event):
193
  return
194
  else:
195
  y = event.chat_id
196
- if is_destination_added(y):
197
- rem_destination(y)
198
  await eor(x, "Destination removed from database")
199
- elif is_destination_added(y):
200
- rem_destination(y)
201
- await eor(x, "Destination removed from database", time=5)
202
- elif not is_destination_added(y):
203
  await eor(x, "Destination channel is already removed from database. ", time=5)
204
 
205
 
@@ -207,8 +190,8 @@ async def dd(event):
207
  async def list_all(event):
208
  ultroid_bot = event.client
209
  x = await event.eor(get_string("com_1"))
210
- channels = get_destinations()
211
- num = get_no_destinations()
212
  if not num:
213
  return await eor(x, "No chats were added.", time=5)
214
  msg = get_string("cha_7")
@@ -219,7 +202,7 @@ async def list_all(event):
219
  except BaseException:
220
  name = ""
221
  msg += f"\n=> **{name}** [`{channel}`]"
222
- msg += f"\nTotal {get_no_destinations()} channels."
223
  if len(msg) > 4096:
224
  MSG = msg.replace("*", "").replace("`", "")
225
  with io.BytesIO(str.encode(MSG)) as out_file:
 
15
  from telethon.errors.rpcerrorlist import FloodWaitError
16
  from telethon.utils import get_display_name, get_peer_id
17
 
18
+ from pyUltroid.dB.base import KeyManager
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  from . import LOGS, asst, eor, events, get_string, udB, ultroid_bot, ultroid_cmd
21
 
22
  ERROR = {}
23
+ SourceM = KeyManager("CH_SOURCE", cast=list)
24
+ DestiM = KeyManager("CH_DESTINATIONS", cast=list)
25
 
26
 
27
  async def autopost_func(e):
28
  if not udB.get_key("AUTOPOST"):
29
  return
30
+ x = SourceM.get()
31
  th = await e.get_chat()
32
  if get_peer_id(th) not in x:
33
  return
34
+ y = DestiM.get()
35
  for ys in y:
36
  try:
37
  await e.client.send_message(int(ys), e.message)
 
82
  return
83
  else:
84
  y = e.chat_id
85
+ if not SourceM.contains(y):
86
+ SourceM.add(y)
87
  await e.eor(get_string("cha_2"))
88
  ultroid_bot.add_handler(autopost_func, events.NewMessage())
89
+ else:
90
  await e.eor(get_string("cha_3"))
91
 
92
 
 
107
  return
108
  else:
109
  y = event.chat_id
110
+ if SourceM.contains(y):
111
+ SourceM.remove(y)
 
 
 
112
  await eor(x, get_string("cha_5"), time=5)
113
+ else:
114
  await eor(x, "Source channel is already removed from database. ", time=3)
115
 
116
 
117
  @ultroid_cmd(pattern="listsource")
118
  async def list_all(event):
119
  x = await event.eor(get_string("com_1"))
120
+ num = SourceM.count()
121
  if not num:
122
  return await eor(x, "No chats were added.", time=5)
123
  msg = get_string("cha_8")
124
+ channels = SourceM.get()
125
  for channel in channels:
126
  name = ""
127
  try:
 
129
  except BaseException:
130
  name = ""
131
  msg += f"\n=> **{name}** [`{channel}`]"
132
+ msg += f"\nTotal {num} channels."
133
  if len(msg) > 4096:
134
  MSG = msg.replace("*", "").replace("`", "")
135
  with io.BytesIO(str.encode(MSG)) as out_file:
136
  out_file.name = "channels.txt"
137
+ await event.reply(
138
+ "Channels in database",
139
+ file=out_file,
140
  force_document=True,
141
  allow_cache=False,
 
 
142
  )
143
  await x.delete()
144
  else:
 
155
  return
156
  else:
157
  y = e.chat_id
158
+ if not DestiM.contains(y):
159
+ DestiM.add(y)
160
  await e.eor("Destination added succesfully")
161
+ else:
162
  await e.eor("Destination channel already added")
163
 
164
 
 
179
  return
180
  else:
181
  y = event.chat_id
182
+ if DestiM.contains(y):
183
+ DestiM.remove(y)
184
  await eor(x, "Destination removed from database")
185
+ else:
 
 
 
186
  await eor(x, "Destination channel is already removed from database. ", time=5)
187
 
188
 
 
190
  async def list_all(event):
191
  ultroid_bot = event.client
192
  x = await event.eor(get_string("com_1"))
193
+ channels = DestiM.get()
194
+ num = len(channels)
195
  if not num:
196
  return await eor(x, "No chats were added.", time=5)
197
  msg = get_string("cha_7")
 
202
  except BaseException:
203
  name = ""
204
  msg += f"\n=> **{name}** [`{channel}`]"
205
+ msg += f"\nTotal {num} channels."
206
  if len(msg) > 4096:
207
  MSG = msg.replace("*", "").replace("`", "")
208
  with io.BytesIO(str.encode(MSG)) as out_file:
plugins/chatbot.py CHANGED
@@ -12,7 +12,7 @@ __doc__ = get_help("help_chatbot")
12
 
13
  from pyUltroid.fns.tools import get_chatbot_reply
14
 
15
- from . import eod, get_string, inline_mention, udB, ultroid_cmd, LOGS
16
 
17
 
18
  @ultroid_cmd(pattern="repai")
@@ -67,8 +67,8 @@ async def chat_bot_fn(event, type_):
67
  user_ = event.chat if event.is_private else None
68
  if not user_:
69
  return await eod(
70
- event,
71
- get_string("chab_1"),
72
  )
73
  key = udB.get_key("CHATBOT_USERS") or {}
74
  chat = event.chat_id
 
12
 
13
  from pyUltroid.fns.tools import get_chatbot_reply
14
 
15
+ from . import LOGS, eod, get_string, inline_mention, udB, ultroid_cmd
16
 
17
 
18
  @ultroid_cmd(pattern="repai")
 
67
  user_ = event.chat if event.is_private else None
68
  if not user_:
69
  return await eod(
70
+ event,
71
+ get_string("chab_1"),
72
  )
73
  key = udB.get_key("CHATBOT_USERS") or {}
74
  chat = event.chat_id
plugins/cleanaction.py CHANGED
@@ -44,6 +44,5 @@ async def _(e):
44
  except BaseException:
45
  title = get_string("clan_3")
46
  o += f"{x} {title}\n"
47
- await e.eor(o)
48
- else:
49
- await e.eor(get_string("clan_4"), time=5)
 
44
  except BaseException:
45
  title = get_string("clan_3")
46
  o += f"{x} {title}\n"
47
+ return await e.eor(o)
48
+ await e.eor(get_string("clan_4"), time=5)
 
plugins/devtools.py CHANGED
@@ -50,22 +50,28 @@ async def _(e):
50
  x, y = await bash("neofetch|sed 's/\x1B\\[[0-9;\\?]*[a-zA-Z]//g' >> neo.txt")
51
  if y and y.endswith("NOT_FOUND"):
52
  return await xx.edit(f"Error: `{y}`")
53
- with open("neo.txt", "r") as neo:
54
  p = (neo.read()).replace("\n\n", "")
55
  haa = await Carbon(code=p, file_name="neofetch", backgroundColor=choice(ATRA_COL))
56
- await e.reply(file=haa)
57
- await xx.delete()
 
 
 
58
  remove("neo.txt")
59
 
60
 
61
  @ultroid_cmd(pattern="bash", fullsudo=True, only_devs=True)
62
  async def _(event):
63
- carb, yamlf = None, False
64
  try:
65
  cmd = event.text.split(" ", maxsplit=1)[1]
66
  if cmd.split()[0] in ["-c", "--carbon"]:
67
  cmd = cmd.split(maxsplit=1)[1]
68
  carb = True
 
 
 
69
  except IndexError:
70
  return await event.eor(get_string("devs_1"), time=10)
71
  xx = await event.eor(get_string("com_1"))
@@ -88,6 +94,33 @@ async def _(event):
88
  download=True,
89
  backgroundColor=choice(ATRA_COL),
90
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  url = f"https://graph.org{uf(li)[-1]}"
92
  OUT = f"[\xad]({url}){OUT}"
93
  out = "**• OUTPUT:**"
@@ -136,7 +169,7 @@ bot = ultroid = ultroid_bot
136
 
137
 
138
  class u:
139
- ...
140
 
141
 
142
  def _parse_eval(value=None):
@@ -152,6 +185,14 @@ def _parse_eval(value=None):
152
  return json_parser(value, indent=1)
153
  except BaseException:
154
  pass
 
 
 
 
 
 
 
 
155
  return str(value)
156
 
157
 
@@ -161,7 +202,8 @@ async def _(event):
161
  cmd = event.text.split(maxsplit=1)[1]
162
  except IndexError:
163
  return await event.eor(get_string("devs_2"), time=5)
164
- silent, gsource, xx = False, False, None
 
165
  spli = cmd.split()
166
 
167
  async def get_():
@@ -174,17 +216,19 @@ async def _(event):
174
 
175
  if spli[0] in ["-s", "--silent"]:
176
  await event.delete()
177
- silent = True
178
- cmd = await get_()
179
  elif spli[0] in ["-n", "-noedit"]:
180
- cmd = await get_()
181
  xx = await event.reply(get_string("com_1"))
182
  elif spli[0] in ["-gs", "--source"]:
183
- gsource = True
 
 
 
184
  cmd = await get_()
185
  if not cmd:
186
  return
187
- if not silent and not xx:
188
  xx = await event.eor(get_string("com_1"))
189
  if black:
190
  try:
@@ -220,13 +264,20 @@ async def _(event):
220
  stderr = redirected_error.getvalue()
221
  sys.stdout = old_stdout
222
  sys.stderr = old_stderr
223
- if value and gsource:
224
  try:
225
- exc = inspect.getsource(value)
 
 
 
 
 
 
 
226
  except Exception:
227
  exc = traceback.format_exc()
228
  evaluation = exc or stderr or stdout or _parse_eval(value) or get_string("instu_4")
229
- if silent:
230
  if exc:
231
  msg = f"• <b>EVAL ERROR\n\n• CHAT:</b> <code>{get_display_name(event.chat)}</code> [<code>{event.chat_id}</code>]"
232
  msg += f"\n\n∆ <b>CODE:</b>\n<code>{cmd}</code>\n\n∆ <b>ERROR:</b>\n<code>{exc}</code>"
 
50
  x, y = await bash("neofetch|sed 's/\x1B\\[[0-9;\\?]*[a-zA-Z]//g' >> neo.txt")
51
  if y and y.endswith("NOT_FOUND"):
52
  return await xx.edit(f"Error: `{y}`")
53
+ with open("neo.txt", "r", encoding="utf-8") as neo:
54
  p = (neo.read()).replace("\n\n", "")
55
  haa = await Carbon(code=p, file_name="neofetch", backgroundColor=choice(ATRA_COL))
56
+ if isinstance(haa, dict):
57
+ await xx.edit(f"`{haa}`")
58
+ else:
59
+ await e.reply(file=haa)
60
+ await xx.delete()
61
  remove("neo.txt")
62
 
63
 
64
  @ultroid_cmd(pattern="bash", fullsudo=True, only_devs=True)
65
  async def _(event):
66
+ carb, rayso, yamlf = None, None, False
67
  try:
68
  cmd = event.text.split(" ", maxsplit=1)[1]
69
  if cmd.split()[0] in ["-c", "--carbon"]:
70
  cmd = cmd.split(maxsplit=1)[1]
71
  carb = True
72
+ if cmd.split()[0] in ["-r", "--rayso"]:
73
+ cmd = cmd.split(maxsplit=1)[1]
74
+ rayso = True
75
  except IndexError:
76
  return await event.eor(get_string("devs_1"), time=10)
77
  xx = await event.eor(get_string("com_1"))
 
94
  download=True,
95
  backgroundColor=choice(ATRA_COL),
96
  )
97
+ if isinstance(li, dict):
98
+ await xx.edit(
99
+ f"Unknown Response from Carbon: `{li}`\n\nstdout`:{stdout}`\nstderr: `{stderr}`"
100
+ )
101
+ return
102
+ url = f"https://graph.org{uf(li)[-1]}"
103
+ OUT = f"[\xad]({url}){OUT}"
104
+ out = "**• OUTPUT:**"
105
+ remove(li)
106
+ elif (rayso or udB.get_key("RAYSO_ON_BASH")) and (
107
+ event.is_private
108
+ or event.chat.admin_rights
109
+ or event.chat.creator
110
+ or event.chat.default_banned_rights.embed_links
111
+ ):
112
+ li = await Carbon(
113
+ code=stdout,
114
+ file_name="bash",
115
+ download=True,
116
+ backgroundColor=choice(ATRA_COL),
117
+ rayso=True,
118
+ )
119
+ if isinstance(li, dict):
120
+ await xx.edit(
121
+ f"Unknown Response from Carbon: `{li}`\n\nstdout`:{stdout}`\nstderr: `{stderr}`"
122
+ )
123
+ return
124
  url = f"https://graph.org{uf(li)[-1]}"
125
  OUT = f"[\xad]({url}){OUT}"
126
  out = "**• OUTPUT:**"
 
169
 
170
 
171
  class u:
172
+ _ = ""
173
 
174
 
175
  def _parse_eval(value=None):
 
185
  return json_parser(value, indent=1)
186
  except BaseException:
187
  pass
188
+ elif isinstance(value, list):
189
+ newlist = "["
190
+ for index, child in enumerate(value):
191
+ newlist += "\n " + str(_parse_eval(child))
192
+ if index < len(value) - 1:
193
+ newlist += ","
194
+ newlist += "\n]"
195
+ return newlist
196
  return str(value)
197
 
198
 
 
202
  cmd = event.text.split(maxsplit=1)[1]
203
  except IndexError:
204
  return await event.eor(get_string("devs_2"), time=5)
205
+ xx = None
206
+ mode = ""
207
  spli = cmd.split()
208
 
209
  async def get_():
 
216
 
217
  if spli[0] in ["-s", "--silent"]:
218
  await event.delete()
219
+ mode = "silent"
 
220
  elif spli[0] in ["-n", "-noedit"]:
221
+ mode = "no-edit"
222
  xx = await event.reply(get_string("com_1"))
223
  elif spli[0] in ["-gs", "--source"]:
224
+ mode = "gsource"
225
+ elif spli[0] in ["-ga", "--args"]:
226
+ mode = "g-args"
227
+ if mode:
228
  cmd = await get_()
229
  if not cmd:
230
  return
231
+ if not mode == "silent" and not xx:
232
  xx = await event.eor(get_string("com_1"))
233
  if black:
234
  try:
 
264
  stderr = redirected_error.getvalue()
265
  sys.stdout = old_stdout
266
  sys.stderr = old_stderr
267
+ if value:
268
  try:
269
+ if mode == "gsource":
270
+ exc = inspect.getsource(value)
271
+ elif mode == "g-args":
272
+ args = inspect.signature(value).parameters.values()
273
+ name = ""
274
+ if hasattr(value, "__name__"):
275
+ name = value.__name__
276
+ exc = f"**{name}**\n\n" + "\n ".join([str(arg) for arg in args])
277
  except Exception:
278
  exc = traceback.format_exc()
279
  evaluation = exc or stderr or stdout or _parse_eval(value) or get_string("instu_4")
280
+ if mode == "silent":
281
  if exc:
282
  msg = f"• <b>EVAL ERROR\n\n• CHAT:</b> <code>{get_display_name(event.chat)}</code> [<code>{event.chat_id}</code>]"
283
  msg += f"\n\n∆ <b>CODE:</b>\n<code>{cmd}</code>\n\n∆ <b>ERROR:</b>\n<code>{exc}</code>"
plugins/echo.py CHANGED
@@ -14,7 +14,7 @@ from telethon.utils import get_display_name
14
 
15
  from pyUltroid.dB.echo_db import add_echo, check_echo, list_echo, rem_echo
16
 
17
- from . import LOGS, events, ultroid_bot, ultroid_cmd
18
 
19
 
20
  @ultroid_cmd(pattern="addecho( (.*)|$)")
@@ -36,7 +36,7 @@ async def echo(e):
36
  return await e.eor("Echo already activated for this user.", time=5)
37
  add_echo(e.chat_id, user)
38
  ok = await e.client.get_entity(user)
39
- user = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
40
  await e.eor(f"Activated Echo For {user}.")
41
 
42
 
@@ -63,16 +63,6 @@ async def rm(e):
63
  await e.eor("Echo not activated for this user")
64
 
65
 
66
- @ultroid_bot.on(events.NewMessage(incoming=True))
67
- async def okk(e):
68
- if check_echo(e.chat_id, e.sender_id):
69
- try:
70
- ok = await e.client.get_messages(e.chat_id, ids=e.id)
71
- return await e.client.send_message(e.chat_id, ok)
72
- except Exception as er:
73
- LOGS.info(er)
74
-
75
-
76
  @ultroid_cmd(pattern="listecho$")
77
  async def lstecho(e):
78
  if k := list_echo(e.chat_id):
 
14
 
15
  from pyUltroid.dB.echo_db import add_echo, check_echo, list_echo, rem_echo
16
 
17
+ from . import inline_mention, ultroid_cmd
18
 
19
 
20
  @ultroid_cmd(pattern="addecho( (.*)|$)")
 
36
  return await e.eor("Echo already activated for this user.", time=5)
37
  add_echo(e.chat_id, user)
38
  ok = await e.client.get_entity(user)
39
+ user = inline_mention(ok)
40
  await e.eor(f"Activated Echo For {user}.")
41
 
42
 
 
63
  await e.eor("Echo not activated for this user")
64
 
65
 
 
 
 
 
 
 
 
 
 
 
66
  @ultroid_cmd(pattern="listecho$")
67
  async def lstecho(e):
68
  if k := list_echo(e.chat_id):
plugins/fontgen.py CHANGED
@@ -11,7 +11,7 @@ __doc__ = get_help("help_fontgen")
11
 
12
  import string
13
 
14
- from . import HNDLR, eod, ultroid_cmd
15
 
16
  _default = string.ascii_letters
17
  Fonts = {
 
11
 
12
  import string
13
 
14
+ from . import eod, ultroid_cmd
15
 
16
  _default = string.ascii_letters
17
  Fonts = {
plugins/giftools.py CHANGED
@@ -60,7 +60,7 @@ async def igif(e):
60
  async def reverse_gif(event):
61
  a = await event.get_reply_message()
62
  if not (a and a.media) and "video" not in mediainfo(a.media):
63
- return await e.eor("`Reply To Video only`", time=5)
64
  msg = await event.eor(get_string("com_1"))
65
  file = await a.download_media()
66
  await bash(f'ffmpeg -i "{file}" -vf reverse -af areverse reversed.mp4 -y')
 
60
  async def reverse_gif(event):
61
  a = await event.get_reply_message()
62
  if not (a and a.media) and "video" not in mediainfo(a.media):
63
+ return await event.eor("`Reply To Video only`", time=5)
64
  msg = await event.eor(get_string("com_1"))
65
  file = await a.download_media()
66
  await bash(f'ffmpeg -i "{file}" -vf reverse -af areverse reversed.mp4 -y')
plugins/glitch.py CHANGED
@@ -35,7 +35,7 @@ async def _(e):
35
  else:
36
  return await xx.eor(get_string("com_4"))
37
  cmd = f"glitch_me gif --line_count 200 -f 10 -d 50 '{ok}' ult.gif"
38
- stdout, stderr = await bash(cmd)
39
  await e.reply(file="ult.gif", force_document=False)
40
  await xx.delete()
41
  os.remove(ok)
 
35
  else:
36
  return await xx.eor(get_string("com_4"))
37
  cmd = f"glitch_me gif --line_count 200 -f 10 -d 50 '{ok}' ult.gif"
38
+ await bash(cmd)
39
  await e.reply(file="ult.gif", force_document=False)
40
  await xx.delete()
41
  os.remove(ok)
plugins/globaltools.py CHANGED
@@ -45,6 +45,7 @@ from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
45
  from telethon.tl.types import ChatAdminRights, User
46
 
47
  from pyUltroid.dB import DEVLIST
 
48
  from pyUltroid.dB.gban_mute_db import (
49
  gban,
50
  gmute,
@@ -54,11 +55,6 @@ from pyUltroid.dB.gban_mute_db import (
54
  ungban,
55
  ungmute,
56
  )
57
- from pyUltroid.dB.gcast_blacklist_db import (
58
- add_gblacklist,
59
- is_gblacklisted,
60
- rem_gblacklist,
61
- )
62
  from pyUltroid.fns.tools import create_tl_btn, format_btn, get_msg_button
63
 
64
  from . import (
@@ -93,6 +89,8 @@ _gdemote_rights = ChatAdminRights(
93
  pin_messages=False,
94
  )
95
 
 
 
96
 
97
  @ultroid_cmd(pattern="gpromote( (.*)|$)", fullsudo=True)
98
  async def _(e):
@@ -462,7 +460,7 @@ async def gcast(event):
462
  if x.is_group:
463
  chat = x.entity.id
464
  if (
465
- not is_gblacklisted(chat)
466
  and int(f"-100{str(chat)}") not in NOSPAM_CHAT
467
  and (
468
  (
@@ -545,7 +543,7 @@ async def gucast(event):
545
  for x in dialog:
546
  if x.is_user and not x.entity.bot:
547
  chat = x.id
548
- if not is_gblacklisted(chat):
549
  try:
550
  if btn:
551
  bt = create_tl_btn(btn)
@@ -749,7 +747,7 @@ async def gblacker(event, type_):
749
  except IndexError:
750
  chat_id = event.chat_id
751
  if type_ == "add":
752
- add_gblacklist(chat_id)
753
  elif type_ == "remove":
754
- rem_gblacklist(chat_id)
755
  await event.eor(f"Global Broadcasts: \n{type_}ed {chat_id}")
 
45
  from telethon.tl.types import ChatAdminRights, User
46
 
47
  from pyUltroid.dB import DEVLIST
48
+ from pyUltroid.dB.base import KeyManager
49
  from pyUltroid.dB.gban_mute_db import (
50
  gban,
51
  gmute,
 
55
  ungban,
56
  ungmute,
57
  )
 
 
 
 
 
58
  from pyUltroid.fns.tools import create_tl_btn, format_btn, get_msg_button
59
 
60
  from . import (
 
89
  pin_messages=False,
90
  )
91
 
92
+ keym = KeyManager("GBLACKLISTS", cast=list)
93
+
94
 
95
  @ultroid_cmd(pattern="gpromote( (.*)|$)", fullsudo=True)
96
  async def _(e):
 
460
  if x.is_group:
461
  chat = x.entity.id
462
  if (
463
+ not keym.contains(chat)
464
  and int(f"-100{str(chat)}") not in NOSPAM_CHAT
465
  and (
466
  (
 
543
  for x in dialog:
544
  if x.is_user and not x.entity.bot:
545
  chat = x.id
546
+ if not keym.contains(chat):
547
  try:
548
  if btn:
549
  bt = create_tl_btn(btn)
 
747
  except IndexError:
748
  chat_id = event.chat_id
749
  if type_ == "add":
750
+ keym.add(chat_id)
751
  elif type_ == "remove":
752
+ keym.remove(chat_id)
753
  await event.eor(f"Global Broadcasts: \n{type_}ed {chat_id}")
plugins/imagetools.py CHANGED
@@ -177,11 +177,9 @@ async def ult_tools(event):
177
  ish = centers[labels.flatten()]
178
  ultroid = ish.reshape(ult.shape)
179
  cv2.imwrite("ult.jpg", ultroid)
180
- await event.client.send_file(
181
- event.chat_id,
182
- "ult.jpg",
183
  force_document=False,
184
- reply_to=event.reply_to_msg_id,
185
  )
186
  await xx.delete()
187
  os.remove("ult.jpg")
@@ -196,9 +194,7 @@ async def sampl(ult):
196
  try:
197
  try:
198
  await ult.delete()
199
- await ult.client.send_message(
200
- ult.chat_id, f"Colour Sample for `{color}` !", file="csample.png"
201
- )
202
  except MessageDeleteForbiddenError:
203
  await ult.reply(f"Colour Sample for `{color}` !", file="csample.png")
204
  except ChatSendMediaForbiddenError:
@@ -275,7 +271,7 @@ async def ok(event):
275
  @ultroid_cmd(pattern="pixelator( (.*)|$)")
276
  async def pixelator(event):
277
  reply_message = await event.get_reply_message()
278
- if not (reply_message and reply_message.photo):
279
  return await event.eor("`Reply to a photo`")
280
  hw = 50
281
  try:
 
177
  ish = centers[labels.flatten()]
178
  ultroid = ish.reshape(ult.shape)
179
  cv2.imwrite("ult.jpg", ultroid)
180
+ await ureply.reply(
181
+ file="ult.jpg",
 
182
  force_document=False,
 
183
  )
184
  await xx.delete()
185
  os.remove("ult.jpg")
 
194
  try:
195
  try:
196
  await ult.delete()
197
+ await ult.respond(f"Colour Sample for `{color}` !", file="csample.png")
 
 
198
  except MessageDeleteForbiddenError:
199
  await ult.reply(f"Colour Sample for `{color}` !", file="csample.png")
200
  except ChatSendMediaForbiddenError:
 
271
  @ultroid_cmd(pattern="pixelator( (.*)|$)")
272
  async def pixelator(event):
273
  reply_message = await event.get_reply_message()
274
+ if not (reply_message and (reply_message.photo or reply_message.sticker)):
275
  return await event.eor("`Reply to a photo`")
276
  hw = 50
277
  try:
plugins/instagram.py DELETED
@@ -1,267 +0,0 @@
1
- # Ultroid - UserBot
2
- # Copyright (C) 2021-2022 TeamUltroid
3
- #
4
- # This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
5
- # PLease read the GNU Affero General Public License in
6
- # <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
7
- """
8
- ✘ Commands Available -
9
-
10
- • `{i}instadl <Instagram Url>`
11
- `Download Instagram Media...`
12
-
13
- • `{i}instadata <username>`
14
- `Get Instagram Data of someone or self`
15
-
16
- • `{i}instaul <reply video/photo> <caption>`
17
- `Upload Media to Instagram...`
18
-
19
- • `{i}igtv <reply video> <caption>`
20
- `Upload Media to Igtv...`
21
-
22
- • `{i}reels <reply video> <caption>`
23
- `Upload Media to Instagram reels...`
24
-
25
- • Go Inline with Your Assistant with query `instatm`
26
- To get home page's posts...
27
-
28
- • Fill `INSTA_USERNAME` and `INSTA_PASSWORD`
29
- before using it..
30
- """
31
-
32
- import os
33
- from re import compile
34
-
35
- from telethon.errors.rpcerrorlist import ChatSendInlineForbiddenError
36
- from telethon.tl.types import (
37
- DocumentAttributeFilename,
38
- InputWebDocument,
39
- MessageMediaWebPage,
40
- WebPage,
41
- )
42
-
43
- from pyUltroid.fns.helper import numerize
44
- from pyUltroid.fns.misc import create_instagram_client
45
-
46
- from . import (
47
- LOGS,
48
- Button,
49
- asst,
50
- callback,
51
- eor,
52
- get_string,
53
- in_pattern,
54
- udB,
55
- ultroid_cmd,
56
- )
57
-
58
-
59
- @ultroid_cmd(pattern="instadl( (.*)|$)")
60
- async def insta_dl(e):
61
- match = e.pattern_match.group(1).strip()
62
- replied = await e.get_reply_message()
63
- tt = await e.eor(get_string("com_1"))
64
- if match:
65
- text = match
66
- elif e.is_reply and "insta" in replied.message:
67
- text = replied.message
68
- else:
69
- return await eor(tt, "Provide a Link to Download...")
70
- CL = await create_instagram_client(e)
71
- if CL:
72
- try:
73
- mpk = CL.media_pk_from_url(text)
74
- media = CL.media_info(mpk)
75
- if media.media_type == 1: # photo
76
- media = CL.photo_download(mpk)
77
- elif media.media_type == 2 and media.product_type == "feed": # video:
78
- media = CL.video_download(mpk)
79
- elif media.media_type == 2 and media.product_type == "igtv": # igtv:
80
- media = CL.igtv_download(mpk)
81
- elif (
82
- media.media_type == 2 and media.product_type == "clips"
83
- ): # clips/reels:
84
- media = CL.clip_download(mpk)
85
- elif media.media_type == 8: # Album:
86
- media = CL.album_download(mpk)
87
- else:
88
- LOGS.info(f"UnPredictable Media Type : {mpk}")
89
- return
90
- await e.reply(
91
- f"**• Uploaded Successfully\n• Link :** {text}\n",
92
- file=media,
93
- )
94
- await tt.delete()
95
- if not isinstance(media, list):
96
- os.remove(media)
97
- else:
98
- [os.remove(media) for media in media]
99
- return
100
- except Exception as B:
101
- LOGS.exception(B)
102
- return await eor(tt, str(B))
103
- if isinstance(e.media, MessageMediaWebPage) and isinstance(
104
- e.media.webpage, WebPage
105
- ):
106
- if photo := e.media.webpage.photo or e.media.webpage.document:
107
- await tt.delete()
108
- return await e.reply(
109
- f"**Link** :{text}\n\nIf This Wasnt Excepted Result, Please Fill `INSTA_USERNAME` and `INSTA_PASSWORD`...",
110
- file=photo,
111
- )
112
- # await eor(tt, "Please Fill Instagram Credential to Use this Command...")
113
-
114
-
115
- @ultroid_cmd(pattern="instadata( (.*)|$)")
116
- async def soon_(e):
117
- cl = await create_instagram_client(e)
118
- if not cl:
119
- return
120
- match = e.pattern_match.group(1).strip()
121
- ew = await e.eor(get_string("com_1"))
122
- if match:
123
- try:
124
- iid = cl.user_id_from_username(match)
125
- data = cl.user_info(iid)
126
- except Exception as g:
127
- return await eor(ew, f"**ERROR** : `{g}`")
128
- else:
129
- data = cl.account_info()
130
- data = cl.user_info(data.pk)
131
- photo = data.profile_pic_url
132
- unam = f"https://instagram.com/{data.username}"
133
- msg = f"• **Full Name** : __{data.full_name}__"
134
- if hasattr(data, "biography") and data.biography:
135
- msg += f"\n• **Bio** : `{data.biography}`"
136
- msg += f"\n• **UserName** : [@{data.username}]({unam})"
137
- msg += f"\n• **Verified** : {data.is_verified}"
138
- msg += f"\n• **Posts Count** : {numerize(data.media_count)}"
139
- msg += f"\n• **Followers** : {numerize(data.follower_count)}"
140
- msg += f"\n• **Following** : {numerize(data.following_count)}"
141
- msg += f"\n• **Category** : {data.category_name}"
142
- await e.reply(
143
- msg,
144
- file=photo,
145
- force_document=True,
146
- attributes=[DocumentAttributeFilename("InstaUltroid.jpg")],
147
- )
148
- await ew.delete()
149
-
150
-
151
- @ultroid_cmd(pattern="(instaul|reels|igtv)( (.*)|$)")
152
- async def insta_karbon(event):
153
- cl = await create_instagram_client(event)
154
- if not cl:
155
- return
156
- msg = await event.eor(get_string("com_1"))
157
- replied = await event.get_reply_message()
158
- type_ = event.pattern_match.group(1).strip()
159
- if not (replied and (replied.photo or replied.video)):
160
- return await event.eor("`Reply to Photo Or Video...`")
161
- caption = (
162
- event.pattern_match.group(2) + "\n\n• By #Ultroid"
163
- or replied.message + "\n\n• By #Ultroid"
164
- or "Telegram To Instagram Upload\nBy #Ultroid.."
165
- )
166
- dle = await replied.download_media()
167
- title = None
168
- if replied.photo:
169
- method = cl.photo_upload
170
- elif type_ == "instaul":
171
- method = cl.video_upload
172
- elif type_ == "igtv":
173
- method = cl.igtv_upload
174
- title = caption
175
- elif type_ == "reels":
176
- method = cl.clip_upload
177
- else:
178
- return await eor(msg, "`Use In Proper Format...`")
179
- try:
180
- if title:
181
- uri = method(dle, caption=caption, title=title)
182
- else:
183
- uri = method(dle, caption=caption)
184
- os.remove(dle)
185
- except Exception as er:
186
- LOGS.exception(er)
187
- return await msg.edit(str(er))
188
- if not event.client._bot:
189
- try:
190
- que = await event.client.inline_query(
191
- asst.me.username, f"instp-{uri.code}_{uri.pk}"
192
- )
193
- await que[0].click(event.chat_id, reply_to=replied.id)
194
- await msg.delete()
195
- except ChatSendInlineForbiddenError:
196
- pass
197
- except Exception as er:
198
- return await msg.edit(str(er))
199
- await msg.edit(
200
- f"__Uploaded To Instagram!__\n~ https://instagram.com/p/{uri.code}",
201
- buttons=Button.inline("•Delete•", f"instd{uri.pk}"),
202
- link_preview=False,
203
- )
204
-
205
-
206
- @in_pattern("instp-(.*)", owner=True)
207
- async def instapl(event):
208
- match = event.pattern_match.group(1).strip().split("_")
209
- uri = f"https://instagram.com/p/{match[0]}"
210
- await event.answer(
211
- [
212
- await event.builder.article(
213
- title="Instagram Post",
214
- text="**Uploaded on Instagram**",
215
- buttons=[
216
- Button.url("•View•", uri),
217
- Button.inline("•Delete•", f"instd{match[1]}"),
218
- ],
219
- )
220
- ]
221
- )
222
-
223
-
224
- @callback(compile("instd(.*)"), owner=True)
225
- async def dele_post(event):
226
- CL = await create_instagram_client(event)
227
- if not CL:
228
- return await event.answer("Fill Instagram Credentials", alert=True)
229
- await event.answer("• Deleting...")
230
- try:
231
- CL.media_delete(event.data_match.group(1).decode("utf-8"))
232
- except Exception as er:
233
- return await event.edit(f"ERROR: {str(er)}")
234
- await event.edit("**• Deleted!**")
235
-
236
-
237
- @in_pattern(pattern="instatm", owner=True)
238
- async def bhoot_ayaa(event):
239
- if not udB.get_key("INSTA_SET"):
240
- return await event.answer(
241
- [], switch_pm="Fill Instagram Credentials First.", switch_pm_param="start"
242
- )
243
- insta = await create_instagram_client(event)
244
- posts = insta.get_timeline_feed()
245
- res = []
246
- switch_pm = f"Showing {posts['num_results']} Feeds.."
247
- for rp in posts["feed_items"]:
248
- try:
249
- me = rp["media_or_ad"]
250
- url = me["image_versions2"]["candidates"][1]["url"] + ".jpg"
251
- text = (
252
- f"| Instagram Inline Search |\n~ https://instagram.com/p/{me['code']}"
253
- )
254
- file = InputWebDocument(url, 0, "image/jpeg", [])
255
- res.append(
256
- await event.builder.article(
257
- title="Instagram",
258
- type="photo",
259
- content=file,
260
- thumb=file,
261
- text=text,
262
- include_media=True,
263
- )
264
- )
265
- except Exception as er:
266
- LOGS.exception(er)
267
- await event.answer(res, gallery=True, switch_pm=switch_pm, switch_pm_param="start")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plugins/logo.py CHANGED
@@ -19,6 +19,10 @@ import random
19
 
20
  from telethon.tl.types import InputMessagesFilterPhotos
21
 
 
 
 
 
22
  from pyUltroid.fns.misc import unsplashsearch
23
  from pyUltroid.fns.tools import LogoHelper
24
 
@@ -45,9 +49,22 @@ async def logo_gen(event):
45
  bg_ = await temp.download_media()
46
  if not bg_:
47
  if event.client._bot:
48
- SRCH = ["blur background", "background", "neon lights", "wallpaper"]
 
 
 
 
 
 
 
 
49
  res = await unsplashsearch(random.choice(SRCH), limit=1)
50
- bg_ = await download_file(res[0], "resources/downloads/logo.png")
 
 
 
 
 
51
  else:
52
  pics = []
53
  async for i in event.client.iter_messages(
 
19
 
20
  from telethon.tl.types import InputMessagesFilterPhotos
21
 
22
+ try:
23
+ from PIL import Image
24
+ except ImportError:
25
+ Image = None
26
  from pyUltroid.fns.misc import unsplashsearch
27
  from pyUltroid.fns.tools import LogoHelper
28
 
 
49
  bg_ = await temp.download_media()
50
  if not bg_:
51
  if event.client._bot:
52
+ SRCH = [
53
+ "blur background",
54
+ "background",
55
+ "neon lights",
56
+ "nature",
57
+ "abstract",
58
+ "space",
59
+ "3d render",
60
+ ]
61
  res = await unsplashsearch(random.choice(SRCH), limit=1)
62
+ bg_, _ = await download_file(res[0], "resources/downloads/logo.png")
63
+ newimg = "resources/downloads/unsplash-temp.jpg"
64
+ img_ = Image.open(bg_)
65
+ img_.resize((5000, 5000)).save(newimg)
66
+ os.remove(bg_)
67
+ bg_ = newimg
68
  else:
69
  pics = []
70
  async for i in event.client.iter_messages(
plugins/mediatools.py CHANGED
@@ -73,7 +73,8 @@ async def mi(e):
73
  else:
74
  naam = await r.download_media()
75
  elif match and (
76
- os.path.isfile(match) or (match.startswith("https://") and is_url_ok(match))
 
77
  ):
78
  naam, xx = match, "file"
79
  else:
@@ -123,18 +124,18 @@ async def rotate_(ult):
123
  reply = await ult.get_reply_message()
124
  msg = await ult.eor(get_string("com_1"))
125
  photo = reply.game.photo if reply.game else None
126
- if photo or reply.photo or reply.sticker:
127
- media = await ult.client.download_media(photo or reply)
128
- img = cv2.imread(media)
129
- new_ = rotate_image(img, match)
130
- file = "ult.png"
131
- cv2.imwrite(file, new_)
132
- elif reply.video:
133
  media = await reply.download_media()
134
  file = f"{media}.mp4"
135
  await bash(
136
  f'ffmpeg -i "{media}" -c copy -metadata:s:v:0 rotate={match} "{file}" -y'
137
  )
 
 
 
 
 
 
138
  else:
139
  return await msg.edit("`Unsupported Media..\nReply to Photo/Video`")
140
  if os.path.exists(file):
 
73
  else:
74
  naam = await r.download_media()
75
  elif match and (
76
+ os.path.isfile(match)
77
+ or (match.startswith("https://") and (await is_url_ok(match)))
78
  ):
79
  naam, xx = match, "file"
80
  else:
 
124
  reply = await ult.get_reply_message()
125
  msg = await ult.eor(get_string("com_1"))
126
  photo = reply.game.photo if reply.game else None
127
+ if reply.video:
 
 
 
 
 
 
128
  media = await reply.download_media()
129
  file = f"{media}.mp4"
130
  await bash(
131
  f'ffmpeg -i "{media}" -c copy -metadata:s:v:0 rotate={match} "{file}" -y'
132
  )
133
+ elif photo or reply.photo or reply.sticker:
134
+ media = await ult.client.download_media(photo or reply)
135
+ img = cv2.imread(media)
136
+ new_ = rotate_image(img, match)
137
+ file = "ult.png"
138
+ cv2.imwrite(file, new_)
139
  else:
140
  return await msg.edit("`Unsupported Media..\nReply to Photo/Video`")
141
  if os.path.exists(file):
plugins/mute.py CHANGED
@@ -109,16 +109,16 @@ async def _(e):
109
  except IndexError:
110
  return await xx.eor("`Time till mute?`", time=5)
111
  try:
112
- input = huh[2]
113
  except IndexError:
114
- pass
115
  chat = await e.get_chat()
116
  if e.reply_to_msg_id:
117
  reply = await e.get_reply_message()
118
  userid = reply.sender_id
119
  name = (await reply.get_sender()).first_name
120
- elif input:
121
- userid = await e.client.parse_id(input)
122
  name = (await e.client.get_entity(userid)).first_name
123
  else:
124
  return await xx.eor(get_string("tban_1"), time=3)
 
109
  except IndexError:
110
  return await xx.eor("`Time till mute?`", time=5)
111
  try:
112
+ input_ = huh[2]
113
  except IndexError:
114
+ input_ = ""
115
  chat = await e.get_chat()
116
  if e.reply_to_msg_id:
117
  reply = await e.get_reply_message()
118
  userid = reply.sender_id
119
  name = (await reply.get_sender()).first_name
120
+ elif input_:
121
+ userid = await e.client.parse_id(input_)
122
  name = (await e.client.get_entity(userid)).first_name
123
  else:
124
  return await xx.eor(get_string("tban_1"), time=3)
plugins/nightmode.py CHANGED
@@ -40,10 +40,12 @@ except ImportError:
40
  from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest
41
  from telethon.tl.types import ChatBannedRights
42
 
43
- from pyUltroid.dB.night_db import *
44
 
45
  from . import get_string, udB, ultroid_bot, ultroid_cmd
46
 
 
 
47
 
48
  @ultroid_cmd(pattern="nmtime( (.*)|$)")
49
  async def set_time(e):
@@ -64,29 +66,29 @@ async def set_time(e):
64
  async def add_grp(e):
65
  if pat := e.pattern_match.group(1).strip():
66
  try:
67
- add_night((await ultroid_bot.get_entity(pat)).id)
68
  return await e.eor(f"Done, Added {pat} To Night Mode.")
69
  except BaseException:
70
  return await e.eor(get_string("nightm_5"), time=5)
71
- add_night(e.chat_id)
72
  await e.eor(get_string("nightm_3"))
73
 
74
 
75
  @ultroid_cmd(pattern="remnm( (.*)|$)")
76
- async def rem_grp(e):
77
  if pat := e.pattern_match.group(1).strip():
78
  try:
79
- rem_night((await ultroid_bot.get_entity(pat)).id)
80
  return await e.eor(f"Done, Removed {pat} To Night Mode.")
81
  except BaseException:
82
  return await e.eor(get_string("nightm_5"), time=5)
83
- rem_night(e.chat_id)
84
  await e.eor(get_string("nightm_4"))
85
 
86
 
87
  @ultroid_cmd(pattern="listnm$")
88
  async def rem_grp(e):
89
- chats = night_grps()
90
  name = "NightMode Groups Are-:\n\n"
91
  for x in chats:
92
  try:
@@ -98,8 +100,7 @@ async def rem_grp(e):
98
 
99
 
100
  async def open_grp():
101
- chats = night_grps()
102
- for chat in chats:
103
  try:
104
  await ultroid_bot(
105
  EditChatDefaultBannedRightsRequest(
@@ -122,11 +123,10 @@ async def open_grp():
122
 
123
 
124
  async def close_grp():
125
- chats = night_grps()
126
- h1, m1, h2, m2 = 0, 0, 7, 0
127
  if udB.get_key("NIGHT_TIME"):
128
- h1, m1, h2, m2 = eval(udB.get_key("NIGHT_TIME"))
129
- for chat in chats:
130
  try:
131
  await ultroid_bot(
132
  EditChatDefaultBannedRightsRequest(
@@ -144,7 +144,7 @@ async def close_grp():
144
  LOGS.info(er)
145
 
146
 
147
- if AsyncIOScheduler and night_grps():
148
  try:
149
  h1, m1, h2, m2 = 0, 0, 7, 0
150
  if udB.get_key("NIGHT_TIME"):
 
40
  from telethon.tl.functions.messages import EditChatDefaultBannedRightsRequest
41
  from telethon.tl.types import ChatBannedRights
42
 
43
+ from pyUltroid.dB.base import KeyManager
44
 
45
  from . import get_string, udB, ultroid_bot, ultroid_cmd
46
 
47
+ keym = KeyManager("NIGHT_CHATS", cast=list)
48
+
49
 
50
  @ultroid_cmd(pattern="nmtime( (.*)|$)")
51
  async def set_time(e):
 
66
  async def add_grp(e):
67
  if pat := e.pattern_match.group(1).strip():
68
  try:
69
+ keym.add((await ultroid_bot.get_entity(pat)).id)
70
  return await e.eor(f"Done, Added {pat} To Night Mode.")
71
  except BaseException:
72
  return await e.eor(get_string("nightm_5"), time=5)
73
+ keym.add(e.chat_id)
74
  await e.eor(get_string("nightm_3"))
75
 
76
 
77
  @ultroid_cmd(pattern="remnm( (.*)|$)")
78
+ async def r_em_grp(e):
79
  if pat := e.pattern_match.group(1).strip():
80
  try:
81
+ keym.remove((await ultroid_bot.get_entity(pat)).id)
82
  return await e.eor(f"Done, Removed {pat} To Night Mode.")
83
  except BaseException:
84
  return await e.eor(get_string("nightm_5"), time=5)
85
+ keym.remove(e.chat_id)
86
  await e.eor(get_string("nightm_4"))
87
 
88
 
89
  @ultroid_cmd(pattern="listnm$")
90
  async def rem_grp(e):
91
+ chats = keym.get()
92
  name = "NightMode Groups Are-:\n\n"
93
  for x in chats:
94
  try:
 
100
 
101
 
102
  async def open_grp():
103
+ for chat in keym.get():
 
104
  try:
105
  await ultroid_bot(
106
  EditChatDefaultBannedRightsRequest(
 
123
 
124
 
125
  async def close_grp():
126
+ __, _, h2, m2 = 0, 0, 7, 0
 
127
  if udB.get_key("NIGHT_TIME"):
128
+ _, __, h2, m2 = eval(udB.get_key("NIGHT_TIME"))
129
+ for chat in keym.get():
130
  try:
131
  await ultroid_bot(
132
  EditChatDefaultBannedRightsRequest(
 
144
  LOGS.info(er)
145
 
146
 
147
+ if AsyncIOScheduler and keym.get():
148
  try:
149
  h1, m1, h2, m2 = 0, 0, 7, 0
150
  if udB.get_key("NIGHT_TIME"):
plugins/pdftools.py CHANGED
@@ -8,21 +8,22 @@
8
  ✘ Commands Available -
9
 
10
  • `{i}pdf <page num> <reply to pdf file>`
11
- Extract nd Send page as a Image.(note-: For Extraction all pages just use .pdf)
12
- You Can use multi pages too like `{i}pdf 1-7`
13
 
14
  • `{i}pdtext <page num> <reply to pdf file>`
15
  Extract Text From the Pdf.(note-: For Extraction all text just use .pdtext)
16
- You Can use multi pages too like `{i}pdf 1-7`
17
 
18
  • `{i}pdscan <reply to image>`
19
- It scan, crop nd send img as pdf.
20
 
21
  • `{i}pdsave <reply to image/pdf>`
22
- It scan, crop nd save file to merge u can merge many pages as a single pdf.
 
23
 
24
  • `{i}pdsend `
25
- Merge nd send the Pdf to collected from .pdsave.
26
  """
27
  import glob
28
  import os
 
8
  ✘ Commands Available -
9
 
10
  • `{i}pdf <page num> <reply to pdf file>`
11
+ Extract & send page as an Image.(note-: For extracting all pages, just use .pdf)
12
+ to upload selected range `{i}pdf 1-7`
13
 
14
  • `{i}pdtext <page num> <reply to pdf file>`
15
  Extract Text From the Pdf.(note-: For Extraction all text just use .pdtext)
16
+ to extract selected pages `{i}pdf 1-7`
17
 
18
  • `{i}pdscan <reply to image>`
19
+ It scan, crop & send image(s) as pdf.
20
 
21
  • `{i}pdsave <reply to image/pdf>`
22
+ It scan, crop & save file to merge.
23
+ you can merge many pages in a single pdf.
24
 
25
  • `{i}pdsend `
26
+ Merge & send the pdf, collected from .pdsave.
27
  """
28
  import glob
29
  import os
plugins/pmpermit.py CHANGED
@@ -43,8 +43,6 @@ import re
43
  from os import remove
44
 
45
  from pyUltroid.dB import DEVLIST
46
- from pyUltroid.dB.logusers_db import *
47
- from pyUltroid.dB.pmpermit_db import *
48
 
49
  try:
50
  from tabulate import tabulate
@@ -60,6 +58,8 @@ from telethon.tl.functions.contacts import (
60
  from telethon.tl.functions.messages import ReportSpamRequest
61
  from telethon.utils import get_display_name, resolve_bot_file_id
62
 
 
 
63
  from . import *
64
 
65
  # ========================= CONSTANTS =============================
@@ -68,6 +68,11 @@ COUNT_PM = {}
68
  LASTMSG = {}
69
  WARN_MSGS = {}
70
  U_WARNS = {}
 
 
 
 
 
71
  PMPIC = udB.get_key("PMPIC")
72
  LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
73
  UND = get_string("pmperm_1")
@@ -127,10 +132,10 @@ if udB.get_key("PMLOG"):
127
  async def _(e):
128
  if not e.is_private:
129
  return await e.eor("`Use me in Private.`", time=3)
130
- if not is_logger(e.chat_id):
131
  return await e.eor("`Wasn't logging msgs from here.`", time=3)
132
 
133
- nolog_user(e.chat_id)
134
  return await e.eor("`Now I Will log msgs from here.`", time=3)
135
 
136
  @ultroid_cmd(
@@ -139,10 +144,10 @@ if udB.get_key("PMLOG"):
139
  async def _(e):
140
  if not e.is_private:
141
  return await e.eor("`Use me in Private.`", time=3)
142
- if is_logger(e.chat_id):
143
  return await e.eor("`Wasn't logging msgs from here.`", time=3)
144
 
145
- log_user(e.chat_id)
146
  return await e.eor("`Now I Won't log msgs from here.`", time=3)
147
 
148
  @ultroid_bot.on(
@@ -153,7 +158,7 @@ if udB.get_key("PMLOG"):
153
  )
154
  async def permitpm(event):
155
  user = await event.get_sender()
156
- if user.bot or user.is_self or user.verified or is_logger(user.id):
157
  return
158
  await event.forward_to(udB.get_key("PMLOGGROUP") or LOG_CHANNEL)
159
 
@@ -171,9 +176,9 @@ if udB.get_key("PMSETTING"):
171
  miss = await e.get_chat()
172
  if miss.bot or miss.is_self or miss.verified or miss.id in DEVLIST:
173
  return
174
- if is_approved(miss.id):
175
  return
176
- approve_user(miss.id)
177
  await delete_pm_warn_msgs(miss.id)
178
  try:
179
  await ultroid_bot.edit_folder(miss.id, folder=0)
@@ -209,7 +214,7 @@ if udB.get_key("PMSETTING"):
209
  async def permitpm(event):
210
  inline_pm = Redis("INLINE_PM") or False
211
  user = event.sender
212
- if not is_approved(user.id) and event.text != UND:
213
  if Redis("MOVE_ARCHIVE"):
214
  try:
215
  await ultroid_bot.edit_folder(user.id, folder=1)
@@ -221,11 +226,11 @@ if udB.get_key("PMSETTING"):
221
  fullname = get_display_name(user)
222
  username = f"@{user.username}"
223
  mention = inline_mention(user)
224
- count = len(get_approved())
225
  try:
226
  wrn = COUNT_PM[user.id] + 1
227
  await asst.edit_message(
228
- int(udB.get_key("LOG_CHANNEL")),
229
  _not_approved[user.id],
230
  f"Incoming PM from **{mention}** [`{user.id}`] with **{wrn}/{WARNS}** warning!",
231
  buttons=[
@@ -235,7 +240,7 @@ if udB.get_key("PMSETTING"):
235
  )
236
  except KeyError:
237
  _not_approved[user.id] = await asst.send_message(
238
- int(udB.get_key("LOG_CHANNEL")),
239
  f"Incoming PM from **{mention}** [`{user.id}`] with **1/{WARNS}** warning!",
240
  buttons=[
241
  Button.inline("Approve PM", data=f"approve_{user.id}"),
@@ -366,14 +371,14 @@ if udB.get_key("PMSETTING"):
366
  del LASTMSG[user.id]
367
  except KeyError:
368
  await asst.send_message(
369
- int(udB.get_key("LOG_CHANNEL")),
370
  "PMPermit is messed! Pls restart the bot!!",
371
  )
372
  return LOGS.info("COUNT_PM is messed.")
373
  await ultroid_bot(BlockRequest(user.id))
374
  await ultroid_bot(ReportSpamRequest(peer=user.id))
375
  await asst.edit_message(
376
- int(udB.get_key("LOG_CHANNEL")),
377
  _not_approved[user.id],
378
  f"**{mention}** [`{user.id}`] was Blocked for spamming.",
379
  )
@@ -407,8 +412,8 @@ if udB.get_key("PMSETTING"):
407
  apprvpm,
408
  "Lol, He is my Developer\nHe is auto Approved",
409
  )
410
- if not is_approved(user.id):
411
- approve_user(user.id)
412
  try:
413
  await delete_pm_warn_msgs(user.id)
414
  await apprvpm.client.edit_folder(user.id, folder=0)
@@ -421,7 +426,7 @@ if udB.get_key("PMSETTING"):
421
  )
422
  try:
423
  await asst.edit_message(
424
- int(udB.get_key("LOG_CHANNEL")),
425
  _not_approved[user.id],
426
  f"#APPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was approved to PM you!</code>",
427
  buttons=[
@@ -432,7 +437,7 @@ if udB.get_key("PMSETTING"):
432
  )
433
  except KeyError:
434
  _not_approved[user.id] = await asst.send_message(
435
- int(udB.get_key("LOG_CHANNEL")),
436
  f"#APPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was approved to PM you!</code>",
437
  buttons=[
438
  Button.inline("Disapprove PM", data=f"disapprove_{user.id}"),
@@ -458,8 +463,8 @@ if udB.get_key("PMSETTING"):
458
  e,
459
  "`Lol, He is my Developer\nHe Can't Be DisApproved.`",
460
  )
461
- if is_approved(user.id):
462
- disapprove_user(user.id)
463
  await eod(
464
  e,
465
  f"<b>{inline_mention(user, html=True)}</b> <code>Disapproved to PM!</code>",
@@ -467,7 +472,7 @@ if udB.get_key("PMSETTING"):
467
  )
468
  try:
469
  await asst.edit_message(
470
- int(udB.get_key("LOG_CHANNEL")),
471
  _not_approved[user.id],
472
  f"#DISAPPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was disapproved to PM you.</code>",
473
  buttons=[
@@ -478,7 +483,7 @@ if udB.get_key("PMSETTING"):
478
  )
479
  except KeyError:
480
  _not_approved[user.id] = await asst.send_message(
481
- int(udB.get_key("LOG_CHANNEL")),
482
  f"#DISAPPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was disapproved to PM you.</code>",
483
  buttons=[
484
  Button.inline("Approve PM", data=f"approve_{user.id}"),
@@ -515,12 +520,12 @@ async def blockpm(block):
515
  aname = await block.client.get_entity(user)
516
  await block.eor(f"{inline_mention(aname)} [`{user}`] `has been blocked!`")
517
  try:
518
- disapprove_user(user)
519
  except AttributeError:
520
  pass
521
  try:
522
  await asst.edit_message(
523
- int(udB.get_key("LOG_CHANNEL")),
524
  _not_approved[user],
525
  f"#BLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **blocked**.",
526
  buttons=[
@@ -529,7 +534,7 @@ async def blockpm(block):
529
  )
530
  except KeyError:
531
  _not_approved[user] = await asst.send_message(
532
- int(udB.get_key("LOG_CHANNEL")),
533
  f"#BLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **blocked**.",
534
  buttons=[
535
  Button.inline("UnBlock", data=f"unblock_{user}"),
@@ -604,7 +609,7 @@ async def unblockpm(event):
604
  @ultroid_cmd(pattern="listapproved$", owner=True)
605
  async def list_approved(event):
606
  xx = await event.eor(get_string("com_1"))
607
- all = get_approved()
608
  if not all:
609
  return await xx.eor("`You haven't approved anyone yet!`", time=5)
610
  users = []
@@ -641,8 +646,8 @@ async def apr_in(event):
641
  uid = int(event.data_match.group(1).decode("UTF-8"))
642
  if uid in DEVLIST:
643
  await event.edit("It's a dev! Approved!")
644
- if not is_approved(uid):
645
- approve_user(uid)
646
  try:
647
  await ultroid_bot.edit_folder(uid, folder=0)
648
  except BaseException:
@@ -683,8 +688,8 @@ async def apr_in(event):
683
  )
684
  async def disapr_in(event):
685
  uid = int(event.data_match.group(1).decode("UTF-8"))
686
- if is_approved(uid):
687
- disapprove_user(uid)
688
  try:
689
  user = await ultroid_bot.get_entity(uid)
690
  except BaseException:
 
43
  from os import remove
44
 
45
  from pyUltroid.dB import DEVLIST
 
 
46
 
47
  try:
48
  from tabulate import tabulate
 
58
  from telethon.tl.functions.messages import ReportSpamRequest
59
  from telethon.utils import get_display_name, resolve_bot_file_id
60
 
61
+ from pyUltroid.dB.base import KeyManager
62
+
63
  from . import *
64
 
65
  # ========================= CONSTANTS =============================
 
68
  LASTMSG = {}
69
  WARN_MSGS = {}
70
  U_WARNS = {}
71
+ if isinstance(udB.get_key("PMPERMIT"), (int, str)):
72
+ value = [udB.get_key("PMPERMIT")]
73
+ udB.set_key("PMPERMIT", value)
74
+ keym = KeyManager("PMPERMIT", cast=list)
75
+ Logm = KeyManager("LOGUSERS", cast=list)
76
  PMPIC = udB.get_key("PMPIC")
77
  LOG_CHANNEL = udB.get_key("LOG_CHANNEL")
78
  UND = get_string("pmperm_1")
 
132
  async def _(e):
133
  if not e.is_private:
134
  return await e.eor("`Use me in Private.`", time=3)
135
+ if not Logm.contains(e.chat_id):
136
  return await e.eor("`Wasn't logging msgs from here.`", time=3)
137
 
138
+ Logm.remove(e.chat_id)
139
  return await e.eor("`Now I Will log msgs from here.`", time=3)
140
 
141
  @ultroid_cmd(
 
144
  async def _(e):
145
  if not e.is_private:
146
  return await e.eor("`Use me in Private.`", time=3)
147
+ if Logm.contains(e.chat_id):
148
  return await e.eor("`Wasn't logging msgs from here.`", time=3)
149
 
150
+ Logm.add(e.chat_id)
151
  return await e.eor("`Now I Won't log msgs from here.`", time=3)
152
 
153
  @ultroid_bot.on(
 
158
  )
159
  async def permitpm(event):
160
  user = await event.get_sender()
161
+ if user.bot or user.is_self or user.verified or Logm.contains(user.id):
162
  return
163
  await event.forward_to(udB.get_key("PMLOGGROUP") or LOG_CHANNEL)
164
 
 
176
  miss = await e.get_chat()
177
  if miss.bot or miss.is_self or miss.verified or miss.id in DEVLIST:
178
  return
179
+ if keym.contains(miss.id):
180
  return
181
+ keym.add(miss.id)
182
  await delete_pm_warn_msgs(miss.id)
183
  try:
184
  await ultroid_bot.edit_folder(miss.id, folder=0)
 
214
  async def permitpm(event):
215
  inline_pm = Redis("INLINE_PM") or False
216
  user = event.sender
217
+ if not keym.contains(user.id) and event.text != UND:
218
  if Redis("MOVE_ARCHIVE"):
219
  try:
220
  await ultroid_bot.edit_folder(user.id, folder=1)
 
226
  fullname = get_display_name(user)
227
  username = f"@{user.username}"
228
  mention = inline_mention(user)
229
+ count = keym.count()
230
  try:
231
  wrn = COUNT_PM[user.id] + 1
232
  await asst.edit_message(
233
+ udB.get_key("LOG_CHANNEL"),
234
  _not_approved[user.id],
235
  f"Incoming PM from **{mention}** [`{user.id}`] with **{wrn}/{WARNS}** warning!",
236
  buttons=[
 
240
  )
241
  except KeyError:
242
  _not_approved[user.id] = await asst.send_message(
243
+ udB.get_key("LOG_CHANNEL"),
244
  f"Incoming PM from **{mention}** [`{user.id}`] with **1/{WARNS}** warning!",
245
  buttons=[
246
  Button.inline("Approve PM", data=f"approve_{user.id}"),
 
371
  del LASTMSG[user.id]
372
  except KeyError:
373
  await asst.send_message(
374
+ udB.get_key("LOG_CHANNEL"),
375
  "PMPermit is messed! Pls restart the bot!!",
376
  )
377
  return LOGS.info("COUNT_PM is messed.")
378
  await ultroid_bot(BlockRequest(user.id))
379
  await ultroid_bot(ReportSpamRequest(peer=user.id))
380
  await asst.edit_message(
381
+ udB.get_key("LOG_CHANNEL"),
382
  _not_approved[user.id],
383
  f"**{mention}** [`{user.id}`] was Blocked for spamming.",
384
  )
 
412
  apprvpm,
413
  "Lol, He is my Developer\nHe is auto Approved",
414
  )
415
+ if not keym.contains(user.id):
416
+ keym.add(user.id)
417
  try:
418
  await delete_pm_warn_msgs(user.id)
419
  await apprvpm.client.edit_folder(user.id, folder=0)
 
426
  )
427
  try:
428
  await asst.edit_message(
429
+ udB.get_key("LOG_CHANNEL"),
430
  _not_approved[user.id],
431
  f"#APPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was approved to PM you!</code>",
432
  buttons=[
 
437
  )
438
  except KeyError:
439
  _not_approved[user.id] = await asst.send_message(
440
+ udB.get_key("LOG_CHANNEL"),
441
  f"#APPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was approved to PM you!</code>",
442
  buttons=[
443
  Button.inline("Disapprove PM", data=f"disapprove_{user.id}"),
 
463
  e,
464
  "`Lol, He is my Developer\nHe Can't Be DisApproved.`",
465
  )
466
+ if keym.contains(user.id):
467
+ keym.remove(user.id)
468
  await eod(
469
  e,
470
  f"<b>{inline_mention(user, html=True)}</b> <code>Disapproved to PM!</code>",
 
472
  )
473
  try:
474
  await asst.edit_message(
475
+ udB.get_key("LOG_CHANNEL"),
476
  _not_approved[user.id],
477
  f"#DISAPPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was disapproved to PM you.</code>",
478
  buttons=[
 
483
  )
484
  except KeyError:
485
  _not_approved[user.id] = await asst.send_message(
486
+ udB.get_key("LOG_CHANNEL"),
487
  f"#DISAPPROVED\n\n<b>{inline_mention(user, html=True)}</b> [<code>{user.id}</code>] <code>was disapproved to PM you.</code>",
488
  buttons=[
489
  Button.inline("Approve PM", data=f"approve_{user.id}"),
 
520
  aname = await block.client.get_entity(user)
521
  await block.eor(f"{inline_mention(aname)} [`{user}`] `has been blocked!`")
522
  try:
523
+ keym.remove(user)
524
  except AttributeError:
525
  pass
526
  try:
527
  await asst.edit_message(
528
+ udB.get_key("LOG_CHANNEL"),
529
  _not_approved[user],
530
  f"#BLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **blocked**.",
531
  buttons=[
 
534
  )
535
  except KeyError:
536
  _not_approved[user] = await asst.send_message(
537
+ udB.get_key("LOG_CHANNEL"),
538
  f"#BLOCKED\n\n{inline_mention(aname)} [`{user}`] has been **blocked**.",
539
  buttons=[
540
  Button.inline("UnBlock", data=f"unblock_{user}"),
 
609
  @ultroid_cmd(pattern="listapproved$", owner=True)
610
  async def list_approved(event):
611
  xx = await event.eor(get_string("com_1"))
612
+ all = keym.get()
613
  if not all:
614
  return await xx.eor("`You haven't approved anyone yet!`", time=5)
615
  users = []
 
646
  uid = int(event.data_match.group(1).decode("UTF-8"))
647
  if uid in DEVLIST:
648
  await event.edit("It's a dev! Approved!")
649
+ if not keym.contains(uid):
650
+ keym.add(uid)
651
  try:
652
  await ultroid_bot.edit_folder(uid, folder=0)
653
  except BaseException:
 
688
  )
689
  async def disapr_in(event):
690
  uid = int(event.data_match.group(1).decode("UTF-8"))
691
+ if keym.contains(uid):
692
+ keym.remove(uid)
693
  try:
694
  user = await ultroid_bot.get_entity(uid)
695
  except BaseException:
plugins/polls.py CHANGED
@@ -58,9 +58,8 @@ async def uri_poll(e):
58
  return await e.eor("`Options Should be More than 1..`", time=5)
59
  m = await e.eor(get_string("com_1"))
60
  OUT = [PollAnswer(option[on], str(on).encode()) for on in range(len(option))]
61
- await e.client.send_file(
62
- e.chat_id,
63
- InputMediaPoll(
64
  Poll(20, ques, OUT, multiple_choice=mpp, public_voters=publ, quiz=quizo),
65
  correct_answers=karzo,
66
  ),
 
58
  return await e.eor("`Options Should be More than 1..`", time=5)
59
  m = await e.eor(get_string("com_1"))
60
  OUT = [PollAnswer(option[on], str(on).encode()) for on in range(len(option))]
61
+ await e.respond(
62
+ file=InputMediaPoll(
 
63
  Poll(20, ques, OUT, multiple_choice=mpp, public_voters=publ, quiz=quizo),
64
  correct_answers=karzo,
65
  ),
plugins/profanityfilter.py CHANGED
@@ -20,13 +20,13 @@ from pyUltroid.dB.nsfw_db import profan_chat, rem_profan
20
  from . import get_string, ultroid_cmd
21
 
22
 
23
- @ultroid_cmd(pattern="addprofanity$", admins_only=True)
24
  async def addp(e):
25
- profan_chat(e.chat_id, "mute")
26
- await e.eor(get_string("prof_1"), time=10)
27
-
28
-
29
- @ultroid_cmd(pattern="remprofanity", admins_only=True)
30
- async def remp(e):
31
  rem_profan(e.chat_id)
32
  await e.eor(get_string("prof_2"), time=10)
 
20
  from . import get_string, ultroid_cmd
21
 
22
 
23
+ @ultroid_cmd(pattern="(add|rem)profanity$", admins_only=True)
24
  async def addp(e):
25
+ cas = e.pattern_match.group(1)
26
+ add = cas == "add"
27
+ if add:
28
+ profan_chat(e.chat_id, "mute")
29
+ await e.eor(get_string("prof_1"), time=10)
30
+ return
31
  rem_profan(e.chat_id)
32
  await e.eor(get_string("prof_2"), time=10)
plugins/profile.py CHANGED
@@ -19,7 +19,10 @@
19
  • `{i}delpfp <n>(optional)`
20
  Delete one profile pic, if no value given, else delete n number of pics.
21
 
22
- • `{i}poto <username>`
 
 
 
23
  Upload the photo of Chat/User if Available.
24
  """
25
  import os
@@ -51,8 +54,7 @@ async def _(ult):
51
  @ultroid_cmd(pattern="setname ?((.|//)*)", fullsudo=True)
52
  async def _(ult):
53
  ok = await ult.eor("...")
54
- names = ult.pattern_match.group(1).strip()
55
- first_name = names
56
  last_name = ""
57
  if "//" in names:
58
  first_name, last_name = names.split("//", 1)
@@ -111,21 +113,56 @@ async def remove_profilepic(delpfp):
111
  @ultroid_cmd(pattern="poto( (.*)|$)")
112
  async def gpoto(e):
113
  ult = e.pattern_match.group(1).strip()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  a = await e.eor(get_string("com_1"))
 
 
115
  just_dl = ult in ["-dl", "--dl"]
116
  if just_dl:
117
  ult = None
118
- if not ult:
119
- if e.is_reply:
120
- gs = await e.get_reply_message()
121
- ult = gs.sender_id
122
- else:
123
- ult = e.chat_id
124
- okla = await e.client.download_profile_photo(ult)
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  if not okla:
126
  return await eor(a, "`Pfp Not Found...`")
127
  if not just_dl:
128
  await a.delete()
129
  await e.reply(file=okla)
130
- return os.remove(okla)
 
 
 
 
 
 
131
  await a.edit(f"Downloaded pfp to [ `{okla}` ].")
 
19
  • `{i}delpfp <n>(optional)`
20
  Delete one profile pic, if no value given, else delete n number of pics.
21
 
22
+ • `{i}poto <username>/reply`
23
+ `{i}poto <reply/upload-limit>/all`
24
+
25
+ Ex: `{i}poto 10` - uploads starting 10 pfps of user.
26
  Upload the photo of Chat/User if Available.
27
  """
28
  import os
 
54
  @ultroid_cmd(pattern="setname ?((.|//)*)", fullsudo=True)
55
  async def _(ult):
56
  ok = await ult.eor("...")
57
+ names = first_name = ult.pattern_match.group(1).strip()
 
58
  last_name = ""
59
  if "//" in names:
60
  first_name, last_name = names.split("//", 1)
 
113
  @ultroid_cmd(pattern="poto( (.*)|$)")
114
  async def gpoto(e):
115
  ult = e.pattern_match.group(1).strip()
116
+
117
+ if e.is_reply:
118
+ gs = await e.get_reply_message()
119
+ user_id = gs.sender_id
120
+ elif ult:
121
+ split = ult.split()
122
+ user_id = split[0]
123
+ if len(ult) > 1:
124
+ ult = ult[-1]
125
+ else:
126
+ ult = None
127
+ else:
128
+ user_id = e.chat_id
129
+
130
  a = await e.eor(get_string("com_1"))
131
+ limit = None
132
+
133
  just_dl = ult in ["-dl", "--dl"]
134
  if just_dl:
135
  ult = None
136
+
137
+ if ult and ult != "all":
138
+ try:
139
+ limit = int(ult)
140
+ except ValueError:
141
+ pass
142
+
143
+ if not limit or e.client._bot:
144
+ okla = await e.client.download_profile_photo(user_id)
145
+ else:
146
+ okla = []
147
+ if limit == "all":
148
+ limit = None
149
+ async for photo in e.client.iter_profile_photos(user_id, limit=limit):
150
+ photo_path = await e.client.download_media(photo)
151
+ if photo.video_sizes:
152
+ await e.respond(file=photo_path)
153
+ os.remove(photo_path)
154
+ else:
155
+ okla.append(photo_path)
156
  if not okla:
157
  return await eor(a, "`Pfp Not Found...`")
158
  if not just_dl:
159
  await a.delete()
160
  await e.reply(file=okla)
161
+ if not isinstance(okla, list):
162
+ okla = [okla]
163
+ for file in okla:
164
+ os.remove(file)
165
+ return
166
+ if isinstance(okla, list):
167
+ okla = "\n".join(okla)
168
  await a.edit(f"Downloaded pfp to [ `{okla}` ].")
plugins/qrcode.py CHANGED
@@ -28,7 +28,6 @@ except ImportError:
28
  import qrcode
29
  from PIL import Image
30
  from telethon.tl.types import MessageMediaDocument as doc
31
- from telethon.tl.types import MessageMediaPhoto as photu
32
 
33
  from . import check_filename, get_string, ultroid_bot, ultroid_cmd
34
 
@@ -70,11 +69,10 @@ async def cd(e):
70
  async def qrwater(e):
71
  msg = e.pattern_match.group(1).strip()
72
  r = await e.get_reply_message()
73
- if isinstance(r.media, photu):
74
- dl = await e.client.download_media(r.media)
75
- elif isinstance(r.media, doc):
76
- dl = await e.client.download_media(r, thumb=-1)
77
- else:
78
  return await e.eor("`Reply Any Media and Give Text`", time=5)
79
  kk = await e.eor(get_string("com_1"))
80
  img_bg = Image.open(dl)
@@ -96,11 +94,10 @@ async def decod(e):
96
  if not (r and r.media):
97
  return await e.eor("`Reply to Qrcode Media`", time=5)
98
  kk = await e.eor(get_string("com_1"))
99
- if isinstance(r.media, photu):
100
- dl = await r.download_media()
101
- elif isinstance(r.media, doc):
102
- dl = await r.download_media(thumb=-1)
103
- else:
104
  return
105
  im = cv2.imread(dl)
106
  try:
 
28
  import qrcode
29
  from PIL import Image
30
  from telethon.tl.types import MessageMediaDocument as doc
 
31
 
32
  from . import check_filename, get_string, ultroid_bot, ultroid_cmd
33
 
 
69
  async def qrwater(e):
70
  msg = e.pattern_match.group(1).strip()
71
  r = await e.get_reply_message()
72
+ dl = await e.client.download_media(
73
+ r, thumb=-1 if isinstance(r.media, doc) else None
74
+ )
75
+ if not dl:
 
76
  return await e.eor("`Reply Any Media and Give Text`", time=5)
77
  kk = await e.eor(get_string("com_1"))
78
  img_bg = Image.open(dl)
 
94
  if not (r and r.media):
95
  return await e.eor("`Reply to Qrcode Media`", time=5)
96
  kk = await e.eor(get_string("com_1"))
97
+ dl = await e.client.download_media(
98
+ r, thumb=-1 if isinstance(r.media, doc) else None
99
+ )
100
+ if not dl:
 
101
  return
102
  im = cv2.imread(dl)
103
  try:
plugins/resize.py CHANGED
@@ -36,7 +36,7 @@ async def size(e):
36
 
37
 
38
  @ultroid_cmd(pattern="resize( (.*)|$)")
39
- async def size(e):
40
  r = await e.get_reply_message()
41
  if not (r and r.media):
42
  return await e.eor(get_string("ascii_1"))
 
36
 
37
 
38
  @ultroid_cmd(pattern="resize( (.*)|$)")
39
+ async def resize(e):
40
  r = await e.get_reply_message()
41
  if not (r and r.media):
42
  return await e.eor(get_string("ascii_1"))
plugins/schedulemsg.py CHANGED
@@ -34,20 +34,18 @@ async def _(e):
34
  else:
35
  try:
36
  z = ban_time(y)
37
- await e.client.send_message(e.chat_id, k, schedule=z)
38
  await e.eor(get_string("schdl_1"), time=5)
39
  except BaseException:
40
  await e.eor(get_string("schdl_2"), time=5)
41
  elif xx and x:
42
  if x.isdigit():
43
- await e.client.send_message(
44
- e.chat_id, xx, schedule=timedelta(seconds=int(x))
45
- )
46
  await e.eor(get_string("schdl_1"), time=5)
47
  else:
48
  try:
49
  z = ban_time(x)
50
- await e.client.send_message(e.chat_id, xx, schedule=z)
51
  await e.eor(get_string("schdl_1"), time=5)
52
  except BaseException:
53
  await e.eor(get_string("schdl_2"), time=5)
 
34
  else:
35
  try:
36
  z = ban_time(y)
37
+ await e.respond(k, schedule=z)
38
  await e.eor(get_string("schdl_1"), time=5)
39
  except BaseException:
40
  await e.eor(get_string("schdl_2"), time=5)
41
  elif xx and x:
42
  if x.isdigit():
43
+ await e.respond(xx, schedule=timedelta(seconds=int(x)))
 
 
44
  await e.eor(get_string("schdl_1"), time=5)
45
  else:
46
  try:
47
  z = ban_time(x)
48
+ await e.respond(xx, schedule=z)
49
  await e.eor(get_string("schdl_1"), time=5)
50
  except BaseException:
51
  await e.eor(get_string("schdl_2"), time=5)
plugins/search.py CHANGED
@@ -24,7 +24,6 @@
24
  Reply an Image or sticker to find its sauce.
25
  """
26
  import os
27
- from shutil import rmtree
28
 
29
  import requests
30
  from bs4 import BeautifulSoup as bs
@@ -39,11 +38,10 @@ except ImportError:
39
  cv2 = None
40
  from telethon.tl.types import DocumentAttributeAudio
41
 
42
- from pyUltroid.fns.google_image import googleimagesdownload
43
  from pyUltroid.fns.misc import google_search
44
- from pyUltroid.fns.tools import saavn_search
45
 
46
- from . import async_searcher, con, eod, fast_download, get_string, ultroid_cmd
47
 
48
 
49
  @ultroid_cmd(
@@ -122,20 +120,12 @@ async def goimg(event):
122
  query = query.split(";")[0]
123
  except BaseException:
124
  pass
125
- try:
126
- gi = googleimagesdownload()
127
- args = {
128
- "keywords": query,
129
- "limit": lmt,
130
- "format": "jpg",
131
- "output_directory": "./resources/downloads/",
132
- }
133
- pth = await gi.download(args)
134
- ok = pth[0][query]
135
- except BaseException:
136
- return await nn.edit(get_string("autopic_2").format(query))
137
- await event.reply(file=ok, message=query)
138
- rmtree(f"./resources/downloads/{query}/")
139
  await nn.delete()
140
 
141
 
@@ -168,22 +158,16 @@ async def reverse(event):
168
  link = alls["href"]
169
  text = alls.text
170
  await ult.edit(f"`Dimension ~ {x} : {y}`\nSauce ~ [{text}](google.com{link})")
171
- gi = googleimagesdownload()
172
- args = {
173
- "keywords": text,
174
- "limit": 2,
175
- "format": "jpg",
176
- "output_directory": "./resources/downloads/",
177
- }
178
- pth = await gi.download(args)
179
- ok = pth[0][text]
180
- await event.client.send_file(
181
- event.chat_id,
182
- ok,
183
- album=True,
184
- caption="Similar Images Realted to Search",
185
- )
186
- rmtree(f"./resources/downloads/{text}/")
187
  os.remove(file)
188
 
189
 
 
24
  Reply an Image or sticker to find its sauce.
25
  """
26
  import os
 
27
 
28
  import requests
29
  from bs4 import BeautifulSoup as bs
 
38
  cv2 = None
39
  from telethon.tl.types import DocumentAttributeAudio
40
 
 
41
  from pyUltroid.fns.misc import google_search
42
+ from pyUltroid.fns.tools import get_google_images, saavn_search
43
 
44
+ from . import LOGS, async_searcher, con, eod, fast_download, get_string, ultroid_cmd
45
 
46
 
47
  @ultroid_cmd(
 
120
  query = query.split(";")[0]
121
  except BaseException:
122
  pass
123
+ images = await get_google_images(query)
124
+ for img in images[:lmt]:
125
+ try:
126
+ await event.client.send_file(event.chat_id, file=img["original"])
127
+ except Exception as er:
128
+ LOGS.exception(er)
 
 
 
 
 
 
 
 
129
  await nn.delete()
130
 
131
 
 
158
  link = alls["href"]
159
  text = alls.text
160
  await ult.edit(f"`Dimension ~ {x} : {y}`\nSauce ~ [{text}](google.com{link})")
161
+ images = await get_google_images(text)
162
+ for z in images[:2]:
163
+ try:
164
+ await event.client.send_file(
165
+ event.chat_id,
166
+ file=z["original"],
167
+ caption="Similar Images Realted to Search",
168
+ )
169
+ except Exception as er:
170
+ LOGS.exception(er)
 
 
 
 
 
 
171
  os.remove(file)
172
 
173
 
plugins/snips.py CHANGED
@@ -88,9 +88,8 @@ async def rs(e):
88
  async def lsnote(e):
89
  if x := list_snip():
90
  sd = "SNIPS Found :\n\n"
91
- await e.eor(sd + x)
92
- else:
93
- await e.eor("No Snips Found Here")
94
 
95
 
96
  async def add_snips(e):
 
88
  async def lsnote(e):
89
  if x := list_snip():
90
  sd = "SNIPS Found :\n\n"
91
+ return await e.eor(sd + x)
92
+ await e.eor("No Snips Found Here")
 
93
 
94
 
95
  async def add_snips(e):
plugins/specialtools.py CHANGED
@@ -35,14 +35,12 @@ import os
35
  import time
36
  from datetime import datetime as dt
37
  from random import choice
38
- from shutil import rmtree
39
 
40
  import pytz
41
  from bs4 import BeautifulSoup as bs
42
  from telethon.tl.types import DocumentAttributeVideo
43
 
44
- from pyUltroid.fns.google_image import googleimagesdownload
45
- from pyUltroid.fns.tools import metadata
46
 
47
  from . import (
48
  HNDLR,
@@ -284,17 +282,9 @@ async def wall(event):
284
  return await event.eor("`Give me something to search..`")
285
  nn = await event.eor(get_string("com_1"))
286
  query = f"hd {inp}"
287
- gi = googleimagesdownload()
288
- args = {
289
- "keywords": query,
290
- "limit": 10,
291
- "format": "jpg",
292
- "output_directory": "./resources/downloads/",
293
- }
294
- await gi.download(args)
295
- xx = choice(os.listdir(os.path.abspath(f"./resources/downloads/{query}/")))
296
- await event.client.send_file(event.chat_id, f"./resources/downloads/{query}/{xx}")
297
- rmtree(f"./resources/downloads/{query}/")
298
  await nn.delete()
299
 
300
 
 
35
  import time
36
  from datetime import datetime as dt
37
  from random import choice
 
38
 
39
  import pytz
40
  from bs4 import BeautifulSoup as bs
41
  from telethon.tl.types import DocumentAttributeVideo
42
 
43
+ from pyUltroid.fns.tools import get_google_images, metadata
 
44
 
45
  from . import (
46
  HNDLR,
 
282
  return await event.eor("`Give me something to search..`")
283
  nn = await event.eor(get_string("com_1"))
284
  query = f"hd {inp}"
285
+ images = await get_google_images(query)
286
+ for z in range(5):
287
+ await event.client.send_file(event.chat_id, file=images[z]["original"])
 
 
 
 
 
 
 
 
288
  await nn.delete()
289
 
290
 
plugins/tools.py CHANGED
@@ -39,6 +39,7 @@
39
  import glob
40
  import io
41
  import os
 
42
  from asyncio.exceptions import TimeoutError as AsyncTimeout
43
 
44
  try:
@@ -46,10 +47,15 @@ try:
46
  except ImportError:
47
  cv2 = None
48
 
 
 
 
 
49
  try:
50
  from htmlwebshot import WebShot
51
  except ImportError:
52
  WebShot = None
 
53
  from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
54
  from telethon.tl.types import (
55
  ChannelParticipantAdmin,
@@ -67,12 +73,12 @@ from . import (
67
  bash,
68
  check_filename,
69
  con,
 
70
  eor,
71
- fast_download,
72
  get_string,
73
  )
74
  from . import humanbytes as hb
75
- from . import inline_mention, is_url_ok, mediainfo, ultroid_cmd
76
 
77
 
78
  @ultroid_cmd(pattern="tr( (.*)|$)", manager=True)
@@ -337,16 +343,16 @@ async def _(e):
337
  )
338
  async def lastname(steal):
339
  mat = steal.pattern_match.group(1).strip()
340
- if not steal.is_reply and not mat:
341
- return await steal.eor("`Use this command with reply or give Username/id...`")
342
  if mat:
343
  try:
344
  user_id = await steal.client.parse_id(mat)
345
  except ValueError:
346
  user_id = mat
347
- message = await steal.get_reply_message()
348
- if message:
349
- user_id = message.sender.id
 
350
  chat = "@SangMataInfo_bot"
351
  id = f"/search_id {user_id}"
352
  lol = await steal.eor(get_string("com_1"))
@@ -389,20 +395,37 @@ async def webss(event):
389
  xurl = event.pattern_match.group(1).strip()
390
  if not xurl:
391
  return await xx.eor(get_string("wbs_1"), time=5)
392
- if not is_url_ok(xurl):
393
  return await xx.eor(get_string("wbs_2"), time=5)
394
- try:
395
- shot = WebShot(
396
- quality=88, flags=["--enable-javascript", "--no-stop-slow-scripts"]
397
- )
398
- pic = await shot.create_pic_async(url=xurl)
399
- except FileNotFoundError:
400
- pic = (
401
- await fast_download(
402
- f"https://shot.screenshotapi.net/screenshot?&url={xurl}&output=image&file_type=png&wait_for_event=load",
403
- filename=check_filename("shot.png"),
 
 
 
 
 
 
404
  )
405
- )[0]
 
 
 
 
 
 
 
 
 
 
 
406
  if pic:
407
  await xx.reply(
408
  get_string("wbs_3").format(xurl),
@@ -420,12 +443,10 @@ async def magic(event):
420
  match = event.text.split(maxsplit=1)[1].strip()
421
  except IndexError:
422
  return await event.eor("`Provide url to turn into tiny...`")
423
- match, id_ = match.split(), None
424
- data = {}
425
- if len(match) > 1:
426
- data["id"] = match[1]
427
- url = match[0]
428
- data["link"] = url
429
  data = await async_searcher(
430
  "https://tiny.ultroid.tech/api/new",
431
  data=data,
 
39
  import glob
40
  import io
41
  import os
42
+ import secrets
43
  from asyncio.exceptions import TimeoutError as AsyncTimeout
44
 
45
  try:
 
47
  except ImportError:
48
  cv2 = None
49
 
50
+ try:
51
+ from playwright.async_api import async_playwright
52
+ except ImportError:
53
+ async_playwright = None
54
  try:
55
  from htmlwebshot import WebShot
56
  except ImportError:
57
  WebShot = None
58
+
59
  from telethon.errors.rpcerrorlist import MessageTooLongError, YouBlockedUserError
60
  from telethon.tl.types import (
61
  ChannelParticipantAdmin,
 
73
  bash,
74
  check_filename,
75
  con,
76
+ download_file,
77
  eor,
 
78
  get_string,
79
  )
80
  from . import humanbytes as hb
81
+ from . import inline_mention, is_url_ok, json_parser, mediainfo, ultroid_cmd
82
 
83
 
84
  @ultroid_cmd(pattern="tr( (.*)|$)", manager=True)
 
343
  )
344
  async def lastname(steal):
345
  mat = steal.pattern_match.group(1).strip()
346
+ message = await steal.get_reply_message()
 
347
  if mat:
348
  try:
349
  user_id = await steal.client.parse_id(mat)
350
  except ValueError:
351
  user_id = mat
352
+ elif message:
353
+ user_id = message.sender_id
354
+ else:
355
+ return await steal.eor("`Use this command with reply or give Username/id...`")
356
  chat = "@SangMataInfo_bot"
357
  id = f"/search_id {user_id}"
358
  lol = await steal.eor(get_string("com_1"))
 
395
  xurl = event.pattern_match.group(1).strip()
396
  if not xurl:
397
  return await xx.eor(get_string("wbs_1"), time=5)
398
+ if not (await is_url_ok(xurl)):
399
  return await xx.eor(get_string("wbs_2"), time=5)
400
+ path, pic = check_filename("shot.png"), None
401
+ if async_playwright:
402
+ try:
403
+ async with async_playwright() as playwright:
404
+ chrome = await playwright.chromium.launch()
405
+ page = await chrome.new_page()
406
+ await page.goto(xurl)
407
+ await page.screenshot(path=path, full_page=True)
408
+ pic = path
409
+ except Exception as er:
410
+ LOGS.exception(er)
411
+ await xx.respond(f"Error with playwright:\n`{er}`")
412
+ if WebShot and not pic:
413
+ try:
414
+ shot = WebShot(
415
+ quality=88, flags=["--enable-javascript", "--no-stop-slow-scripts"]
416
  )
417
+ pic = await shot.create_pic_async(url=xurl)
418
+ except Exception as er:
419
+ LOGS.exception(er)
420
+ if not pic:
421
+ pic, msg = await download_file(
422
+ f"https://shot.screenshotapi.net/screenshot?&url={xurl}&output=image&file_type=png&wait_for_event=load",
423
+ path,
424
+ validate=True,
425
+ )
426
+ if msg:
427
+ await xx.edit(json_parser(msg, indent=1))
428
+ return
429
  if pic:
430
  await xx.reply(
431
  get_string("wbs_3").format(xurl),
 
443
  match = event.text.split(maxsplit=1)[1].strip()
444
  except IndexError:
445
  return await event.eor("`Provide url to turn into tiny...`")
446
+ data = {
447
+ "url": match.split()[0],
448
+ "id": match[1] if len(match) > 1 else secrets.token_urlsafe(6),
449
+ }
 
 
450
  data = await async_searcher(
451
  "https://tiny.ultroid.tech/api/new",
452
  data=data,