linebot.models package

linebot.models.base module

linebot.models.base module.

class linebot.models.base.Base(**kwargs)

Bases: object

Base class of model.

Suitable for JSON base data.

__init__ method.

Parameters:kwargs
as_json_dict()

Return dictionary from this object.

Returns:dict
as_json_string()

Return JSON string from this object.

Return type:str
Returns:
static get_or_new_from_json_dict(data, cls)

Helper function.

If data is instance of cls, return data. Else if data is instance of dict, create instance from dict. Else, return None.

Parameters:
  • data
  • cls
Return type:

object

Returns:

static get_or_new_from_json_dict_with_types(data, cls_map, type_key=u'type')

Helper function.

If data is instance of one of cls, return data. Else if data is instance of dict, create instance from dict. Else, return None.

Parameters:
  • data
  • cls_map
  • type_key
Return type:

object

Returns:

classmethod new_from_json_dict(data)

Create a new instance from a dict.

Parameters:data – JSON dict
Return type:
Returns:

linebot.models.error module

linebot.models.error module.

class linebot.models.error.Error(message=None, details=None, **kwargs)

Bases: linebot.models.base.Base

Error response of LINE messaging API.

https://devdocs.line.me/en/#error-response

__init__ method.

Parameters:

:type :param kwargs:

class linebot.models.error.ErrorDetail(message=None, property=None, **kwargs)

Bases: linebot.models.base.Base

ErrorDetail response of LINE messaging API.

https://devdocs.line.me/en/#error-response

__init__ method.

https://devdocs.line.me/en/#error-response

Parameters:
  • message (str) – Details of the error message
  • property (str) – Related property
  • kwargs

linebot.models.events module

linebot.models.events module.

class linebot.models.events.Beacon(type=None, hwid=None, **kwargs)

Bases: linebot.models.base.Base

Beacon.

https://devdocs.line.me/en/#beacon-event

__init__ method.

Parameters:
  • type (str) – Type of beacon event
  • hwid (str) – Hardware ID of the beacon that was detected
  • kwargs
class linebot.models.events.BeaconEvent(timestamp=None, source=None, reply_token=None, beacon=None, **kwargs)

Bases: linebot.models.events.Event

Webhook BeaconEvent.

https://devdocs.line.me/en/#beacon-event

Event object for when a user detects a LINE Beacon. You can reply to beacon events.

__init__ method.

Parameters:
class linebot.models.events.Event(timestamp=None, source=None, **kwargs)

Bases: linebot.models.base.Base

Abstract Base Class of Webhook Event.

https://devdocs.line.me/en/#webhook-event-object

__init__ method.

Parameters:
class linebot.models.events.FollowEvent(timestamp=None, source=None, reply_token=None, **kwargs)

Bases: linebot.models.events.Event

Webhook FollowEvent.

https://devdocs.line.me/en/#follow-event

Event object for when your account is added as a friend (or unblocked). You can reply to follow events.

__init__ method.

Parameters:
  • timestamp (long) – Time of the event in milliseconds
  • source (T <= linebot.models.sources.Source) – Source object
  • reply_token (str) – Reply token
  • kwargs
class linebot.models.events.JoinEvent(timestamp=None, source=None, reply_token=None, **kwargs)

Bases: linebot.models.events.Event

Webhook JoinEvent.

https://devdocs.line.me/en/#join-event

Event object for when your account joins a group or talk room. You can reply to join events.

__init__ method.

Parameters:
  • timestamp (long) – Time of the event in milliseconds
  • source (T <= linebot.models.sources.Source) – Source object
  • reply_token (str) – Reply token
  • kwargs
class linebot.models.events.LeaveEvent(timestamp=None, source=None, **kwargs)

Bases: linebot.models.events.Event

Webhook LeaveEvent.

https://devdocs.line.me/en/#leave-event

Event object for when your account leaves a group.

__init__ method.

Parameters:
class linebot.models.events.MessageEvent(timestamp=None, source=None, reply_token=None, message=None, **kwargs)

Bases: linebot.models.events.Event

Webhook MessageEvent.

https://devdocs.line.me/en/#message-event

Event object which contains the sent message. The message field contains a message object which corresponds with the message type. You can reply to message events.

__init__ method.

Parameters:
class linebot.models.events.Postback(data=None, **kwargs)

Bases: linebot.models.base.Base

Postback.

https://devdocs.line.me/en/#postback-event

__init__ method.

Parameters:
  • data (str) –
  • kwargs
class linebot.models.events.PostbackEvent(timestamp=None, source=None, reply_token=None, postback=None, **kwargs)

Bases: linebot.models.events.Event

Webhook PostbackEvent.

https://devdocs.line.me/en/#postback-event

Event object for when a user performs an action on a template message which initiates a postback. You can reply to postback events.

