Giter Club home page Giter Club logo

telebot's Introduction

telebot

Telegram Bot starter kit. Very easy to install with Google App Engine.

Reddit post: http://www.reddit.com/r/Telegram/comments/3b1pwl/create_your_own_telegram_bot_stepbystep/

Instructions

  1. Message @botfather https://telegram.me/botfather with the following text: /newbot If you don't know how to message by username, click the search field on your Telegram app and type @botfather, you should be able to initiate a conversation. Be careful not to send it to the wrong contact, because some users has similar usernames to botfather.

    botfather initial conversation

  2. @botfather replies with Alright, a new bot. How are we going to call it? Please choose a name for your bot.

  3. Type whatever name you want for your bot.

  4. @botfather replies with Good. Now let's choose a username for your bot. It must end in bot. Like this, for example: TetrisBot or tetris_bot.

  5. Type whatever username you want for your bot, minimum 5 characters, and must end with bot. For example: whateversamplebot

  6. @botfather replies with:

    Done! Congratulations on your new bot. You will find it at telegram.me/whateversamplebot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands.

    Use this token to access the HTTP API: 123456789:AAG90e14-0f8-40183D-18491dDE

    For a description of the Bot API, see this page: https://core.telegram.org/bots/api

  7. Note down the 'token' mentioned above.

  8. Type /setprivacy to @botfather.

    botfather later conversation

  9. @botfather replies with Choose a bot to change group messages settings.

  10. Type @whateversamplebot (change to the username you set at step 5 above, but start it with @)

  11. @botfather replies with

    'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username. 'Disable' - your bot will receive all messages that people send to groups. Current status is: ENABLED

  12. Type Disable to let your bot receive all messages sent to a group. This step is up to you actually.

  13. @botfather replies with Success! The new status is: DISABLED. /help

  14. Go to https://console.cloud.google.com/project

  15. Click Create Project

  16. Type the project name, whatever you want. For example: octopus-gorilla-123. Make sure the Project ID is also the same.

    App Engine registration

  17. Clone this repository. If you don't understand what I said, click the green Clone or download button on this page, click Download ZIP, and extract the ZIP file.

  18. Open app.yaml file using a good text editor like Sublime Text. Change the YOUR_APP_ID_HERE to the Project ID you set on step 16, and save the file.

app.yaml

  1. Open main.py file using a good text editor. Change the YOUR_BOT_TOKEN_HERE to the token you get from @botfather at step 6, and save the file.

main.py

  1. Download Google App Engine SDK for Python from https://cloud.google.com/appengine/downloads and install it.

  2. Run the GoogleAppEngineLauncher application.

  3. Click the File menu, choose Add Existing Application... and browse to the folder with the app.yaml and main.py file.

  4. The project ID should appear as a row at the Name column.

    app engine launcher

  5. Click Deploy, enter your Google credentials, and your app should be installed to Google's servers.

  6. Open your browser and go to https://project-id.appspot.com/me (replace project-id with the Project ID you set on step 16).

  7. Wait until you see a long text with "ok": true and your bot's name. This could take a minute or so, please reload if it does not succeed.

  8. Now, go to https://project-id.appspot.com/set_webhook?url=https://project-id.appspot.com/webhook (replace both project-ids with the Project ID you set on step 16).

  9. You should see Webhook was set.

  10. Open your Telegram client and send the message /start to your bot. (type @your-bot-username at the search field to initiate the conversation)

  11. You can, for example, send what time to the bot and the bot will reply you. Try sending /image as well. Mission completed!

To customize the bot, edit the main.py starting from the CUSTOMIZE FROM HERE line. They are simple if-else statements.

telebot's People

Contributors

adtc avatar tsangiotis avatar yukuku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telebot's Issues

Group Response

In normal and supper groups:
On /setprivacy Enabled - bot only responds to "/"(/start and /stop) commands and not to @username commands - no log pulls trough.

On /setprivacy Disabled - bot responds to all messages even if not tagged or "/" command used. - logs to server.

All messages in private gets handled correctly.

Send a picture of my pc?

Hi
How can I send a picture of my pc?
for example: C:\Users\Nicolson21\Downloads\2015-11-09_00002.jpg

Custom keyboard

Hi there, thanks a lot for the starter-kit!

Do you have any idea gow to use ReplyKeyboardMarkup in your example to create custom keyborads within the bot resopnses?

Thanks a lot in advance!

How to restart this bot for a new user?

