Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit 6cb526c

Browse files
committed
userbot: cleanup
1 parent f6b1a7b commit 6cb526c

File tree

2 files changed

+67
-44
lines changed

2 files changed

+67
-44
lines changed

userbot/modules/gimages.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
""" Userbot module for searching Image with CSE Google,
2+
please setup your own CSE"""
3+
4+
import os
5+
import shutil
6+
7+
from userbot import CMD_HELP, GCS_DEVELOPER_KEY, GCS_CX
8+
from userbot.events import register
9+
from google_images_search import GoogleImagesSearch
10+
11+
@register(outgoing=True, pattern="^.gimg (.*)")
12+
async def gis_search(event):
13+
""" .srcimg command will search and download only"""
14+
await event.edit("Please wait..")
15+
q = event.pattern_match.group(1)
16+
num = findall(r"num=\d+", q)
17+
try:
18+
num = num[0]
19+
num = num.replace("num=" "")
20+
q = q.replace("num=" + n[0], "")
21+
except IndexError:
22+
num = 5
23+
response = google_images_search.GoogleImagesSearch()
24+
25+
# if you don't enter api key and cx, the package will try to search
26+
# them from environment variables GCS_DEVELOPER_KEY and GCS_CX
27+
28+
gis = GoogleImagesSearch(GCS_DEVELOPER_KEY, GCS_CX)
29+
30+
#define search params:
31+
_search_params = {
32+
'q': '...',
33+
'num': 1-10,
34+
'safe': 'high|medium|off',
35+
'fileType': 'jpg|gif|png',
36+
'imgType': 'clipart|face|lineart|news|photo',
37+
'imgSize': 'huge|icon|large|medium|small|xlarge|xxlarge',
38+
'imgDominantColor': 'black|blue|brown|gray|green|pink|purple|teal|white|yellow'
39+
}
40+
41+
gis.search(search_params=_search_params, path_to_dir='./downloads/')
42+
43+
# argument list
44+
arguments = {
45+
"keywords": q,
46+
"limit": num,
47+
"filetype": "jpg",
48+
"path": "./downloads/"
49+
}
50+
51+
# passing arguments to the function
52+
paths = response.download(arguments)
53+
lst = paths[0][q]
54+
await event.client.send_file(
55+
await event.client.get_input_entity(event.chat.id), lst)
56+
shutil.rmtree(os.path.dirname(os.path.abspath(lst[0]))
57+
)
58+
await event.delete()
59+
60+
CMD_HELP.update({
61+
"googleimgsrc":
62+
".gimg <query>\
63+
\nusage: search and download images from your customsearch engine"
64+
})

userbot/modules/misc.py

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -73,41 +73,10 @@ async def killdabot(event):
7373
# Shut the existing one down
7474
exit()
7575

76-
77-
@register(outgoing=True, pattern="^.community$")
78-
async def bot_community(community):
79-
""" For .community command, just returns OG Paperplane's group link. """
80-
await community.edit(
81-
"Join RaphielGang's awesome userbot community: @userbot_support"
82-
"\nDo note that Paperplane Extended is an unoficial fork of their "
83-
"Paperplane project and it may get limited or no support for bugs.")
84-
85-
86-
@register(outgoing=True, pattern="^.support$")
87-
async def bot_support(wannahelp):
88-
""" For .support command, just returns the group link. """
89-
await wannahelp.edit(
90-
"Join the OpenUserBot Channel: @PaperPlaneExtended_news \
91-
\nJoin the OpenUserBot Chat: @PPE_Support")
92-
93-
9476
@register(outgoing=True, pattern="^.creator$")
9577
async def creator(e):
96-
await e.edit("[TeKnoways](https://t.me/Three_Cube_TeKnoways)")
97-
98-
99-
@register(outgoing=True, pattern="^.readme$")
100-
async def reedme(e):
101-
await e.edit(
102-
"Here's something for you to read:\n"
103-
"\n[OpenUserBot's README.md file](https://github.com/mkaraniya/OpenUserBot/blob/sql-extended/README.md)"
104-
"\n[Setup Guide - Basic](https://telegra.ph/How-to-host-a-Telegram-Userbot-11-02)"
105-
"\n[Setup Guide - Google Drive](https://telegra.ph/How-To-Setup-GDrive-11-02)"
106-
"\n[Setup Guide - LastFM Module](https://telegra.ph/How-to-set-up-LastFM-module-for-Paperplane-userbot-11-02)"
107-
"\n[Video Tutorial - 576p](https://mega.nz/#!ErwCESbJ!1ZvYAKdTEfb6y1FnqqiLhHH9vZg4UB2QZNYL9fbQ9vs)"
108-
"\n[Video Tutorial - 1080p](https://mega.nz/#!x3JVhYwR!u7Uj0nvD8_CyyARrdKrFqlZEBFTnSVEiqts36HBMr-o)"
109-
"\n[Special - Note](https://telegra.ph/Special-Note-11-02)")
110-
78+
await e.edit("[Nobody]")
79+
11180

11281
# Copyright (c) Gegham Zakaryan | 2019
11382
@register(outgoing=True, pattern="^.repeat (.*)")
@@ -128,7 +97,7 @@ async def repeat(rep):
12897
async def repo_is_here(wannasee):
12998
""" For .repo command, just returns the repo URL. """
13099
await wannasee.edit(
131-
"Click [here](https://github.com/mkaraniya/OpenUserBot) to open OpenUserBot's GitHub page."
100+
"Click [here](https://github.com/goodmeow/OpenUbot) to open Bot's GitHub page."
132101
)
133102

134103

@@ -175,16 +144,6 @@ async def raw(event):
175144
hear Windows XP shutdown sound... but you don't."
176145
})
177146

178-
CMD_HELP.update(
179-
{'support': ".support\
180-
\nUsage: If you need help, use this command."})
181-
182-
CMD_HELP.update({
183-
'community':
184-
".community\
185-
\nUsage: Join the awesome Paperplane userbot community !!"
186-
})
187-
188147
CMD_HELP.update({
189148
'repo':
190149
'.repo\

0 commit comments

Comments
 (0)