__init__ method.

Parameters:
class linebot.models.events.UnfollowEvent(timestamp=None, source=None, **kwargs)

Bases: linebot.models.events.Event

Webhook UnfollowEvent.

https://devdocs.line.me/en/#unfollow-event

Event object for when your account is blocked.

__init__ method.

Parameters:

linebot.models.imagemap module

linebot.models.imagemap module.

class linebot.models.imagemap.BaseSize(width=None, height=None, **kwargs)

Bases: linebot.models.base.Base

BaseSize.

https://devdocs.line.me/en/#imagemap-message

__init__ method.

https://devdocs.line.me/en/#imagemap-message

Parameters:
  • width (int) – Width of base image (set to 1040px)
  • height (int) – Height of base image(set to the height that corresponds to a width of 1040px
  • kwargs
class linebot.models.imagemap.ImagemapAction(**kwargs)

Bases: linebot.models.base.Base

ImagemapAction.

https://devdocs.line.me/en/#imagemap-message

__init__ method.

Parameters:kwargs
class linebot.models.imagemap.ImagemapArea(x=None, y=None, width=None, height=None, **kwargs)

Bases: linebot.models.base.Base

ImagemapArea.

https://devdocs.line.me/en/#imagemap-area-object

Defines the size of the full imagemap with the width as 1040px. The top left is used as the origin of the area.

__init__ method.

Parameters:
  • x (int) – Horizontal position of the tappable area
  • y (int) – Vertical position of the tappable area
  • width (int) – Width of the tappable area
  • height (int) – Height of the tappable area
  • kwargs
class linebot.models.imagemap.ImagemapSendMessage(base_url=None, alt_text=None, base_size=None, actions=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

ImagemapSendMessage.

https://devdocs.line.me/en/#imagemap-message

Imagemaps are images with one or more links. You can assign one link for the entire image or multiple links which correspond to different regions of the image.

__init__ method.

Parameters:
class linebot.models.imagemap.MessageImagemapAction(text=None, area=None, **kwargs)

Bases: linebot.models.imagemap.ImagemapAction

MessageImagemapAction.

https://devdocs.line.me/en/#imagemap-message

__init__ method.

Parameters:
class linebot.models.imagemap.URIImagemapAction(link_uri=None, area=None, **kwargs)

Bases: linebot.models.imagemap.ImagemapAction

URIImagemapAction.

https://devdocs.line.me/en/#imagemap-message

__init__ method.

Parameters:

linebot.models.messages module

linebot.models.messages module.

class linebot.models.messages.AudioMessage(id=None, **kwargs)

Bases: linebot.models.messages.Message

AudioMessage.

https://devdocs.line.me/en/#audio-message

Message object which contains the audio content sent from the source. The binary audio data can be retrieved with the Content API.

__init__ method.

Parameters:
  • id (str) – Message ID
  • kwargs
class linebot.models.messages.ImageMessage(id=None, **kwargs)

Bases: linebot.models.messages.Message

ImageMessage.

https://devdocs.line.me/en/#image-message

Message object which contains the image content sent from the source. The binary image data can be retrieved with the Content API.

__init__ method.

Parameters:
  • id (str) – Message ID
  • kwargs
class linebot.models.messages.LocationMessage(id=None, title=None, address=None, latitude=None, longitude=None, **kwargs)

Bases: linebot.models.messages.Message

LocationMessage.

https://devdocs.line.me/en/#location-message

__init__ method.

Parameters:
  • id (str) – Message ID
  • title (str) – Title
  • address (str) – Address
  • latitude (float) – Latitude
  • longitude (float) – Longitude
  • kwargs
class linebot.models.messages.Message(id=None, **kwargs)

Bases: linebot.models.base.Base

Abstract Base Class of Message.

__init__ method.

Parameters:
  • id (str) – Message ID
  • kwargs
class linebot.models.messages.StickerMessage(id=None, package_id=None, sticker_id=None, **kwargs)

Bases: linebot.models.messages.Message

StickerMessage.

https://devdocs.line.me/en/#sticker-message

Message object which contains the sticker data sent from the source. For a list of basic LINE stickers and sticker IDs, see sticker list.

__init__ method.

Parameters:
  • id (str) – Message ID
  • package_id (str) – Package ID
  • sticker_id (str) – Sticker ID
  • kwargs
class linebot.models.messages.TextMessage(id=None, text=None, **kwargs)

Bases: linebot.models.messages.Message

TextMessage.

https://devdocs.line.me/en/#text-message

Message object which contains the text sent from the source.

__init__ method.

Parameters:
  • id (str) – Message ID
  • text (str) – Message text
  • kwargs
class linebot.models.messages.VideoMessage(id=None, **kwargs)

Bases: linebot.models.messages.Message

VideoMessage.

https://devdocs.line.me/en/#video-message

Message object which contains the video content sent from the source. The binary video data can be retrieved with the Content API.

__init__ method.

Parameters:
  • id (str) – Message ID
  • kwargs

linebot.models.responses module

linebot.models.responses module.

class linebot.models.responses.MessageContent(response)

Bases: object

MessageContent.

https://devdocs.line.me/ja/#get-content

__init__ method.

Parameters:
content

Get content.

If content size is large, should use iter_content.

Return type:binary
content_type

Get Content-type header value.

Return type:str
Returns:content-type header value
iter_content(chunk_size=1024)

Get content as iterator (stream).

If content size is large, should use this.

Parameters:chunk_size – Chunk size
Return type:iterator
Returns:
class linebot.models.responses.Profile(display_name=None, user_id=None, picture_url=None, status_message=None, **kwargs)

Bases: linebot.models.base.Base

Profile.

https://devdocs.line.me/en/#bot-api-get-profile

__init__ method.

Parameters:
  • display_name (str) – Display name
  • user_id (str) – User ID
  • picture_url (str) – Image URL
  • status_message (str) – Status message
  • kwargs

linebot.models.send_messages module

linebot.models.send_messages module.

class linebot.models.send_messages.AudioSendMessage(original_content_url=None, duration=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

AudioSendMessage.

https://devdocs.line.me/en/#audio

__init__ method.

Parameters:
  • original_content_url (str) – URL of audio file. HTTPS m4a Less than 1 minute Max 10 MB
  • duration (long) – Length of audio file (milliseconds).
  • kwargs
class linebot.models.send_messages.ImageSendMessage(original_content_url=None, preview_image_url=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

ImageSendMessage.

https://devdocs.line.me/en/#image

__init__ method.

Parameters:
  • original_content_url (str) – Image URL. HTTPS JPEG Max: 1024 x 1024 Max: 1 MB
  • preview_image_url (str) – Preview image URL HTTPS JPEG Max: 240 x 240 Max: 1 MB
  • kwargs
class linebot.models.send_messages.LocationSendMessage(title=None, address=None, latitude=None, longitude=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

LocationSendMessage.

https://devdocs.line.me/en/#location

__init__ method.

Parameters:
  • title (str) – Title
  • address (str) – Address
  • latitude (float) – Latitude
  • longitude (float) – Longitude
  • kwargs
class linebot.models.send_messages.SendMessage(**kwargs)

Bases: linebot.models.base.Base

Abstract Base Class of SendMessage.

__init__ method.

Parameters:kwargs
class linebot.models.send_messages.StickerSendMessage(package_id=None, sticker_id=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

StickerSendMessage.

https://devdocs.line.me/en/#sticker

__init__ method.

Parameters:
  • package_id (str) – Package ID
  • sticker_id (str) – Sticker ID
  • kwargs
class linebot.models.send_messages.TextSendMessage(text=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

TextSendMessage.

https://devdocs.line.me/en/#text

__init__ method.

Parameters:
  • text (str) – Message text
  • kwargs
class linebot.models.send_messages.VideoSendMessage(original_content_url=None, preview_image_url=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

VideoSendMessage.

https://devdocs.line.me/en/#video

__init__ method.

Parameters:
  • original_content_url (str) – URL of video file. HTTPS mp4 Less than 1 minute Max: 10 MB
  • preview_image_url (str) – URL of preview image. HTTPS JPEG Max: 240 x 240 Max: 1 MB
  • kwargs

linebot.models.sources module

linebot.models.sources module.

class linebot.models.sources.Source(**kwargs)

Bases: linebot.models.base.Base

Abstract Base Class of Source.

__init__ method.

Parameters:kwargs
sender_id

Helper method.

If SourceUser, return user_id. If SourceGroup, return group_id. If SourceRoom, return room_id.

Return type:str
Returns:
class linebot.models.sources.SourceGroup(group_id=None, **kwargs)

Bases: linebot.models.sources.Source

SourceGroup.

https://devdocs.line.me/en/#source-group

JSON object which contains the source group of the event.

__init__ method.

Parameters:
  • group_id (str) – ID of the source group
  • kwargs
sender_id

Helper method.

Alias of group_id.

Return type:str
Returns:
class linebot.models.sources.SourceRoom(room_id=None, **kwargs)

Bases: linebot.models.sources.Source

SourceRoom.

https://devdocs.line.me/en/#source-room

JSON object which contains the source room of the event.

__init__ method.

Parameters:
  • room_id (str) – ID of the source room
  • kwargs
sender_id

Helper method.

Alias of room_id.

If SourceUser, return user_id. If SourceGroup, return group_id. If SourceRoom, return room_id.

Return type:str
Returns:
class linebot.models.sources.SourceUser(user_id=None, **kwargs)

Bases: linebot.models.sources.Source

SourceUser.

https://devdocs.line.me/en/#source-user

JSON object which contains the source user of the event.

__init__ method.

Parameters:
  • user_id (str) – ID of the source user
  • kwargs
sender_id

Helper method.

Alias of user_id.

Return type:str
Returns:

linebot.models.template module

linebot.models.template module.

class linebot.models.template.ButtonsTemplate(text=None, title=None, thumbnail_image_url=None, actions=None, **kwargs)

Bases: linebot.models.template.Template

ButtonsTemplate.

https://devdocs.line.me/en/#buttons

Template message with an image, title, text, and multiple action buttons.

__init__ method.

Parameters:
  • text (str) – Message text. Max: 160 characters (no image or title). Max: 60 characters (message with an image or title)
  • title (str) – Title. Max: 40 characters
  • thumbnail_image_url (str) – Image URL. HTTPS JPEG or PNG Aspect ratio: 1:1.51 Max width: 1024px Max: 1 MB
  • actions (list[T <= linebot.models.template.TemplateAction]) – Action when tapped. Max: 4
  • kwargs
class linebot.models.template.CarouselColumn(text=None, title=None, thumbnail_image_url=None, actions=None, **kwargs)

Bases: linebot.models.base.Base

CarouselColumn.

https://devdocs.line.me/en/#column-object

__init__ method.

Parameters:
  • text (str) – Message text. Max: 120 characters (no image or title) Max: 60 characters (message with an image or title)
  • title (str) – Title. Max: 40 characters
  • thumbnail_image_url (str) – Image URL. HTTPS JPEG or PNG Aspect ratio: 1:1.51 Max width: 1024px Max: 1 MB
  • actions (list[T <= linebot.models.template.TemplateAction]) – Action when tapped. Max: 3
  • kwargs
class linebot.models.template.CarouselTemplate(columns=None, **kwargs)

Bases: linebot.models.base.Base

CarouselTemplate.

https://devdocs.line.me/en/#carousel

Template message with multiple columns which can be cycled like a carousel.

__init__ method.

Parameters:
class linebot.models.template.ConfirmTemplate(text=None, actions=None, **kwargs)

Bases: linebot.models.template.Template

ConfirmTemplate.

https://devdocs.line.me/en/#confirm

Template message with two action buttons.

__init__ method.

Parameters:
class linebot.models.template.MessageTemplateAction(label=None, text=None, **kwargs)

Bases: linebot.models.template.TemplateAction

MessageTemplateAction.

https://devdocs.line.me/en/#template-messages

When this action is tapped, the string in the text field is sent as a message from the user.

__init__ method.

Parameters:
  • label (str) – Label for the action. Max: 20 characters
  • text (str) – Text sent when the action is performed. Max: 300 characters
  • kwargs
class linebot.models.template.PostbackTemplateAction(label=None, data=None, text=None, **kwargs)

Bases: linebot.models.template.TemplateAction

PostbackTemplateAction.

https://devdocs.line.me/en/#template-messages

When this action is tapped, a postback event is returned via webhook with the specified string in the data field.

If you have included the text field, the string in the text field is sent as a message from the user.

__init__ method.

Parameters:
  • label (str) – Label for the action. Max: 20 characters
  • data (str) – String returned via webhook in the postback.data property of the postback event. Max: 300 characters
  • text (str) – Text sent when the action is performed. Max: 300 characters
  • kwargs
class linebot.models.template.Template(**kwargs)

Bases: linebot.models.base.Base

Abstract Base Class of Template.

__init__ method.

Parameters:kwargs
class linebot.models.template.TemplateAction(**kwargs)

Bases: linebot.models.base.Base

Abstract Base Class of TemplateAction.

__init__ method.

Parameters:kwargs
class linebot.models.template.TemplateSendMessage(alt_text=None, template=None, **kwargs)

Bases: linebot.models.send_messages.SendMessage

TemplateSendMessage.

https://devdocs.line.me/en/#template-messages

Template messages are messages with predefined layouts which you can customize. There are three types of templates available that can be used to interact with users through your bot.

__init__ method.

Parameters:
  • alt_text (str) – Alternative text for unsupported devices.
  • template (T <= linebot.models.template.Template) – Object with the contents of the template.
  • kwargs
class linebot.models.template.URITemplateAction(label=None, uri=None, **kwargs)

Bases: linebot.models.template.TemplateAction

URITemplateAction.

https://devdocs.line.me/en/#template-messages

When this action is tapped, the URI specified in the uri field is opened.

__init__ method.

Parameters:
  • label (str) – Label for the action Max: 20 characters
  • uri (str) – URI opened when the action is performed. http, https, tel
  • kwargs