Giter VIP home page Giter VIP logo

line-py's Introduction

logo LINE Python

Version 3.0.8 LICENSE Supported python versions: 3.x Chat on Discord

LINE Messaging's private API


Requirement

The linepy module only requires Python 3. You can download from here.

Installation

Installation is simple. It can be installed from pip using the following command:

$ pip install linepy

Or from the code:

$ python setup.py install

Usage

>>> from linepy import *
>>> line = LINE('EMAIL', 'PASSWORD')
>>> line.log("Auth Token : " + str(line.authToken))

Examples

All examples can be found here.

Updates

From pip using the following command:

$ pip install linepy --upgrade

Author

Fadhiil Rachman / @fadhiilrachman

line-py's People

Contributors

ervan0707 avatar fadhiilrachman avatar moepoi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

line-py's Issues

'NoneType' has no atribute 'lower

i get the error in the title every time someone posts a contact or sticker, and i think it is causing the contenttypes to not work properly

heroku error

Hey so i tried deploying this to Heroku. It was working fine at first, but later on i get this error:

2018-01-16T14:19:52.743896+00:00 heroku[web.1]: Starting process with command python sb.py
2018-01-16T14:20:04.706960+00:00 app[web.1]: [2018-01-16 14:20:04.706869] [TesBot] : Login success
2018-01-16T14:20:04.707003+00:00 app[web.1]: [2018-01-16 14:20:04.706960] Auth Token : -
2018-01-16T14:20:06.833303+00:00 app[web.1]: [2018-01-16 14:20:06.833212] [TesBot] : LineTimeline attached
2018-01-16T14:20:07.940032+00:00 app[web.1]: [2018-01-16 14:20:07.939941] [TesBot] : Success login to Timeline
2018-01-16T14:20:07.940052+00:00 app[web.1]: [2018-01-16 14:20:07.940011] Channel Access Token : -
2018-01-16T14:20:53.163182+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-01-16T14:20:53.163293+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-01-16T14:20:53.255695+00:00 heroku[web.1]: Process exited with status 137
2018-01-16T14:20:53.269183+00:00 heroku[web.1]: State changed from starting to crashed

What happened there?

ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:645)

I have a problem like this, please help me :(

Traceback (most recent call last):
File "echobot.py", line 4, in
line = LINE('My Email', 'My Password')
File "/usr/local/lib/python3.5/site-packages/linepy/client.py", line 18, in init
self.loginWithCredential(_id=idOrAuthToken, passwd=passwd, certificate=certificate, systemName=systemName, appName=appName, keepLoggedIn=keepLoggedIn)
File "/usr/local/lib/python3.5/site-packages/linepy/auth.py", line 73, in loginWithCredential
rsaKey = self.tauth.getRSAKeyInfo(self.provider)
File "/usr/local/lib/python3.5/site-packages/akad/TalkService.py", line 5109, in getRSAKeyInfo
self.send_getRSAKeyInfo(provider)
File "/usr/local/lib/python3.5/site-packages/akad/TalkService.py", line 5118, in send_getRSAKeyInfo
self._oprot.trans.flush()
File "/usr/local/lib/python3.5/site-packages/thrift/transport/THttpClient.py", line 141, in _f
result = f(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/thrift/transport/THttpClient.py", line 181, in flush
self.__http.endheaders()
File "/usr/local/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/usr/local/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/local/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/usr/local/lib/python3.5/http/client.py", line 1260, in connect
server_hostname=server_hostname)
File "/usr/local/lib/python3.5/ssl.py", line 377, in wrap_socket
_context=self)
File "/usr/local/lib/python3.5/ssl.py", line 752, in init
self.do_handshake()
File "/usr/local/lib/python3.5/ssl.py", line 988, in do_handshake
self._sslobj.do_handshake()
File "/usr/local/lib/python3.5/ssl.py", line 633, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:645)

can't use findAndAddContactsByMid(mid)

define findAndAddContactsByMid(self, reqSeq, mid, type, reference) in TalkService
But uses self.talk.findAndAddContactsByMid(0, mid) in client.py
So i got error
findAndAddContactsByMid() missing 2 required positional arguments: 'type' and 'reference'
Please fix this

Error 500

i got an error when i try like and comment function
{u'message': u'Your request has not been\nprocessed due to a temporary error.\nPlease try again.', u'code': 500, u'result': None}

Login success but get error akad.ttypes.SquareException

I got this error, when I try to login with email and password.
How can i fix this?