Thanks a lot for your bot! I cant solve one problem. When I test my bot by myself everything fine, but if another user connect with my bot script doesnt start for him with initial state of variables. For example, in this code script increment x variable when user send "1". But for new user x already not null. Please help me to fix it. Every user who connect to bot have to start work with script like no other users, and the script is the first time for him with initial state e.g. x=0.

import StringIO
import json
import logging
import random
import urllib
import urllib2

# for sending images
from PIL import Image
import multipart

# standard app engine imports
from google.appengine.api import urlfetch
from google.appengine.ext import ndb
import webapp2

TOKEN = 'TOKEN HERE'

BASE_URL = 'https://api.telegram.org/bot' + TOKEN + '/'

x = 0

# ================================

class EnableStatus(ndb.Model):
# key name: str(chat_id)
enabled = ndb.BooleanProperty(indexed=False, default=False)


# ================================

def setEnabled(chat_id, yes):
es = EnableStatus.get_or_insert(str(chat_id))
es.enabled = yes
es.put()

def getEnabled(chat_id):
es = EnableStatus.get_by_id(str(chat_id))
if es:
    return es.enabled
return False


# ================================

class MeHandler(webapp2.RequestHandler):
def get(self):
    urlfetch.set_default_fetch_deadline(60)
    self.response.write(json.dumps(json.load(urllib2.urlopen(BASE_URL + 'getMe'))))


class GetUpdatesHandler(webapp2.RequestHandler):
def get(self):
    urlfetch.set_default_fetch_deadline(60)
    self.response.write(json.dumps(json.load(urllib2.urlopen(BASE_URL + 'getUpdates'))))


class SetWebhookHandler(webapp2.RequestHandler):
def get(self):
    urlfetch.set_default_fetch_deadline(60)
    url = self.request.get('url')
    if url:
        self.response.write(json.dumps(json.load(urllib2.urlopen(BASE_URL + 'setWebhook', urllib.urlencode({'url': url})))))


class WebhookHandler(webapp2.RequestHandler):
def post(self):
    urlfetch.set_default_fetch_deadline(60)
    body = json.loads(self.request.body)
    logging.info('request body:')
    logging.info(body)
    self.response.write(json.dumps(body))

    update_id = body['update_id']
    message = body['message']
    message_id = message.get('message_id')
    date = message.get('date')
    text = message.get('text')
    fr = message.get('from')
    chat = message['chat']
    chat_id = chat['id']

    if not text:
        logging.info('no text')
        return
    def reply(msg=None, img=None):
        if msg:
            resp = urllib2.urlopen(BASE_URL + 'sendMessage', urllib.urlencode({
                'chat_id': str(chat_id),
                'text': msg.encode('utf-8'),
                'disable_web_page_preview': 'true',
                #'reply_to_message_id': str(message_id),
            })).read()
        elif img:
            resp = multipart.post_multipart(BASE_URL + 'sendPhoto', [
                ('chat_id', str(chat_id)),
                #('reply_to_message_id', str(message_id)),
            ], [
                ('photo', 'image.jpg', img),
            ])
        else:
            logging.error('no msg or img specified')
            resp = None

        logging.info('send response:')
        logging.info(resp)

    if text.startswith('/'):
        if text == '/start':
            reply('Bot start')
            setEnabled(chat_id, True)
        elif text == '/stop':
            reply('Bot disabled')
            setEnabled(chat_id, False)
        else:
            reply('What command?')

    elif '1' in text:
        global x
        x = x + 1
        reply(str(x))
    else:
        if getEnabled(chat_id):
            reply('?')
        else:
            logging.info('not enabled for chat_id {}'.format(chat_id))


