Skip to content

Commit

Permalink
revert DB_URI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy1709 committed Aug 27, 2024
1 parent a9f77e5 commit 648458f
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 115 deletions.
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
version: '3.3'

services:
app:
app:
container_name: cat
build:
context: .
dockerfile: Dockerfile
command: python3 -m userbot
restart: on-failure
environment:
- DB_URI=postgresql://postgres:postgres@db/catuserbot
- DATABASE_URL=postgresql://postgres:postgres@db/catuserbot
depends_on:
- db

db:
db:
image: postgres
restart: always
environment:
Expand All @@ -34,3 +34,6 @@ services:
volumes:
db:
driver: local
botdata:
driver: local

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ cinemagoer
cloudscraper
colour
cowpy
c-telethon
emoji==1.7.0
fonttools
geopy
Expand Down Expand Up @@ -59,6 +58,7 @@ wand
wget

git+https://github.com/Jisan09/search-engine-parser
git+https://github.com/Jisan09/Telethon@test
git+https://github.com/goldsmith/Wikipedia
git+https://github.com/sandy1709/py-googletrans
git+https://github.com/alexmercerind/youtube-search-python
Expand Down
2 changes: 1 addition & 1 deletion sample_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Config(object):
APP_ID = int(os.environ.get("APP_ID", 6))
API_HASH = os.environ.get("API_HASH") or None
# Datbase url heroku sets it automatically else get this from elephantsql
DB_URI = os.environ.get("DB_URI", None)
DB_URI = os.environ.get("DATABASE_URL", None)
# Get this value by running python3 stringsetup.py or https://repl.it/@sandeep1709/generatestringsession
STRING_SESSION = os.environ.get("STRING_SESSION", None)
# Telegram BOT Token and bot username from @BotFather
Expand Down
220 changes: 110 additions & 110 deletions userbot/plugins/google.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Reverse search image and Google search """
"""Reverse search image and Google search"""

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# CatUserBot #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Copyright (C) 2020-2023 by TgCatUB@Github.
Expand Down Expand Up @@ -27,6 +27,115 @@
plugin_category = "tools"


@catub.cat_cmd(
pattern="gs ([\s\S]*)",
command=("gs", plugin_category),
info={
"header": "Google search command.",
"flags": {
"-l": "for number of search results.",
"-p": "for choosing which page results should be showed.",
},
"usage": [
"{tr}gs <flags> <query>",
"{tr}gs <query>",
],
"examples": [
"{tr}gs catuserbot",
"{tr}gs -l6 catuserbot",
"{tr}gs -p2 catuserbot",
"{tr}gs -p2 -l7 catuserbot",
],
},
)
async def gsearch(q_event):
"Google search command."
catevent = await edit_or_reply(q_event, "`searching........`")
match = q_event.pattern_match.group(1)
page = re.findall(r"-p\d+", match)
lim = re.findall(r"-l\d+", match)
try:
page = page[0]
page = page.replace("-p", "")
match = match.replace(f"-p{page}", "")
except IndexError:
page = 1
try:
lim = lim[0]
lim = lim.replace("-l", "")
match = match.replace(f"-l{lim}", "")
lim = int(lim)
if lim <= 0:
lim = 5
except IndexError:
lim = 5
# smatch = urllib.parse.quote_plus(match)
smatch = match.replace(" ", "+")
search_args = str(smatch), page
gsearch = GoogleSearch()
bsearch = BingSearch()
ysearch = YahooSearch()
try:
gresults = await gsearch.async_search(*search_args)
except NoResultsOrTrafficError:
try:
gresults = await bsearch.async_search(*search_args)
except NoResultsOrTrafficError:
try:
gresults = await ysearch.async_search(*search_args)
except Exception as e:
return await edit_delete(catevent, f"**Error:**\n`{e}`", time=10)
msg = ""
for i in range(lim):
if i > len(gresults["links"]):
break
try:
title = gresults["titles"][i]
link = gresults["links"][i]
desc = gresults["descriptions"][i]
msg += f"👉[{title}]({link})\n`{desc}`\n\n"
except IndexError:
break
await edit_or_reply(
catevent,
"**Search Query:**\n`" + match + "`\n\n**Results:**\n" + msg,
link_preview=False,
aslink=True,
linktext=f"**The search results for the query **__{match}__ **are** :",
)
if BOTLOG:
await q_event.client.send_message(
BOTLOG_CHATID,
f"Google Search query `{match}` was executed successfully",
)


@catub.cat_cmd(
pattern="gis ([\s\S]*)",
command=("gis", plugin_category),
info={
"header": "Google search in image format",
"usage": "{tr}gis <query>",
"examples": "{tr}gis cat",
},
)
async def gis(event):
"To search in google and send result in picture."


@catub.cat_cmd(
pattern="grs$",
command=("grs", plugin_category),
info={
"header": "Google reverse search command.",
"description": "Reverse search replied media in google and shows results.",
"usage": "{tr}grs",
},
)
async def grs(event):
"Google Reverse Search"


@catub.cat_cmd(
pattern="(grs|reverse)(?:\s|$)([\s\S]*)",
command=("reverse", plugin_category),
Expand Down Expand Up @@ -145,112 +254,3 @@ async def google_search(event):
results = await event.client.inline_query("@StickerizerBot", query)
await results[0].click(event.chat_id, reply_to=reply_to_id, hide_via=True)
await event.delete()


@catub.cat_cmd(
pattern="gs ([\s\S]*)",
command=("gs", plugin_category),
info={
"header": "Google search command.",
"flags": {
"-l": "for number of search results.",
"-p": "for choosing which page results should be showed.",
},
"usage": [
"{tr}gs <flags> <query>",
"{tr}gs <query>",
],
"examples": [
"{tr}gs catuserbot",
"{tr}gs -l6 catuserbot",
"{tr}gs -p2 catuserbot",
"{tr}gs -p2 -l7 catuserbot",
],
},
)
async def gsearch(q_event):
"Google search command."
catevent = await edit_or_reply(q_event, "`searching........`")
match = q_event.pattern_match.group(1)
page = re.findall(r"-p\d+", match)
lim = re.findall(r"-l\d+", match)
try:
page = page[0]
page = page.replace("-p", "")
match = match.replace(f"-p{page}", "")
except IndexError:
page = 1
try:
lim = lim[0]
lim = lim.replace("-l", "")
match = match.replace(f"-l{lim}", "")
lim = int(lim)
if lim <= 0:
lim = 5
except IndexError:
lim = 5
# smatch = urllib.parse.quote_plus(match)
smatch = match.replace(" ", "+")
search_args = str(smatch), page
gsearch = GoogleSearch()
bsearch = BingSearch()
ysearch = YahooSearch()
try:
gresults = await gsearch.async_search(*search_args)
except NoResultsOrTrafficError:
try:
gresults = await bsearch.async_search(*search_args)
except NoResultsOrTrafficError:
try:
gresults = await ysearch.async_search(*search_args)
except Exception as e:
return await edit_delete(catevent, f"**Error:**\n`{e}`", time=10)
msg = ""
for i in range(lim):
if i > len(gresults["links"]):
break
try:
title = gresults["titles"][i]
link = gresults["links"][i]
desc = gresults["descriptions"][i]
msg += f"👉[{title}]({link})\n`{desc}`\n\n"
except IndexError:
break
await edit_or_reply(
catevent,
"**Search Query:**\n`" + match + "`\n\n**Results:**\n" + msg,
link_preview=False,
aslink=True,
linktext=f"**The search results for the query **__{match}__ **are** :",
)
if BOTLOG:
await q_event.client.send_message(
BOTLOG_CHATID,
f"Google Search query `{match}` was executed successfully",
)


@catub.cat_cmd(
pattern="gis ([\s\S]*)",
command=("gis", plugin_category),
info={
"header": "Google search in image format",
"usage": "{tr}gis <query>",
"examples": "{tr}gis cat",
},
)
async def gis(event):
"To search in google and send result in picture."


@catub.cat_cmd(
pattern="grs$",
command=("grs", plugin_category),
info={
"header": "Google reverse search command.",
"description": "Reverse search replied media in google and shows results.",
"usage": "{tr}grs",
},
)
async def grs(event):
"Google Reverse Search"

0 comments on commit 648458f

Please sign in to comment.