Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions linebot/models/delivery_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""linebot.models.delivery_context module."""


from abc import ABCMeta

from future.utils import with_metaclass

from .base import Base


class DeliveryContext(with_metaclass(ABCMeta, Base)):
"""Abstract Base Class of DeliveryContext."""

def __init__(self, is_redelivery=None, **kwargs):
"""__init__ method.

:param bool is_redelivery: Whether the webhook event is a redelivered one or not
:param kwargs:
"""
super(DeliveryContext, self).__init__(**kwargs)

self.is_redelivery = is_redelivery
15 changes: 14 additions & 1 deletion linebot/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from future.utils import with_metaclass

from linebot.models.base import Base
from linebot.models.delivery_context import DeliveryContext
from linebot.models.messages import (
TextMessage,
ImageMessage,
Expand All @@ -46,7 +47,15 @@ class Event(with_metaclass(ABCMeta, Base)):
https://developers.line.biz/en/reference/messaging-api/#webhook-event-objects
"""

def __init__(self, mode=None, timestamp=None, source=None, **kwargs):
def __init__(
self,
mode=None,
timestamp=None,
source=None,
webhook_event_id=None,
delivery_context=None,
**kwargs
):
"""__init__ method.

:param str mode: Channel state
Expand All @@ -67,6 +76,10 @@ def __init__(self, mode=None, timestamp=None, source=None, **kwargs):
'room': SourceRoom,
}
)
self.webhook_event_id = webhook_event_id
self.delivery_context = self.get_or_new_from_json_dict(
delivery_context, DeliveryContext
)


class MessageEvent(Event):
Expand Down
Loading