app = webapp2.WSGIApplication([
('/me', MeHandler),
('/updates', GetUpdatesHandler),
('/set_webhook', SetWebhookHandler),
('/webhook', WebhookHandler),
], debug=True)`

Google Image Search API

I am trying to integrate Google Image Search API under the /image section. How do I read the user's next input for search after the user enters /image in telegram?

Don't speak in groups

Hello again,

my bot works perfectly in private chat, but not in groups.

Why?

Thank You.

Not responding

Hi, I followed all steps successfully but when I type /start nothing happens...

What can it be?

Tnx

NO JSON object could be decoded.

Hi, After many tries with your codes I encountered this issue.

From the GAE Logs:

No JSON object could be decoded
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in call
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in call
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in call
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(_args, _kwargs)
* File "/base/data/home/apps/s~fango-bot/1.390834458736047060/main.py", line 168, in post
resp1 = json.load(urllib2.urlopen('http://www.simsimi.com/requestChat?lc=en&ft=1.0&req=' + urllib.quote_plus(text.encode('utf-8'))))

File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/init.py", line 290, in load
**kw)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/init.py", line 338, in loads
return _default_decoder.decode(s)
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/decoder.py", line 383, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

I thought it could depend from Simsimi no more responding, so I tried with a Trial Key but It doesnt work.
Any idea how to fix it?

Thank you in advance.

Webhook

hey . i did everthing just as you said but when i want to set webhook get the following error
"Error: Forbidden
Your client does not have permission to get URL /set_webhook?url=https://_my id_.appspot.com/webhook from this server."
whats the problem?

WebHook Issue

Trying to set up the webhook and I keep getting the folowing SyntaxError. I am new to this so I would appericate any help. Up to this point I have had no problems. Thanks!

Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = import(path[0])
File "/base/data/home/apps/s~fantasy-football-bot-1036/1.386410096399007800/main.py", line 17
TOKEN = bot/112638032:AAE1LmXpOEG8pxDE69qgKTxk-iPvZj9iu-M
^
SyntaxError: invalid syntax

Markdown Parse Mode

Telegram Bot API now supports Markdown on sendMessage method.

It can be used by adding 'parse_mode': 'Markdown' to reply {if msg} definition or by creating a new reply class (replyMarkdown for example) with the Markdown parse mode included.
Choosing the second option implies calling replyMarkdown(str(markdown_formated_message)) instead of reply(str(non_markdown_formated_message)).

send image, videos.

Hi, I have my bot working by now, but the thing is it can only send text. I have seen in the Bot API there are functions to send phots, videos... but I can't get it to work. Someone has achieved it?
plzz need help

deploy problem

When i try to deploy i get this, What can i do about it?

2016-04-02 04:40:19,269 ERROR appcfg.py:2396 An error occurred processing file '': HTTP Error 403: Forbidden Unexpected HTTP status 403. Aborting. 
Error 403: --- begin server output ---
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 403 (Forbidden)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>403.</b> <ins>That’s an error.</ins>
  <p>Your client does not have permission to get URL <code>/api/appversion/getresourcelimits</code> from this server.  <ins>That’s all we know.</ins>
--- end server output ---
2016-04-02 04:40:19 (Process exited with code 1)

You can close this window now.

deploy error

when I try to deply it I get this:

WARNING util.py:134 new_request() takes at most 1 positional argument (6 given)

Load image from web

Hi. I have a question about images.
How I can change the behavior of telebot if I want to load an image from the web? I have a JSON source [{"image": "mediafiles/00002.jpg", "id": 002}].

I've tried to change the behavior of the chat function (simsimi.com/requestChat) but it doesn't work.

Thanks in advance.

"A request to the Telegram API was unsuccessful"

Hello,

Sometimes I got this error message :

2015-10-11 17:48:12,169 (__init__.py:159) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 502 Bad Gateway. Response body:
[<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.9.1</center>
</body>
</html>
]"

I'm using the update_listener like that :

tg_bot.set_update_listener(self.on_messages)
tg_bot.polling()

def on_message():
    for message in messages:
        # ...
        tg_bot.send_message(message.chat.id, '')

I've seen that this kind of error is due to telegram server itself but is it possible ton make a way that we can handle these exceptions ?

Thanks :)

Feature: External csv file with custom responses?

Would it be possible to configure an external csv file with 2 values on each line:
First value is the text the bot should search in user message
second value is the response of the bot.
This will make it easy to configure the responses on the fly.
is such option possible? And would we be able to edit the file in google apps or we need to edit it offline and then use the gapps sdk to upload the app again?

Simsimi

Simsimi its no more working.
Any workround ?

How to use in pythonanywhere

Hi Yukuku.

The first, thank you for this project.

Can you explain how use pythonanywhere for this bot?

Thank you.

reply_markup

Hey, I'm trying to build a full class to wrap up the new bot API (at https://github.com/fopina/py-tgbot) and just stumbled in your example but it seems you haven't tried to use any custom keyboards with sendMessage reply_markup.
I can use the custom keyboard as long as I don't specify any extra options, otherwise it seems the whole object is ignored..
Have you used it (outside this github repo)?

reply('\r\n')

Hello,
if I try to send a CR+LF using replay ... it say HTTP 400, bad request.

Any help will be appreciated.
Ty.

Internal Server Error

I follow your steps untill deploying to appengine and i got a message like this :

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~digital-mutabaah/1.385654266843284493/main.py", line 48, in get
    self.response.write(json.dumps(json.load(urllib2.urlopen(BASE_URL + 'getMe'))))
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

unicode utf-8

elif 'what time' in text:
reply('look at the top-right corner of your screen!')

i want bot reply arabic text

like this

reply('اهلا بكم')

error when i select dploy

hi guys

i have a problem when i want to select deploy

this error appear

2017-01-05 11:07:44 Running command: "['C:\Python27\python2.7.exe', '-u', 'C:\Program Files (x86)\Google\google_appengine\appcfg.py', '--oauth2_credential_file=C:\Users\Shahab/.appcfg_oauth2_tokens', 'update', 'C:\Users\Shahab\Desktop\telebot-master\telebot-master']"
11:07 AM Application: mohsentestshaina; version: 1
11:07 AM Host: appengine.google.com
11:07 AM Starting update of app: mohsentestshaina, version: 1
11:07 AM Getting current resource limits.
2017-01-05 11:09:15,250 ERROR appcfg.py:2411 An error occurred processing file '': [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. Aborting.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 133, in
run_file(file, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 129, in run_file
execfile(PATHS.script_file(script_name), globals)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 5497, in
main(sys.argv)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 5488, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2966, in Run
self.action(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 5144, in call
return method()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3876, in Update
self._UpdateWithParsedAppYaml(appyaml, self.basepath)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3929, in _UpdateWithParsedAppYaml
self.UpdateVersion(rpcserver, basepath, appyaml, APP_YAML_FILENAME)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3814, in UpdateVersion
return appversion.DoUpload(paths, openfunc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2401, in DoUpload
self.error_fh)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 497, in GetResourceLimits
resource_limits.update(_GetRemoteResourceLimits(logging_context))
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 467, in GetRemoteResourceLimits
yaml_data = logging_context.Send('/api/appversion/getresourcelimits')
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 1709, in Send
result = self.rpcserver.Send(url, payload=payload, **kwargs)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc_httplib2.py", line 246, in Send
url, method=method, body=payload, headers=headers)
File "C:\Program Files (x86)\Google\google_appengine\lib\httplib2\httplib2_init
.py", line 1584, in request
(response, content) = self.request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\Program Files (x86)\Google\google_appengine\lib\httplib2\httplib2_init
.py", line 1332, in _request
(response, content) = self.conn_request(conn, request_uri, method, body, headers)
File "C:\Program Files (x86)\Google\google_appengine\lib\httplib2\httplib2_init
.py", line 1306, in conn_request
conn.connect()
File "C:\Program Files (x86)\Google\google_appengine\lib\httplib2\httplib2_init
.py", line 1053, in connect
raise socket.error, msg
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
2017-01-05 11:09:15 (Process exited with code 1)

You can close this window now.

Supporting language question

Thanks to the auther of this bot, it is seems as really a great opportuninty fo thouse who little dummy.
I try to redisign telobot to make a @gamegurubot, which will be an outdoor game expert. The idea is quite simple, suppose we have a group of people having a free time, one of them may type to the bot something like: /play 5, outdoor, running. What will be recognized by bot as: group of 5 people, wonna spend their free time outside, playing something active like tag or freezbe. So bot will respond with a set of games best relevates with the request, choosing one, user will get the description and some media, or maybe map with the best nearest places to begin.
i've collected games desctiptions mainly in russian, and for the first version i need bot to understand and responds in Russian. For begin i try to change basic answer for "what time" with something russian and it returns nothing, i added unicode supporting at a comment at the top of the main.py file and deploy again but the respond was still empty. Have you any guesses how to add a multilanguage suppurting, espessialy russian.

Improvements

After forking this project I have made a few improvements that I think should be in by default, e.g. markdown/HTML responses and better logging. I haven't opened a PR because I don't know if they would be accepted, being a "starter" kit, or if anyone who can merge changes is still active.

Write to all who opened the chat with my bot

Hi,
I want my bot to write after a command to all chat_id 's. How can I do this?

ex:
If I write: /writetoallusers test
All groups and people who started the chat with my bot (with /start) shall get the text: test

Send Stickers

I'm sorry I am new to all this and is there anyway i can send a sticker instead of just images/words.
I know how to reply with images and messages but do not know how to send a sticker.

Include some test features

It would be cool if you add some examples sending images, stickers, forwarding messages or videos.
Or if you have enough time, some kind of modules or plugins to extend the functionality of the bot.

help for a dummy...

well .. i have no idea on how to send you a msg.. or where ask for help about your project...
so sorry if i made something wrong .. writing this msg as issue!!!!

well.. i dont know anything about python... but i know something of php.. mysql.. and visual basic..
so.. i try to understand as best as i can...

well.. right now .. im not stil able to ANSWER...
for example :
/start

please select a feature from A , B, C ... at this point i cant grab the answer... and i cannot find a tutorial on how TO DO THAT...
i tried to do something like that.. but i (obviously) FAILED...
this is the "amazing" code i tried....

`import sys
import random
import traceback
import telepot
from telepot.delegate import per_chat_id, create_open

