X Tutup
Skip to content

Add api changes as of october#431

Merged
jsmnbom merged 55 commits intomasterfrom
october3
Oct 19, 2016
Merged

Add api changes as of october#431
jsmnbom merged 55 commits intomasterfrom
october3

Conversation

@jsmnbom
Copy link
Copy Markdown
Member

@jsmnbom jsmnbom commented Oct 3, 2016

Add changes as of October 3, 2016.
Mostly games: https://core.telegram.org/bots/api#games
Other changes: https://core.telegram.org/bots/api#recent-changes

  • Games
    • Unitests
  • getWebhookInfo and WebhookInfo
    • Unitests
  • Allow HTTP url in all methods that accept InputFile or file_id (this requires disabling our own handling of this)
    • Unitests
  • Url parameter in answerCallbackQuery
    • Unitests
  • switch_inline_query_current_chat
    • Unitests
  • Add caption fields to send_audio, send_voice, InlineQueryResultAudio, InlineQueryResultVoice, ``InlineQueryResultCachedAudioandInlineQueryResultCachedVoice`
    • Unitests
  • all_members_are_admins in Chat
    • Unitests
  • Handle the errors of ResponseParameters (no need unitests for the moment. we already had one response param and we didn't unitest it)

@jsmnbom jsmnbom mentioned this pull request Oct 3, 2016
8 tasks
@jsmnbom jsmnbom added the ⚙️ bot-api affected functionality: bot-api label Oct 3, 2016
tsnoam and others added 24 commits October 3, 2016 20:43
Missing docstrings for now though, wanna add everything first
Also chat_instance in CallbackQuery which will break a lot of tests probably
N.B. test_send_video_mp4_file_url() is still failing, probably because
of telegram servers bug. Will contact telegram bot support about that.
Also, small fix to the description text of ChatMigrated
 - fix copy/paste errors
 - return Message object
tsnoam and others added 14 commits October 6, 2016 00:11
* bot.py fix copy paste error in url
* callbackquery.py make data field optional
* message.py introduce optional game field
small fix for game related parts
Data is an optional kwargs in CallbackQuery according to Telegram
Still need setGameScore (I'm thinking we can set it to the ever increasing
envvar 'TRAVIS_BUILD_NUMBER') and getGameHighScores.
The tests currently don't work... Since I don't really understand how
PhotoSize works... Please halp :P
)

* fixes broken test with PhotoSize, Game and Animation

However:
testSendGame and test_set_game_score both produces *BadRequest: u'Wrong file identifier/HTTP URL specified'*.

* fixes test_set_game_score

* adds to_dict method to Game to prevent extra collection type checks in base.TelegramObject
Needs proper animation file_id and size.
Also assertEqual can't test if two objects have the same data, so we just check the file_id instead.
@jsmnbom jsmnbom added the 📋 pending-review work status: pending-review label Oct 14, 2016
telegram/bot.py Outdated
@message
def sendGame(self,
chat_id,
game_short_name,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://core.telegram.org/bots/api#sendgame the kwargs should be different

telegram/bot.py Outdated
data['edit_message'] = edit_message

result = self._request.post(url, data, timeout=kwargs.get('timeout'))
return Message.de_json(result, self)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result could be just True (https://core.telegram.org/bots/api#setgamescore), won't this raise an error?

self.message = kwargs.get('message')
self.data = kwargs.get('data', '')
self.inline_message_id = kwargs.get('inline_message_id', '')
self.game_short_name = kwargs.get('game_short_name')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an empty string as default

telegram/chat.py Outdated
self.username = kwargs.get('username', '')
self.first_name = kwargs.get('first_name', '')
self.last_name = kwargs.get('last_name', '')
self.all_members_are_admins = kwargs.get('all_members_are_admins', '')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be False as default, not empty string

data['text_entities'] = [x.to_dict() for x in self.text_entities]

return data

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these just copy-pasted from telegram.Message?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they are. Is there a better way to do it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bomjacob
I think what @jh0ker means is that you don't need to manually serialize a list. the base class will do it for you. (and yes, i missed it myself going over the code)

#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains a object that represents a Telegram GameHighScore."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an*

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure... an sounds wrong to me here.. T is a consonant sound, and so is G for that matter so I think it should be a.
I could be wrong though...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not meaning to meddle :), but he's most likely talking about "a object", not "a Telegram".

Copy link
Copy Markdown
Member Author

@jsmnbom jsmnbom Oct 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah of cause, sorry, I derped. Will fix shortly :) Thanks :D
EDIT: It seems however that we use "a object" litterally everywhere in the library... @jh0ker, Should I fix this everywhere, leave it for now, or just fix this particular instance?

telegram/game.py Outdated
title,
description,
photo,
text=None,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty string?

self.has_custom_certificate = has_custom_certificate
self.pending_update_count = pending_update_count
self.last_error_date = kwargs.get('last_error_date')
self.last_error_message = kwargs.get('last_error_message')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty string

# Conflicts:
#	telegram/bot.py
#	telegram/callbackquery.py
#	telegram/chat.py
#	telegram/ext/messagehandler.py
#	telegram/inlinekeyboardbutton.py
#	telegram/inlinequeryresultcachedaudio.py
#	telegram/message.py
#	tests/test_filters.py
@jsmnbom jsmnbom merged commit 61fe438 into master Oct 19, 2016
@jsmnbom jsmnbom removed the 📋 pending-review work status: pending-review label Oct 19, 2016
@jsmnbom jsmnbom deleted the october3 branch May 20, 2017 13:50
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

⚙️ bot-api affected functionality: bot-api

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

X Tutup