LineClient

Introduction

This is the most important class to use LINE with python. You have to make an instance of LineClient first and have to give your id and password as a parameters to login to LINE server. Then you should enter PinCode to pass through PinCode authentication

>>> from line import LineClient
>>> client = LineClient("carpedm20@gmail.com", "xxxxxxxxxx")
Enter PinCode '7390' to your mobile phone in 2 minutes
>>> client = LineClient("carpedm20", "xxxxxxxxxx")
Enter PinCode '9779' to your mobile phone in 2 minutes

With authToken of your line instance, you don’t have to enter Pincode everytime when you create a new LineClient instance.

>>> client = LineClient(authToken=authToken) # login with authToken

LineClient

class line.LineClient(id=None, password=None, authToken=None, is_mac=True, com_name='carpedm20')

Provide a way to communicate with LINE server.

Parameters:
  • idNAVER id or LINE email
  • password – LINE account password
  • authToken – LINE session key
  • is_mac – (optional) os setting
  • com_name – (optional) name of your system
>>> client = LineClient("carpedm20", "xxxxxxxxxx")
Enter PinCode '9779' to your mobile phone in 2 minutes
>>> client = LineClient("carpedm20@gmail.com", "xxxxxxxxxx")
Enter PinCode '7390' to your mobile phone in 2 minutes
>>> client = LineClient(authToken="xxx ... xxx")
True
acceptGroupInvitation(group)

Accept a group invitation

Parameters:group – LineGroup instance
addGroupsWithIds(group_ids, is_joined=True)

Refresh groups of LineClient

createGroupWithContacts(name, contacts=[])

Create a group with contacts

Parameters:
  • name – name of group
  • contacts – list of contacts
createGroupWithIds(name, ids=[])

Create a group with contact ids

Parameters:
  • name – name of group
  • ids – list of contact ids
createRoomWithContacts(contacts=[])

Create a chat room with contacts

createRoomWithIds(ids=[])

Create a chat room with contact ids

findAndAddContactByUserid(userid)

Find and add a contact by userid

Parameters:userid – user id
getContactById(id)

Get a contact by id

Parameters:id – id of a contact
getContactByName(name)

Get a contact by name

Parameters:name – name of a contact
getContactOrRoomOrGroupById(id)

Get a contact or room or group by its id

Parameters:id – id of a instance
getGroupById(id)

Get a group by id

Parameters:id – id of a group
getGroupByName(name)

Get a group by name

Parameters:name – name of a group
getLineMessageFromMessage(messages=[])

Change Message objects to LineMessage objects

Parameters:messges – list of Message object
getMessageBox(id)

Get MessageBox by id

Parameters:idcontact id or group id or room id
getProfile()

Get profile of LINE account

getRecentMessages(messageBox, count)

Get recent message from MessageBox

Parameters:messageBox – MessageBox object
getRoomById(id)

Get a room by id

Parameters:id – id of a room
inviteIntoGroup(group, contacts=[])

Invite contacts into group

Parameters:
  • group – LineGroup instance
  • contacts – LineContact instances to invite
inviteIntoRoom(room, contacts=[])

Invite contacts into room

Parameters:
  • room – LineRoom instance
  • contacts – LineContact instances to invite
leaveGroup(group)

Leave a group

Parameters:group – LineGroup instance to leave
leaveRoom(room)

Leave a room

Parameters:room – LineRoom instance to leave
longPoll(count=50, debug=False)

Receive a list of operations that have to be processed by original Line cleint.

Parameters:count – number of operations to get from
Returns:a generator which returns operations
>>> for op in client.longPoll():
        sender   = op[0]
        receiver = op[1]
        message  = op[2]
        print "%s->%s : %s" % (sender, receiver, message)
refreshActiveRooms()

Refresh active chat rooms

refreshContacts()

Refresh contacts of LineClient

refreshGroups()

Refresh groups of LineClient

sendMessage(message, seq=0)

Send a message

Parameters:message – LineMessage instance to send