def handle(msg):
flavor = telepot.flavor(msg)
if flavor == 'normal':
content_type, chat_type, chat_id = telepot.glance(msg)
print 'Normal Message:', content_type, chat_type, chat_id
self.sender.sendMessage('MESSAGGIO DI TESTO NORMALE')

class Player(telepot.helper.ChatHandler):
def init(self, seed_tuple, timeout):
super(Player, self).init(seed_tuple, timeout)
self._answer = int('6594')

def open(self, initial_msg, seed):
self.sender.sendMessage('Dimmi il tuo pin')
return True

def on_chat_message(self, msg):
content_type, chat_type, chat_id = telepot.glance(msg)

try:
   guess = int(msg['text'])
except ValueError:
    self.sender.sendMessage('Scusa.. mi aspetto un pin numerico...')
    return

# check the guess against the answer ...
if guess != self._answer:
    self.sender.sendMessage('Pin errato. connessione interrotta')
    self.close()
else:
    self.sender.sendMessage('Pin riconosciuto.!')
    self.sender.sendMessage('Dammi un comando!')
    return False
    def on_chat_message(self, msg):
        content_type, chat_type, chat_id = telepot.glance(msg)
        return True
        try:
          risposta = (msg['text'])
        except ValueError:
           self.sender.sendMessage('erorre sconosciuto')
           return
        if risposta != 'sposta':
           self.sender.sendMessage('non hai scritto sposta')
           self.close()
        else:
           self.sender.sendMessage(' hai scritto sposta')
           self.close()

