This bot is just like @bing but using Google Images as backend
-
Go to https://console.developers.google.com and make a new project.
-
Go to
Library
, enableCustom Search API
and make a new credential using the button you will be prompted -
Copy your API key
[CSE_KEY]
-
From the Google Custom Search homepage ( http://www.google.com/cse/ ), click Create a Custom Search Engine.
-
Type a name and description for your search engine.
-
Under Define your search engine, in the Sites to Search box, enter at least one valid URL (For now, just put www.anyurl.com to get past this screen. More on this later ).
-
Select the CSE edition you want and accept the Terms of Service, then click Next. Select the layout option you want, and then click Next.
-
Click any of the links under the Next steps section to navigate to your Control panel.
-
In the left-hand menu, under Control Panel, click Basics.
-
In the Search Preferences section, select Search the entire web but emphasize included sites.
-
Click Save Changes.
-
In the left-hand menu, under Control Panel, click Sites.
-
Delete the site you entered during the initial setup process.
-
Copy your
Search engine ID
using the button for this purpose[CSE_CX]
.
- Talk to @botfather using your Telegram account and he will give you your fresh new API key.
[API_TOKEN]
- Copy your bot nickname
[BOT_NAME]
. - This is that easy
I deploy my Telegram bots using Heroku, so this part will be based on this service but you can use any other if you know how to deploy a webapp using Flask
- Make a new Heroku app and copy its URL
[WEBHOOK_URL]
- Copy the
config_example.py
file toconfig.py
and place there all the vars you copied from previous steps:[BOT_NAME, CSE_KEY, CSE_CX, API_TOKEN, BATCH, WEBHOOK_URL]
- Add this file to the repo:
git add config.py
- You will have to add all the Heroku related files:
app.json
,Procfile
,Procfile.windows
- Add them:
git add app.json Procfile Procfile.windows
- Commit and push it:
git commit -am "This is a push" && git push heroku master
- Done!
When you deploy on Heroku you must change POLLING=True
to POLLING=False
in config.py
. POLLING=True
is meant for development.
You can change BATCH=10
in config.py
. This number means how much images the bot will send when someone ask for images and each time that someone pulls the image grid (on the Telegram app)