|
| 1 | +# Moon-Userbot - telegram userbot |
| 2 | +# Copyright (C) 2020-present Moon Userbot Organization |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | + |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | + |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | + |
| 18 | +from pyrogram import Client, filters |
| 19 | +from pyrogram.types import Message |
| 20 | + |
| 21 | +from utils.misc import modules_help, prefix |
| 22 | +from utils.scripts import import_library |
| 23 | + |
| 24 | +import_library("apksearch") |
| 25 | + |
| 26 | +from apksearch import APKPure, APKMirror, AppTeka, APKCombo, APKFab |
| 27 | + |
| 28 | + |
| 29 | +def search_apkmirror(query: str) -> str: |
| 30 | + apkmirror = APKMirror(query) |
| 31 | + result = apkmirror.search_apk() |
| 32 | + if result: |
| 33 | + title, apk_link = result |
| 34 | + return f"<b>{title}</b>:{apk_link}" |
| 35 | + return "<code>No results found</code>" |
| 36 | + |
| 37 | + |
| 38 | +def search_apkpure(query: str) -> str: |
| 39 | + apkpure = APKPure(query) |
| 40 | + result = apkpure.search_apk() |
| 41 | + if result: |
| 42 | + title, apk_link = result |
| 43 | + return f"<b>{title}</b>:{apk_link}" |
| 44 | + return "<code>No results found</code>" |
| 45 | + |
| 46 | + |
| 47 | +def search_appteka(query: str) -> str: |
| 48 | + appteka = AppTeka(query) |
| 49 | + result = appteka.search_apk() |
| 50 | + if result: |
| 51 | + title, apk_link = result |
| 52 | + return f"<b>{title}</b>:{apk_link}" |
| 53 | + return "<code>No results found</code>" |
| 54 | + |
| 55 | + |
| 56 | +def search_apkcombo(query: str) -> str: |
| 57 | + apkcombo = APKCombo(query) |
| 58 | + result = apkcombo.search_apk() |
| 59 | + if result: |
| 60 | + title, apk_link = result |
| 61 | + return f"<b>{title}</b>:{apk_link}" |
| 62 | + return "<code>No results found</code>" |
| 63 | + |
| 64 | + |
| 65 | +def search_apkfab(query: str) -> str: |
| 66 | + apkfab = APKFab(query) |
| 67 | + result = apkfab.search_apk() |
| 68 | + if result: |
| 69 | + title, apk_link = result |
| 70 | + return f"<b>{title}</b>:{apk_link}" |
| 71 | + return "<code>No results found</code>" |
| 72 | + |
| 73 | + |
| 74 | +def apksearch(query: str) -> str: |
| 75 | + apkmirror_result = search_apkmirror(query) |
| 76 | + apkpure_result = search_apkpure(query) |
| 77 | + appteka_result = search_appteka(query) |
| 78 | + apkcombo_result = search_apkcombo(query) |
| 79 | + apkfab_result = search_apkfab(query) |
| 80 | + results = [ |
| 81 | + apkmirror_result, |
| 82 | + apkpure_result, |
| 83 | + appteka_result, |
| 84 | + apkcombo_result, |
| 85 | + apkfab_result, |
| 86 | + ] |
| 87 | + return "\n\n".join(results) |
| 88 | + |
| 89 | + |
| 90 | +@Client.on_message(filters.command("apkmirror", prefix) & filters.me) |
| 91 | +async def apkmirror(_, message: Message): |
| 92 | + if len(message.command) < 2: |
| 93 | + return await message.edit("<code>No query provided</code>") |
| 94 | + query = message.text.split(maxsplit=1)[1] |
| 95 | + result = search_apkmirror(query) |
| 96 | + await message.edit_text(result, disable_web_page_preview=True) |
| 97 | + |
| 98 | + |
| 99 | +@Client.on_message(filters.command("apkpure", prefix) & filters.me) |
| 100 | +async def apkpure(_, message: Message): |
| 101 | + if len(message.command) > 2: |
| 102 | + return await message.edit("<code>No query provided</code>") |
| 103 | + query = message.text.split(maxsplit=1)[1] |
| 104 | + result = search_apkpure(query) |
| 105 | + await message.edit_text(result, disable_web_page_preview=True) |
| 106 | + |
| 107 | + |
| 108 | +@Client.on_message(filters.command("apkcombo", prefix) & filters.me) |
| 109 | +async def apkcombo(_, message: Message): |
| 110 | + if len(message.command) > 2: |
| 111 | + return await message.edit("<code>No query provided</code>") |
| 112 | + query = message.text.split(maxsplit=1)[1] |
| 113 | + result = search_apkcombo(query) |
| 114 | + await message.edit_text(result, disable_web_page_preview=True) |
| 115 | + |
| 116 | + |
| 117 | +@Client.on_message(filters.command("apkfab", prefix) & filters.me) |
| 118 | +async def apkfab(_, message: Message): |
| 119 | + if len(message.command) > 2: |
| 120 | + return await message.edit("<code>No query provided</code>") |
| 121 | + query = message.text.split(maxsplit=1)[1] |
| 122 | + result = search_apkfab(query) |
| 123 | + await message.edit_text(result, disable_web_page_preview=True) |
| 124 | + |
| 125 | + |
| 126 | +@Client.on_message(filters.command("appteka", prefix) & filters.me) |
| 127 | +async def appteka(_, message: Message): |
| 128 | + if len(message.command) > 2: |
| 129 | + return await message.edit("<code>No query provided</code>") |
| 130 | + query = message.text.split(maxsplit=1)[1] |
| 131 | + result = search_appteka(query) |
| 132 | + await message.edit_text(result, disable_web_page_preview=True) |
| 133 | + |
| 134 | + |
| 135 | +@Client.on_message(filters.command("apksearch", prefix) & filters.me) |
| 136 | +async def apks(_, message: Message): |
| 137 | + if len(message.command) > 2: |
| 138 | + return await message.edit("<code>No query provided</code>") |
| 139 | + query = message.text.split(maxsplit=1)[1] |
| 140 | + result = apksearch(query) |
| 141 | + await message.edit_text(result, disable_web_page_preview=True) |
| 142 | + |
| 143 | + |
| 144 | +modules_help["apksearch"] = { |
| 145 | + "apkmirror [package_name]*": "Search for an apk on apkmirror", |
| 146 | + "apkfab [package_name]*": "Search for an apk on apkfab", |
| 147 | + "appteka [package_name]*": "Search for an apk on appteka", |
| 148 | + "apksearch [package_name]*": "Search for an apk on apksearch", |
| 149 | + "apkpure [package_name]*": "Search for an apk on apkpure", |
| 150 | + "apksearch [package_name]*": "Search for an apk on all supported sources", |
| 151 | +} |
0 commit comments