Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
Update to 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Mar 30, 2020
1 parent 5fc78d8 commit 9d7e000
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 15 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# amanobot changelog

## 1.7.0 (2020-03-30)
- Bot API 4.7
- Added the method `sendDice` for sending a dice message, which will have a random value from 1 to 6
- Added the field `dice` to the `Message` object
- Added the method `getMyCommands` for getting the current list of the bot's commands
- Added the method `setMyCommands` for changing the list of the bot's commands through the Bot API instead of @BotFather
- Added the ability to create animated sticker sets by specifying the parameter `tgs_sticker` instead of `png_sticker` in the method `createNewStickerSet`
- Added the ability to add animated stickers to sets created by the bot by specifying the parameter `tgs_sticker` instead of `png_sticker` in the method `addStickerToSet`
- Added the field `thumb` to the `StickerSet` object
- Added the ability to change thumbnails of sticker sets created by the bot using the method `setStickerSetThumb`

## 1.6.0 (2020-01-23)
- Bot API 4.6
- Added the ability to send non-anonymous, multiple answer, and quiz-style polls: added the parameters `is_anonymous`, `type`, `allows_multiple_answers`, `correct_option_id`, `is_closed` options to the method `sendPoll`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</h6>
<h6 align="center">
<a href="https://pypi.org/project/amanobot"><img src="https://img.shields.io/pypi/v/amanobot.svg" /></a>
<a href="https://core.telegram.org/bots/api"><img src="https://img.shields.io/badge/bot api-v4.6-0688CB.svg" /></a>
<a href="https://core.telegram.org/bots/api"><img src="https://img.shields.io/badge/bot api-v4.7-0688CB.svg" /></a>
</h6>

### [Migrating from Telepot »](https://docs.amanobot.ml/en/latest/migrating-from-telepot.html)
Expand Down
45 changes: 37 additions & 8 deletions amanobot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from . import exception


__version_info__ = (1, 6, 0)
__version_info__ = (1, 7, 0)
__version__ = '.'.join(map(str, __version_info__))