def on_close(self, exception):
if isinstance(exception, telepot.helper.WaitTooLong):
self.sender.sendMessage('Tempo scaduto')
TOKEN = 'Token....'

bot = telepot.DelegatorBot(TOKEN, [
(per_chat_id(), create_open(Player, timeout=30)),
])
bot.notifyOnMessage(run_forever=True)
`

works well till it ask me "dammi un comando".. then when i write "sposta"...
it answers me "Scusa.. mi aspetto un pin numerico..."... That's so sad!!
please help me to understand how to manage this answers!!!!

Inline feature

Is there any inline feature planned?
I mean how can I answer to an InlineQuery with this python-based bot?
Would appreciate any help!

Error on selecting Deploy

When I'm selecting deploy in Google app engine launcher i'm getting this error : NameError
can somebody help me?

Sending a message when a user joins the group?

I made a bot using this to create a rules bot (prints rules on /rules) for a group chat I am in (a rather big chat). How do I make it so when a new user joins, the bot prints the rules?

Cyrrilic problem

Hello there! When i'm trying to make bot reply with cyrillic letters it doesn't do anything.
What shoul i do?

bot channel?

Hello & thank you for this simple explanation..
it worked just fine.. now my question is : How can I make a channel using a bot? & not letting anyone add comments..
Subscribers will receive only not being able to post.

"Documentation"

Hi, my name is Cristofer and I would like to help this repo with a better commented code. I have already done 2 bots with it and now I can understand 100% the code, but when I started I had many problems to understand it and change it. My objective is to help newcomers to understand what is happening.

Thanks, Cristofer.

No JSON object could be decoded

Why do I face this problem? am I doing something wrong?

> Traceback (most recent call last):
>   File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
>     rv = self.handle_exception(request, response, e)
>   File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
>     rv = self.router.dispatch(request, response)
>   File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
>     return route.handler_adapter(request, response)
>   File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
>     return handler.dispatch()
>   File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
>     return self.handle_exception(e, self.app.debug)
>   File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
>     return method(*args, **kwargs)
>   File "/base/data/home/apps/s~bedrybot/1.393553581151676930/main.py", line 48, in get
>     self.response.write(json.dumps(json.load(urllib2.urlopen(BASE_URL + 'getMe'))))
>   File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/__init__.py", line 290, in load
>     **kw)
>   File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/__init__.py", line 338, in loads
>     return _default_decoder.decode(s)
>   File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/decoder.py", line 365, in decode
>     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
>   File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/json/decoder.py", line 383, in raw_decode
>     raise ValueError("No JSON object could be decoded")
> ValueError: No JSON object could be decoded

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.