( I'm using Python 3.6.2 and linepy 3.0.6. )

code

from linepy import *
line = LINE('EMAIL', 'PASSWORD')
line.log("Auth Token : " + str(line.authToken))

error

[2018-01-15 11:28:21.247885] [xxx] : Login success
Traceback (most recent call last):
  File "line2.py", line 12, in <module>
    line = LINE('EMAIL', "PASSWORD")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/linepy/client.py", line 22, in __init__
    self.__initAll()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/linepy/client.py", line 35, in __initAll
    self.squares    = self.getJoinedSquares()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/linepy/square.py", line 7, in checkLogin
    return func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/linepy/square.py", line 266, in getJoinedSquares
    return self.square.getJoinedSquares(rq)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/akad/SquareService.py", line 1833, in getJoinedSquares
    return self.recv_getJoinedSquares()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/akad/SquareService.py", line 1857, in recv_getJoinedSquares
    raise result.e
akad.ttypes.SquareException: SquareException(errorCode=403, errorExtraInfo=None, reason='対応していないか不正なURLです。')

errorCode=0 when using getSquare()

I got this error, when I try to use getSquare, or getJoinableSquareChats.

SquareException(errorCode=0, reason=u'An unknown error occurred. Please try again later.', errorExtraInfo=None)

getJoinedSquares() is fine and returning correct result.

I tried using this code :
print client.getJoinableSquareChats(mid, limit=3)

already tried to fill mid with user mid or square mid, but get the same result

am I using wrong format or I miss something somewhere?

how can i make autolike bot

elif "like" == msg.text:
                sender = msg._from
                typel = [1001,1002,1003,1004,1005,1006]
                hasil = line.getHomeProfile(mid=msg.to)
                st = hasil['result']['feeds']
                for i in range(len(st)):
                    test = st[i]
                    result = test['post']['postInfo']['postId']
                    # line.likePost(str(result), likeType=random.choice(typel))
                    line.likePost(mid=line.profile.mid, postId=result)

                    # line.createComment(str(sender), str(result), 'Auto Like by none')
                line.sendMessage(receiver, 'Like & Comment '+str(len(st))+' Post From None')

there is no error.but not successfully.
help me :(

GroupPost

Does anyone know how to craete a group post?
I have already try createGroupPost, but however how hard I had tried, it still post on my home, I had already try to put the gid and mid in the needed in createGroupPost, but both are unuseful,help~~~~~~
thx QAQQQQQQQQQ

Update Notice for version 3 of linepy

What update?

  1. Support Thrift version 0.11.0
  2. Not support for Python 2.x, please update your Python 2.x to Python 3.x (Recommended 3.6)
  3. Rename LineClient instance as LINE instance, it will be notice after update version 3.0.0
  4. Rename LinePoll instance as OEPoll instance, it will be notice after update version 3.0.0
  5. LineTimeline, LineCall, LineAuth, LineTalk, LineChannel will be renamed without 'Line'
  6. LineTimeline will be merged to LINE instance
  7. Some several bug will be fixed
  8. Implement new feature in LINE Square

EOFError

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "linepy/client.py", line 24, in __init__
    self.qrLogin(keepLoggedIn=keepLoggedIn, systemName=systemName, appName=appName, showQr=showQr)
  File "linepy/api.py", line 121, in qrLogin
    self.tokenLogin(result.authToken, appName)
  File "linepy/api.py", line 133, in tokenLogin
    self.loadSession()
  File "linepy/api.py", line 30, in loadSession
    self.revision = self.poll.getLastOpRevision()
  File "/usr/local/lib/python2.7/dist-packages/akad/TalkService.py", line 3440, in getLastOpRevision
    return self.recv_getLastOpRevision()
  File "/usr/local/lib/python2.7/dist-packages/akad/TalkService.py", line 3451, in recv_getLastOpRevision
    (fname, mtype, rseqid) = iprot.readMessageBegin()
  File "/usr/local/lib/python2.7/dist-packages/thrift/protocol/TCompactProtocol.py", line 323, in readMessageBegin
    proto_id = self.__readUByte()
  File "/usr/local/lib/python2.7/dist-packages/thrift/protocol/TCompactProtocol.py", line 302, in __readUByte
    result, = unpack('!B', self.trans.readAll(1))
  File "/usr/local/lib/python2.7/dist-packages/thrift/transport/TTransport.py", line 65, in readAll
    raise EOFError()
EOFError

Today LINE server got updated. I use this module for my project and now I cannot login or update my work. Please help

Error login;revoke

Input this PIN code '0002' on your LINE for smartphone in 2 minutes
[2018-02-08 19:46:33.156521] [mønö] : Login success
[2018-02-08 19:46:44.130510] Your LINE account is not support Square
Traceback (most recent call last):
File "e.py", line 4, in
line = LINE('****@gmail.com', '*****)
File "/data/data/com.termux/files/home/line-py/line-py/line-py/linepy/client.py", line 22, in init
self.__initAll()
File "/data/data/com.termux/files/home/line-py/line-py/line-py/linepy/client.py", line 33, in __initAll
Timeline.init(self)
File "/data/data/com.termux/files/home/line-py/line-py/line-py/linepy/timeline.py", line 18, in init
Channel.init(self, self.channel, self.server.CHANNEL_ID['LINE_TIMELINE'], False)
File "/data/data/com.termux/files/home/line-py/line-py/line-py/linepy/channel.py", line 20, in init
self.__loginChannel()
File "/data/data/com.termux/files/home/line-py/line-py/line-py/linepy/channel.py", line 27, in __loginChannel
self.channelResult = self.approveChannelAndIssueChannelToken(self.channelId)
File "/data/data/com.termux/files/home/line-py/line-py/line-py/linepy/channel.py", line 6, in checkLogin
return func(*args, **kwargs)
File "/data/data/com.termux/files/home/line-py/line-py/line-py/linepy/channel.py", line 41, in approveChannelAndIssueChannelToken
return self.client.approveChannelAndIssueChannelToken(channelId)
File "/data/data/com.termux/files/usr/lib/python3.6/site-packages/akad/ChannelService.py", line 243, in approveChannelAndIssueChannelToken
return self.recv_approveChannelAndIssueChannelToken()
File "/data/data/com.termux/files/usr/lib/python3.6/site-packages/akad/ChannelService.py", line 267, in recv_approveChannelAndIssueChannelToken
raise result.e
akad.ttypes.ChannelException: ChannelException(code=3, reason='REVOKE', parameterMap=None)

What i have to do ?

Make start and size for getActivePurchases kwargs

instead of:
getActivePurchases(start,size,country,language)
can it please be:
getActivePurchases(country, language, start=0, size=99999)
because i think people might be confused as to how to use it otherwise

Remove Message Error

I try using func removeMessage, and thats doesnt work. But i forgot the error code :v

Validity concerns

I am concern for ban. I have some question?

  1. Do you emulate mobile or desktop line client. Can you show how do you sniff packet?

  2. How can I get official value from official line client.
    'User-Agent' -> 'Line/7.18.1'
    'X-Line-Application' -> 'DESKTOPWIN 7.18.1 FDLRCN 11.2.5'

  3. Is there a need for this because from above it say that it is Windows.
    'X-Line-Carrier' -> '51089, 1-0' -> Hutchison CP Telecommunications

Thanks

Cannot login

Hi, please help, now i cant login using link provided when start, before it is work, is it from Line that change something?

Traceback (most recent call last):
File "E:/SHARE/scripts/line-py-master/singletrace.py", line 4, in
client = LineClient()
File "E:\SHARE\scripts\line-py-master\linepy\client.py", line 24, in init
self.qrLogin(keepLoggedIn=keepLoggedIn, systemName=systemName, appName=appName, showQr=showQr)
File "E:\SHARE\scripts\line-py-master\linepy\api.py", line 121, in qrLogin
self.tokenLogin(result.authToken, appName)
File "E:\SHARE\scripts\line-py-master\linepy\api.py", line 133, in tokenLogin
self.loadSession()
File "E:\SHARE\scripts\line-py-master\linepy\api.py", line 30, in loadSession
self.revision = self.poll.getLastOpRevision()
File "build\bdist.win32\egg\akad\TalkService.py", line 3440, in getLastOpRevision
File "build\bdist.win32\egg\akad\TalkService.py", line 3463, in recv_getLastOpRevision
akad.ttypes.TalkException: TalkException(parameterMap=None, reason=u'LOG_OUT', code=8)

Can't Login with mail and password

Input this PIN code '7739' on your LINE for smartphone in 2 minutes
Traceback (most recent call last):
File "...linepy\auth.py", line 123, in login
'e2eeVersion': 0
File "...linepy\auth.py", line 48, in loginRequest
if data['identityProvider']:
KeyError: 'identityProvider'

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 3, in
cl = LineClient(id=mail,passwd=password)
File "...linepy\client.py", line 26, in init
self.login(_id=id, passwd=passwd, certificate=certificate, systemName=systemName, appName=appName, keepLoggedIn=keepLoggedIn)
File "...linepy\auth.py", line 127, in login
raise Exception("Login failed")
Exception: Login failed

When I login with email and password, these error happen.
Would you please fix it?

I tested with Python 3.6.4, akad 0.10.21, and line-py 2.0.1.

How to use timeline?

I had successfully login to line but can't find a way to call timeline function.
Can someone give me a example.
Thanks

Edit:
I found a way. Forgot to read changelog

you can call by
line.getFeed()
line.getHomeProfile()
....

Internal Error

Hello, i have a problem.
I use code, this:

-- coding: utf-8 --

from linepy import *

client = LineClient()
#client = LineClient(authToken='AUTHTOKEN')

client.log("Auth Token : " + str(client.authToken))

Then, i got result Internal Error :

akad.ttypes.TalkException: TalkException(parameterMap=None, reason=u'Internal error', code=20)

How?

Error When Logging

[2018-01-19 17:37:18.940952] Your LINE account is not support Square
And
akad.ttypes.ChannelException: ChannelException(parameterMap=None, reason='REVOKE', code=3)

message.text is None

when i dump op give me this result

#0 object(Operation) (10)
    status => NoneType(None)
    checksum => NoneType(None)
    param3 => NoneType(None)
    param2 => NoneType(None)
    param1 => unicode(1) "0"
    createdTime => long(1511712185926)
    message => object(Message) (12)
        contentType => int(0)
        hasContent => bool(False)
        text => NoneType(None)
        id => unicode(13) "7050489046752"
        to => unicode(33) "c14b6920b17ab40622eddd4178b532212"
        contentPreview => NoneType(None)
        location => NoneType(None)
        deliveredTime => int(0)
        createdTime => long(1511712185884)
        _from => unicode(33) "ua3b2f4575c3ff9d01cafa79f471b8fc7"
        contentMetadata => dict(1)
            ['e2eeVersion'] => unicode(1) "1"
        toType => int(2)
    reqSeq => int(0)
    type => int(26)
    revision => int(46519)

addfrienderror

when someone add me I use findAndAddContactsByMid(op.param1) to add him , and this is successful but when I want to send some notify message to him , and it is error, and system give an error message to me like this

[2018-06-08 09:10:50.346069] TalkException(code=82, reason='can not send using plain mode', parameterMap=None)

does anyone know how to fix it???
thx!!!

Login error when sending message several times

After sending the message several times, a login error occurs and the following error appears.
What does this error message mean?
(login by email and password)

akad.ttypes.TalkException: TalkException(code=20, reason='[UNCAUGHT_INTERNAL_ERROR] [UNCAUGHT_INTERNAL_ERROR] Login from secondary user blocked by userHash + clientType 7381a......', parameterMap=None)

Is there anything way to avoid this error?

Square

What channel id for square? For acces and login square

how to make a read bot

I want to make a bot to get the mid who has read and then turn into name, finally send it to the group
......but I have some problem......
who can help me QAQ
THANKS~~~

fix pls

from linepy import *
Traceback (most recent call last):
File "", line 1, in
File "linepy_init_.py", line 1, in
from .client import LineClient
File "linepy\client.py", line 4, in
from .models import LineModels
File "linepy\models.py", line 2, in
from .channel import LineChannel
File "linepy\channel.py", line 2, in
from .client import LineClient
ImportError: cannot import name LineClient
image

SINGLETRACE ERROR

i use single trace, sometimes i got error like this, ramdomly, wht should i do?
image

Suggestion wait kwarg for unsendMessage

unsendMessage(self, messageID, wait=0)
and if wait is bigger than 0, wait that amount of time before unsending the message.
i would suggest code using threading, but im sure u can come up with that (or better) yourself.

stop responding from user input

while True:
    poll.trace()

5 minutes is working, but next minutes cant respond from user input.
like when i send to bot, its always autoread, but sometimes is not autoread

acceptGroupInvitationByTicket error?

I have two bot ,and one will send join to a group with the ticket and gid which i want to in but it can't work
and I don't know where is wrong here is the code
the first bot

elif text.lower() == 'invite':
                    ticket = cl.reissueGroupTicket(to)
                    G = cl.getGroup(to)
                    if G.preventedJoinByTicket == False:
                        pass
                    else:
                        G.preventedJoinByTicket = False
                        cl.updateGroup(G)
                    cl.sendMessage("c02fb6eba0220cef6c6f82d8e15c458b6", "join_"+format(str(ticket))+'_'+G.id)

and here is the second bot

elif "join" in msg.text:
                    list_ = msg.text.split("_")
                    try:
                        cl.acceptGroupInvitationByTicket(list_[1],list_[2])
                        G = cl.getGroup(list_[1])
                        G.preventedJoinByTickets = True
                        cl.updateGroup(G)
                    except:
                        cl.sendMessage(msg.to,"error\n"+list_[1]+'\n'+list_[2])

how hard I try but it still doesn't work ,so who can help me fix this ,THX

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.