Expand Down Expand Up @@ -747,6 +747,14 @@ def sendPoll(self, chat_id, question, options,
p = _strip(locals())
return self._api_request('sendPoll', _rectify(p))

def sendDice(self, chat_id,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#senddice """
p = _strip(locals())
return self._api_request('sendDice', _rectify(p))

def sendGame(self, chat_id, game_short_name,
disable_notification=None,
reply_to_message_id=None,
Expand Down Expand Up @@ -949,6 +957,15 @@ def answerCallbackQuery(self, callback_query_id,
p = _strip(locals())
return self._api_request('answerCallbackQuery', _rectify(p))

def setMyCommands(self, commands=[]):
""" See: https://core.telegram.org/bots/api#setmycommands """
p = _strip(locals())
return self._api_request('setMyCommands', _rectify(p))

def getMyCommands(self):
""" See: https://core.telegram.org/bots/api#getmycommands """
return self._api_request('getMyCommands')

def setPassportDataErrors(self, user_id, errors):
""" See: https://core.telegram.org/bots/api#setpassportdataerrors """
p = _strip(locals())
Expand Down Expand Up @@ -1073,22 +1090,26 @@ def uploadStickerFile(self, user_id, png_sticker):
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('uploadStickerFile', _rectify(p), {'png_sticker': png_sticker})

def createNewStickerSet(self, user_id, name, title, png_sticker, emojis,
def createNewStickerSet(self, user_id, name, title, emojis,
png_sticker=None,
tgs_sticker=None,
contains_masks=None,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#createnewstickerset
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('createNewStickerSet', _rectify(p), {'png_sticker': png_sticker})
p = _strip(locals(), more=['png_sticker', 'tgs_sticker'])
return self._api_request_with_file('createNewStickerSet', _rectify(p), {'png_sticker': png_sticker, 'tgs_sticker': tgs_sticker})

def addStickerToSet(self, user_id, name, png_sticker, emojis,
mask_position=None):
def addStickerToSet(self, user_id, name, emojis,
png_sticker=None,
tgs_sticker=None,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#addstickertoset
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('addStickerToSet', _rectify(p), {'png_sticker': png_sticker})
p = _strip(locals(), more=['png_sticker', 'tgs_sticker'])
return self._api_request_with_file('addStickerToSet', _rectify(p), {'png_sticker': png_sticker, 'tgs_sticker': tgs_sticker})

def setStickerPositionInSet(self, sticker, position):
"""
Expand All @@ -1104,6 +1125,14 @@ def deleteStickerFromSet(self, sticker):
p = _strip(locals())
return self._api_request('deleteStickerFromSet', _rectify(p))

def setStickerSetThumb(self, name, user_id,
thumb=None):
"""
See: https://core.telegram.org/bots/api#setstickersetthumb
"""
p = _strip(locals(), more=['thumb'])
return self._api_request_with_file('setStickerSetThumb', _rectify(p), {'thumb': thumb})

def answerInlineQuery(self, inline_query_id, results,
cache_time=None,
is_personal=None,
Expand Down
41 changes: 35 additions & 6 deletions amanobot/aio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ async def sendPoll(self, chat_id, question, options,
p = _strip(locals())
return await self._api_request('sendPoll', _rectify(p))

async def sendDice(self, chat_id,
disable_notification=None,
reply_to_message_id=None,
reply_markup=None):
""" See: https://core.telegram.org/bots/api#senddice """
p = _strip(locals())
return await self._api_request('sendDice', _rectify(p))

async def sendGame(self, chat_id, game_short_name,
disable_notification=None,
reply_to_message_id=None,
Expand Down Expand Up @@ -526,6 +534,15 @@ async def answerCallbackQuery(self, callback_query_id,
p = _strip(locals())
return await self._api_request('answerCallbackQuery', _rectify(p))

async def setMyCommands(self, commands=[]):
""" See: https://core.telegram.org/bots/api#setmycommands """
p = _strip(locals())
return await self._api_request('setMyCommands', _rectify(p))

async def getMyCommands(self):
""" See: https://core.telegram.org/bots/api#getmycommands """
return await self._api_request('getMyCommands')

async def answerShippingQuery(self, shipping_query_id, ok,
shipping_options=None,
error_message=None):
Expand Down Expand Up @@ -647,22 +664,26 @@ async def uploadStickerFile(self, user_id, png_sticker):
p = _strip(locals(), more=['png_sticker'])
return await self._api_request_with_file('uploadStickerFile', _rectify(p), {'png_sticker': png_sticker})

async def createNewStickerSet(self, user_id, name, title, png_sticker, emojis,
async def createNewStickerSet(self, user_id, name, title, emojis,
png_sticker=None,
tgs_sticker=None,
contains_masks=None,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#createnewstickerset
"""
p = _strip(locals(), more=['png_sticker'])
return await self._api_request_with_file('createNewStickerSet', _rectify(p), {'png_sticker': png_sticker})
p = _strip(locals(), more=['png_sticker', 'tgs_sticker'])
return await self._api_request_with_file('createNewStickerSet', _rectify(p), {'png_sticker': png_sticker, 'tgs_sticker': tgs_sticker})

async def addStickerToSet(self, user_id, name, png_sticker, emojis,
async def addStickerToSet(self, user_id, name, emojis,
png_sticker=None,
tgs_sticker=None,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#addstickertoset
"""
p = _strip(locals(), more=['png_sticker'])
return await self._api_request_with_file('addStickerToSet', _rectify(p), {'png_sticker': png_sticker})
p = _strip(locals(), more=['png_sticker', 'tgs_sticker'])
return await self._api_request_with_file('addStickerToSet', _rectify(p), {'png_sticker': png_sticker, 'tgs_sticker': tgs_sticker})

async def setStickerPositionInSet(self, sticker, position):
"""
Expand All @@ -678,6 +699,14 @@ async def deleteStickerFromSet(self, sticker):
p = _strip(locals())
return await self._api_request('deleteStickerFromSet', _rectify(p))

async def setStickerSetThumb(self, name, user_id,
thumb=None):
"""
See: https://core.telegram.org/bots/api#setstickersetthumb
"""
p = _strip(locals(), more=['thumb'])
return await self._api_request_with_file('setStickerSetThumb', _rectify(p), {'thumb': thumb})

async def answerInlineQuery(self, inline_query_id, results,
cache_time=None,
is_personal=None,
Expand Down
13 changes: 13 additions & 0 deletions amanobot/namedtuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def UserArray(data):
'can_pin_messages'
])

# incoming
BotCommand = _create_class('BotCommand', [
'command',
'description'
])

# incoming
Chat = _create_class('Chat', [
'id',
Expand Down Expand Up @@ -221,6 +227,7 @@ def StickerArray(data):
'is_animated',
'contains_masks',
_Field('stickers', constructor=StickerArray),
_Field('thumb', constructor=PhotoSize)
])

# incoming
Expand Down Expand Up @@ -303,6 +310,11 @@ def StickerArray(data):
'correct_option_id'
])

# incoming
Dice = _create_class('Dice', [
'value'
])

# incoming
File = _create_class('File', [
'file_id',
Expand Down Expand Up @@ -592,6 +604,7 @@ def MessageEntityArray(data):
_Field('location', constructor=Location),
_Field('venue', constructor=Venue),
_Field('poll', constructor=Poll),
_Field('dice', constructor=Dice),
_Field('new_chat_member', constructor=User),
_Field('left_chat_member', constructor=User),
'new_chat_title',
Expand Down

0 comments on commit 9d7e000

Please sign in to comment.