Commit 18a7302e6c9e3c9fc319fc08db8f31b60e8ce0f4

Authored by rizqiqiqi
Committed by GitHub
1 parent 928d2916

Add files via upload

LineAlpha/.DS_Store 0 → 100644
No preview for this file type
LineAlpha/LineApi.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +from Api import Poll, Talk, channel
  3 +from lib.Gen.ttypes import *
  4 +
  5 +def def_callback(str):
  6 + print(str)
  7 +
  8 +class LINE:
  9 +
  10 + mid = None
  11 + authToken = None
  12 + cert = None
  13 + channel_access_token = None
  14 + token = None
  15 + obs_token = None
  16 + refresh_token = None
  17 +
  18 +
  19 + def __init__(self):
  20 + self.Talk = Talk()
  21 +
  22 + def login(self, mail=None, passwd=None, cert=None, token=None, qr=False, callback=None):
  23 + if callback is None:
  24 + callback = def_callback
  25 + resp = self.__validate(mail,passwd,cert,token,qr)
  26 + if resp == 1:
  27 + self.Talk.login(mail, passwd, callback=callback)
  28 + elif resp == 2:
  29 + self.Talk.login(mail,passwd,cert, callback=callback)
  30 + elif resp == 3:
  31 + self.Talk.TokenLogin(token)
  32 + elif resp == 4:
  33 + self.Talk.qrLogin(callback)
  34 + else:
  35 + raise Exception("invalid arguments")
  36 +
  37 + self.authToken = self.Talk.authToken
  38 + self.cert = self.Talk.cert
  39 +
  40 + self.Poll = Poll(self.authToken)
  41 + self.channel = channel.Channel(self.authToken)
  42 + self.channel.login()
  43 +
  44 + self.mid = self.channel.mid
  45 + self.channel_access_token = self.channel.channel_access_token
  46 + self.token = self.channel.token
  47 + self.obs_token = self.channel.obs_token
  48 + self.refresh_token = self.channel.refresh_token
  49 +
  50 +
  51 + """User"""
  52 +
  53 + def getProfile(self):
  54 + return self.Talk.client.getProfile()
  55 +
  56 + def getSettings(self):
  57 + return self.Talk.client.getSettings()
  58 +
  59 + def getUserTicket(self):
  60 + return self.Talk.client.getUserTicket()
  61 +
  62 + def updateProfile(self, profileObject):
  63 + return self.Talk.client.updateProfile(0, profileObject)
  64 +
  65 + def updateSettings(self, settingObject):
  66 + return self.Talk.client.updateSettings(0, settingObject)
  67 +
  68 +
  69 + """Operation"""
  70 +
  71 + def fetchOperation(self, revision, count):
  72 + return self.Poll.client.fetchOperations(revision, count)
  73 +
  74 + def fetchOps(self, rev, count):
  75 + return self.Poll.client.fetchOps(rev, count, 0, 0)
  76 +
  77 + def getLastOpRevision(self):
  78 + return self.Talk.client.getLastOpRevision()
  79 +
  80 + def stream(self):
  81 + return self.Poll.stream()
  82 +
  83 + """Message"""
  84 +
  85 + def sendMessage(self, messageObject):
  86 + return self.Talk.client.sendMessage(0,messageObject)
  87 +
  88 + def sendText(self, tomid, text):
  89 + msg = Message()
  90 + msg.to = tomid
  91 + msg.text = text
  92 +
  93 + return self.Talk.client.sendMessage(0, msg)
  94 +
  95 + def sendChatChecked(self, mid, lastMessageId):
  96 + return self.Talk.client.sendChatChecked(0, mid, lastMessageId)
  97 +
  98 + def getMessageBoxCompactWrapUp(self, mid):
  99 + return self.Talk.client.getMessageBoxCompactWrapUp(mid)
  100 +
  101 + def getMessageBoxCompactWrapUpList(self, start, messageBox):
  102 + return self.Talk.client.getMessageBoxCompactWrapUpList(start, messageBox)
  103 +
  104 + def getRecentMessages(self, messageBox, count):
  105 + return self.Talk.client.getRecentMessages(messageBox.id, count)
  106 +
  107 + def getMessageBox(self, channelId, messageboxId, lastMessagesCount):
  108 + return self.Talk.client.getMessageBox(channelId, messageboxId, lastMessagesCount)
  109 +
  110 + def getMessageBoxList(self, channelId, lastMessagesCount):
  111 + return self.Talk.client.getMessageBoxList(channelId, lastMessagesCount)
  112 +
  113 + def getMessageBoxListByStatus(self, channelId, lastMessagesCount, status):
  114 + return self.Talk.client.getMessageBoxListByStatus(channelId, lastMessagesCount, status)
  115 +
  116 + def getMessageBoxWrapUp(self, mid):
  117 + return self.Talk.client.getMessageBoxWrapUp(mid)
  118 +
  119 + def getMessageBoxWrapUpList(self, start, messageBoxCount):
  120 + return self.Talk.client.getMessageBoxWrapUpList(start, messageBoxCount)
  121 +
  122 + """Contact"""
  123 +
  124 +
  125 + def blockContact(self, mid):
  126 + return self.Talk.client.blockContact(0, mid)
  127 +
  128 +
  129 + def unblockContact(self, mid):
  130 + return self.Talk.client.unblockContact(0, mid)
  131 +
  132 +
  133 + def findAndAddContactsByMid(self, mid):
  134 + return self.Talk.client.findAndAddContactsByMid(0, mid)
  135 +
  136 +
  137 + def findAndAddContactsByMids(self, midlist):
  138 + for i in midlist:
  139 + self.Talk.client.findAndAddContactsByMid(0, i)
  140 +
  141 + def findAndAddContactsByUserid(self, userid):
  142 + return self.Talk.client.findAndAddContactsByUserid(0, userid)
  143 +
  144 + def findContactsByUserid(self, userid):
  145 + return self.Talk.client.findContactByUserid(userid)
  146 +
  147 + def findContactByTicket(self, ticketId):
  148 + return self.Talk.client.findContactByUserTicket(ticketId)
  149 +
  150 + def getAllContactIds(self):
  151 + return self.Talk.client.getAllContactIds()
  152 +
  153 + def getBlockedContactIds(self):
  154 + return self.Talk.client.getBlockedContactIds()
  155 +
  156 + def getContact(self, mid):
  157 + return self.Talk.client.getContact(mid)
  158 +
  159 + def getContacts(self, midlist):
  160 + return self.Talk.client.getContacts(midlist)
  161 +
  162 + def getFavoriteMids(self):
  163 + return self.Talk.client.getFavoriteMids()
  164 +
  165 + def getHiddenContactMids(self):
  166 + return self.Talk.client.getHiddenContactMids()
  167 +
  168 +
  169 + """Group"""
  170 +
  171 + def acceptGroupInvitation(self, groupId):
  172 + return self.Talk.client.acceptGroupInvitation(0, groupId)
  173 +
  174 + def acceptGroupInvitationByTicket(self, groupId, ticketId):
  175 + return self.Talk.client.acceptGroupInvitationByTicket(0, groupId, ticketId)
  176 +
  177 + def cancelGroupInvitation(self, groupId, contactIds):
  178 + return self.Talk.client.cancelGroupInvitation(0, groupId, contactIds)
  179 +
  180 + def createGroup(self, name, midlist):
  181 + return self.Talk.client.createGroup(0, name, midlist)
  182 +
  183 + def getGroup(self, groupId):
  184 + return self.Talk.client.getGroup(groupId)
  185 +
  186 + def getGroups(self, groupIds):
  187 + return self.Talk.client.getGroups(groupIds)
  188 +
  189 + def getGroupIdsInvited(self):
  190 + return self.Talk.client.getGroupIdsInvited()
  191 +
  192 + def getGroupIdsJoined(self):
  193 + return self.Talk.client.getGroupIdsJoined()
  194 +
  195 + def inviteIntoGroup(self, groupId, midlist):
  196 + return self.Talk.client.inviteIntoGroup(0, groupId, midlist)
  197 +
  198 + def kickoutFromGroup(self, groupId, midlist):
  199 + return self.Talk.client.kickoutFromGroup(0, groupId, midlist)
  200 +
  201 + def leaveGroup(self, groupId):
  202 + return self.Talk.client.leaveGroup(0, groupId)
  203 +
  204 + def rejectGroupInvitation(self, groupId):
  205 + return self.Talk.client.rejectGroupInvitation(0, groupId)
  206 +
  207 + def reissueGroupTicket(self, groupId):
  208 + return self.Talk.client.reissueGroupTicket(groupId)
  209 +
  210 + def updateGroup(self, groupObject):
  211 + return self.Talk.client.updateGroup(0, groupObject)
  212 +
  213 + """Room"""
  214 +
  215 + def createRoom(self, midlist):
  216 + return self.Talk.client.createRoom(0, midlist)
  217 +
  218 + def getRoom(self, roomId):
  219 + return self.Talk.client.getRoom(roomId)
  220 +
  221 + def inviteIntoRoom(self, roomId, midlist):
  222 + return self.Talk.client.inviteIntoRoom(0, roomId, midlist)
  223 +
  224 + def leaveRoom(self, roomId):
  225 + return self.Talk.client.leaveRoom(0, roomId)
  226 +
  227 + """TIMELINE"""
  228 +
  229 + def new_post(self, text):
  230 + return self.channel.new_post(text)
  231 +
  232 + def new_note(self, gid, text):
  233 + return self.channel.new_note(gid, text)
  234 +
  235 + def like(self, mid, postid, likeType=1001):
  236 + return self.channel.like(mid, postid, likeType)
  237 +
  238 + def comment(self, mid, postid, text):
  239 + return self.channel.comment(mid, postid, text)
  240 +
  241 + def activity(self, limit=20):
  242 + return self.channel.activity(limit)
  243 +
  244 + def getAlbum(self, gid):
  245 + return self.channel.getAlbum(gid)
  246 +
  247 + def changeAlbumName(self, gid, name, albumId):
  248 + return self.channel.changeAlbumName(gid, name, albumId)
  249 +
  250 + def deleteAlbum(self, gid, albumId):
  251 + return self.channel.deleteAlbum(gid,albumId)
  252 +
  253 + def getNote(self,gid, commentLimit, likeLimit):
  254 + return self.channel.getNote(gid, commentLimit, likeLimit)
  255 +
  256 + def getDetail(self,mid):
  257 + return self.channel.getDetail(mid)
  258 +
  259 + def getHome(self,mid):
  260 + return self.channel.getHome(mid)
  261 +
  262 + def createAlbum(self, gid, name):
  263 + return self.channel.createAlbum(gid,name)
  264 +
  265 + def createAlbum2(self, gid, name, path):
  266 + return self.channel.createAlbum(gid, name, path, oid)
  267 +
  268 +
  269 + def __validate(self, mail, passwd, cert, token, qr):
  270 + if mail is not None and passwd is not None and cert is None:
  271 + return 1
  272 + elif mail is not None and passwd is not None and cert is not None:
  273 + return 2
  274 + elif token is not None:
  275 + return 3
  276 + elif qr is True:
  277 + return 4
  278 + else:
  279 + return 5
  280 +
  281 + def loginResult(self, callback=None):
  282 + if callback is None:
  283 + callback = def_callback
  284 +
  285 + prof = self.getProfile()
  286 +
  287 + print("---HelloSeyu---\n")
  288 + print("[Mid] -> " + prof.mid)
  289 + print("[Name] -> " + prof.displayName)
  290 + print("[AuthToken] -> " + self.authToken)
  291 + print("[Cert] -> " + self.cert if self.cert is not None else "")
  292 + print("---------------------\n")
... ...
LineAlpha/LineApi.pyc 0 → 100644
No preview for this file type
LineAlpha/__init__.py 0 → 100644
  1 +# -*- coding: utf-8 -*-
  2 +from LineApi import LINE
  3 +from lib.Gen.ttypes import *
... ...
LineAlpha/__init__.pyc 0 → 100644
No preview for this file type
LineAlpha/kongou.py 0 → 100644
No preview for this file type
LineAlpha/st2 json.py 0 → 100644
  1 +#-*-coding:utf8;-*-
  2 +#qpy:2
  3 +#qpy:console
  4 +
  5 +print "This is console module"
  6 +{}
0 7 \ No newline at end of file
... ...