eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.12k stars 2.03k forks source link

pyTelegramBotAPI Bot2.0 Implementation status. #130

Closed eternnoir closed 8 years ago

eternnoir commented 8 years ago

Install pyTelegramBotAPI bot 2.0 branch

$ git clone -b bot20 --single-branch https://github.com/eternnoir/pyTelegramBotAPI.git
$ cd pyTelegramBotAPI
$ python setup.py install

Feel free to report bugs about this branch. https://github.com/eternnoir/pyTelegramBotAPI/issues/130

MonsterDeveloper commented 8 years ago

Can you leave and example using inline keyboard button, callback query and edit message text?

Thorapio commented 8 years ago

Hi! I have a problem with this implementation of your fucking amazing library.

I've copy the error code here to minimize this text: http://pastebin.com/9uNBk3K0

I'm not sure if there is a problem with version compatibility or if this is a bug in your library, but I think the line where I find the error is ok...

Thank you!

eternnoir commented 8 years ago

@Thorapio Try to update python-requests pip install -U requests.

Thorapio commented 8 years ago

@eternnoir , it doesn't seems to work for me... Here I paste the result of update the requests (http://pastebin.com/DRgVS2d0) and here are 2 more errors that appears to me two time when I was testing after update the requests (http://pastebin.com/DRgVS2d0). Futhermore, the first error is still happening and I don't know if I'm doing something wrong...

Thanks for your response!

pevdh commented 8 years ago

That error happens when you previously installed requests with apt. Try uninstalling the requests package with apt: apt-get remove python-requests*, and then reinstalling the package with pip: pip install requests.

thakryptex commented 8 years ago

There is a typo in the name of the method: "bot.edit_message_replay_markup()"

Correct is: "bot.editmessagereply_markup()"

v. 2.0.1

MonsterDeveloper commented 8 years ago

Is there any way so send multiple inline buttons with only one message? Like this: http://prntscr.com/awi4dg

thakryptex commented 8 years ago

@MonsterDeveloper, types.InlineKeyboardMarkup() suppose to do that, but for some reasons it doesn't work for me. Telegram sends:

2016-04-25 11:22:39,174 (__init__.py:211 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"[Error]: Bad Request: Can\'t parse inline keyboard button: InlineKeyboardButton should be an Object"}']"
MonsterDeveloper commented 8 years ago

@thakryptex Oh. Originally, I use that code: http://pastebin.com/AsN6qrum. I tried this: http://pastebin.com/6D4jaMz6 but no succes

thakryptex commented 8 years ago

@MonsterDeveloper, yeah, i've tried this too. and i tried to do markup.row('button1', 'button2') as it works for the simple markup keyboard, but it has no effect too.

MonsterDeveloper commented 8 years ago

@thakryptex Well, I think there is no way to do that. Waiting for @eternnoir answer right now)

eternnoir commented 8 years ago

@thakryptex typo already fixed.

About Is there any way so send multiple inline buttons with only one message? Try this

@bot.message_handler(commands=['start', 'help'])
def command_help(message):
    markup = types.InlineKeyboardMarkup()
    itembtna = types.InlineKeyboardButton('a', switch_inline_query="")
    itembtnv = types.InlineKeyboardButton('v', switch_inline_query="")
    itembtnc = types.InlineKeyboardButton('c', switch_inline_query="")
    markup.row(itembtna)
    markup.row(itembtnv, itembtnc)
    bot.send_message(message.chat.id, "Choose one letter:", reply_markup=markup)

Don't forgot update pyTelegramBotAPI version.

@thakryptex

2016-04-25 11:22:39,174 (__init__.py:211 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"[Error]: Bad Request: Can\'t parse inline keyboard button: InlineKeyboardButton should be an Object"}']"

The reason for this error is that you didn't use any option fields in InlineKeyboardButton. The develop doc says You must use exactly one of the optional fields.

https://core.telegram.org/bots/api#inlinekeyboardbutton

MonsterDeveloper commented 8 years ago

@eternnoir Thank you! I will try it when I come home)

MonsterDeveloper commented 8 years ago

@eternnoir Thanks! That worked for me!

thakryptex commented 8 years ago

@eternnoir oh, thanks, now I understand what was wrong.

sravanthi-nyllabs commented 6 years ago

@eternnoir Appreciate your work man! RegardingAbout Is there any way so send multiple inline buttons with only one message? Try this How can I add reply_to to the InlinekeyboardButton?

kingofnull commented 6 years ago

this show only buttons:

msg = bot.reply_to(m, "Send me your url:")
markup = types.InlineKeyboardMarkup()
itembtna = types.InlineKeyboardButton('a', callback_data="ds")
itembtnv = types.InlineKeyboardButton('v', callback_data="sds")
itembtnc = types.InlineKeyboardButton('c', callback_data="sdss")
markup.row(itembtna)
markup.row(itembtnv, itembtnc)

but how we should set callback query handler for inline buttons?

itJunky commented 6 years ago

How about sendGame method? https://core.telegram.org/bots/api#sendgame