Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion botogram/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

from .chats import User, Chat, UserProfilePhotos, Permissions
from .media import PhotoSize, Photo, Audio, Voice, Document, Sticker, \
Video, VideoNote, Animation, Contact, Location, Venue
Video, VideoNote, Animation, Contact, Location, Venue, \
Dice
from .messages import Message
from .markup import ReplyKeyboardMarkup, ReplyKeyboardHide, ForceReply
from .polls import Poll, PollOption
Expand Down Expand Up @@ -62,6 +63,9 @@
"Poll",
"PollOption",

#Dice-related objects
"Dice",

# Updates-related objects
"Update",
"Updates",
Expand Down
12 changes: 12 additions & 0 deletions botogram/objects/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,15 @@ class VideoNote(BaseObject, mixins.FileMixin):
"file_size": int,
}
_check_equality_ = "file_id"


class Dice(BaseObject):
"""Telegram API representation of a venue

https://core.telegram.orgf/bots/api#dice
"""

required = {
"emoji": str,
"value": int
}
3 changes: 2 additions & 1 deletion botogram/objects/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .. import utils
from .chats import User, Chat
from .media import Audio, Voice, Document, Photo, Sticker, Video, VideoNote, \
Animation, Contact, Location, Venue
Animation, Contact, Location, Venue, Dice
from .polls import Poll


Expand Down Expand Up @@ -353,6 +353,7 @@ def from_(self):
"location": Location,
"venue": Venue,
"poll": Poll,
"dice": Dice,
"new_chat_member": User,
"left_chat_member": User,
"new_chat_title": str,
Expand Down
15 changes: 15 additions & 0 deletions botogram/objects/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ def send_poll(self, question, *kargs, reply_to=None, extra=None,

return self._api.call("sendPoll", args, expect=_objects().Message)

@_require_api
def send_dice(self, emoji=None, reply_to=None, extra=None, attach=None,
notify=True):
"""Send a message"""
args = self._get_call_args(reply_to, extra, attach, notify)
if emoji is not None:
args["emoji"] = emoji

return self._api.call("sendDice", args, expect=_objects().Message)

@_require_api
def delete_message(self, message):
"""Delete a message from chat"""
Expand Down Expand Up @@ -609,6 +619,11 @@ def reply_with_poll(self, *args, **kwargs):
"""Reply with a poll to the current message"""
return self.chat.send_poll(*args, reply_to=self, **kwargs)

@_require_api
def reply_with_dice(self, *args, **kwargs):
"""Reply with a poll to the current message"""
return self.chat.send_dice(*args, reply_to=self, **kwargs)

@_require_api
def delete(self):
"""Delete the message"""
Expand Down
47 changes: 47 additions & 0 deletions docs/api/telegram.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,20 @@ about its business.

.. versionadded:: 0.7

.. py:method:: send_dice([emoji, reply_to=None, extra=None, attach=None, notify=True])

Use this method to send a dice, which will have a random value from 1 to 6

:param str emoji: Emoji on which the dice throw animation is based. Currently, must be one of “🎲” or “🎯”. Defauts to “🎲”
:param int reply_to: The ID of the :py:class:`~botogram.Message` this one is replying to
:param object attach: An extra thing to attach to the message
:param object extra: An extra reply interface object to attach
:param bool notify: If you want to trigger a notification on the client
:returns: The message you sent
:rtype: ~botogram.Message

.. versionadded:: 0.7

.. py:method:: delete_message(message)

Delete the message with the provided ID or :py:class:`~botogram.Message` object.
Expand Down Expand Up @@ -1856,6 +1870,12 @@ about its business.

*This attribute can be None if the message isn't a venue.*

.. py:attribute:: dice

A :py:class:`~botogram.Dice` object, when this message is a dice

*This attribute can be None if it's not provided by Telegram.*

.. py:attribute:: channel_post_author

The author of the message. This only works if the message is a channel
Expand Down Expand Up @@ -2531,6 +2551,19 @@ about its business.

.. versionadded:: 0.7

.. py:method:: reply_with_dice([emoji, extra=None, attach=None, notify=True])

Use this method to reply with a dice, which will have a random value from 1 to 6

:param str emoji: Emoji on which the dice throw animation is based. Currently, must be one of “🎲” or “🎯”. Defauts to “🎲”
:param object attach: An extra thing to attach to the message
:param object extra: An extra reply interface object to attach
:param bool notify: If you want to trigger a notification on the client
:returns: The message you sent
:rtype: ~botogram.Message

.. versionadded:: 0.7

.. py:class:: botogram.Photo

This class provides a general representation of a photo received by your bot.
Expand Down Expand Up @@ -3135,6 +3168,20 @@ about its business.
Number of users that voted for this option.


.. py:class:: botogram.Dice

This object represents a dice with a random value from 1 to 6 for currently supported base emoji.

.. py:attribute:: emoji

Emoji on which the dice throw animation is based

.. py:attribute:: value

Value of the dice, 1-6 for currently supported base emoji

.. versionadded:: 0.7

.. py:class:: botogram.Update

This class represents an update received by the bot. You should not need to
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog/0.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Release description not yet written.
New features
------------

* Added support fo dice

* New :py:class:`botogram.Dice` class
* New attribute :py:attr:`botogram.Message.dice`
* New method :py:meth:`botogram.Chat.send_dice`
* New method :py:meth:`botogram.User.send_dice`
* New method :py:meth:`botogram.Message.reply_with_gif`


* Added support for animations (GIFs)

Expand Down