├── KIA ├── 1 ├── B ├── Yue ├── sya ├── __init__.py ├── callback.py ├── call.py ├── client.py ├── config.py ├── poll.py ├── session.py ├── server.py ├── channel.py ├── models.py ├── object.py ├── auth.py ├── square.py ├── timeline.py └── talk.py ├── akad ├── Agi ├── Ohy ├── __pycache__ │ ├── Ndos │ ├── __init__.cpython-36.pyc │ ├── ttypes.cpython-36.pyc │ ├── AuthService.cpython-36.pyc │ ├── CallService.cpython-36.pyc │ ├── SquareService.cpython-36.pyc │ ├── TalkService.cpython-36.pyc │ └── ChannelService.cpython-36.pyc ├── __init__.py ├── constants.py └── UniversalNotificationService.py ├── thrift ├── Ana ├── Dus ├── server │ ├── Sue │ ├── imports.py │ ├── __init__.py │ ├── THttpServer.py │ ├── TProcessPoolServer.py │ ├── TServer.py │ └── TNonblockingServer.py ├── __pycache__ │ ├── Rww │ ├── Thrift.cpython-36.pyc │ ├── compat.cpython-36.pyc │ └── __init__.cpython-36.pyc ├── protocol │ ├── Jue │ ├── Oka │ ├── bot │ ├── __pycache__ │ │ ├── B │ │ ├── Jues │ │ ├── TProtocol.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── TCompactProtocol.cpython-36.pyc │ ├── fastbinary.cpython-35m-x86_64-linux-gnu.so │ ├── __init__.py │ ├── TMultiplexedProtocol.py │ ├── TProtocolDecorator.py │ ├── TBase.py │ ├── TBinaryProtocol.py │ └── TProtocol.py ├── transport │ ├── Sai │ ├── __pycache__ │ │ ├── Rei │ │ ├── __init__.cpython-36.pyc │ │ ├── THttpClient.cpython-36.pyc │ │ └── TTransport.cpython-36.pyc │ ├── transportx.py │ ├── __init__.py │ ├── sslcompat.py │ ├── TZlibTransport.py │ ├── THttpClient.py │ ├── TSocket.py │ ├── TTransport.py │ └── TTwisted.py ├── compat.py ├── TSCons.py ├── TSerialization.py ├── __init__.py ├── boxup.py ├── TMultiplexedProcessor.py ├── TRecursive.py ├── unverting.py ├── Thrift.py └── TTornado.py ├── README.md ├── st2__b.json ├── admin.json ├── image.json ├── owner.json ├── video.json ├── audio.json ├── creator.json ├── Log_data.json ├── read.json ├── sticker.json ├── setting.json ├── publik.json ├── wait.json ├── .gitignore ├── settings.json ├── sider.json └── temp.json /KIA/1: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /KIA/B: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /KIA/Yue: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /KIA/sya: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /akad/Agi: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /akad/Ohy: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/Ana: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/Dus: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BY:SADIS 2 | -------------------------------------------------------------------------------- /thrift/server/Sue: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /akad/__pycache__/Ndos: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/__pycache__/Rww: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/protocol/Jue: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/protocol/Oka: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/protocol/bot: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/transport/Sai: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/server/imports.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/protocol/__pycache__/B: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/protocol/__pycache__/Jues: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/transport/__pycache__/Rei: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /thrift/transport/transportx.py: -------------------------------------------------------------------------------- 1 | creator mod by prankbots 2 | -------------------------------------------------------------------------------- /st2__b.json: -------------------------------------------------------------------------------- 1 | { 2 | "uf50d888821632d32461e37153ac775c0": true 3 | } -------------------------------------------------------------------------------- /admin.json: -------------------------------------------------------------------------------- 1 | { 2 | "uf50d888821632d32461e37153ac775c0": true 3 | } 4 | -------------------------------------------------------------------------------- /image.json: -------------------------------------------------------------------------------- 1 | { 2 | "u80abbfcbdc60a0a266c807a0dad66b1b": true 3 | } 4 | -------------------------------------------------------------------------------- /owner.json: -------------------------------------------------------------------------------- 1 | { 2 | "uf50d888821632d32461e37153ac775c0": true 3 | } 4 | -------------------------------------------------------------------------------- /video.json: -------------------------------------------------------------------------------- 1 | { 2 | "u80abbfcbdc60a0a266c807a0dad66b1b": true 3 | } 4 | -------------------------------------------------------------------------------- /audio.json: -------------------------------------------------------------------------------- 1 | { 2 | "u80abbfcbdc60a0a266c807a0dad66b1b": true 3 | } 4 | -------------------------------------------------------------------------------- /creator.json: -------------------------------------------------------------------------------- 1 | { 2 | "uf50d888821632d32461e37153ac775c0": true 3 | } 4 | -------------------------------------------------------------------------------- /akad/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/akad/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /akad/__pycache__/ttypes.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/akad/__pycache__/ttypes.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/__pycache__/Thrift.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/__pycache__/Thrift.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/__pycache__/compat.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/__pycache__/compat.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /akad/__pycache__/AuthService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/akad/__pycache__/AuthService.cpython-36.pyc -------------------------------------------------------------------------------- /akad/__pycache__/CallService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/akad/__pycache__/CallService.cpython-36.pyc -------------------------------------------------------------------------------- /akad/__pycache__/SquareService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/akad/__pycache__/SquareService.cpython-36.pyc -------------------------------------------------------------------------------- /akad/__pycache__/TalkService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/akad/__pycache__/TalkService.cpython-36.pyc -------------------------------------------------------------------------------- /akad/__pycache__/ChannelService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/akad/__pycache__/ChannelService.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/protocol/__pycache__/TProtocol.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/protocol/__pycache__/TProtocol.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/protocol/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/protocol/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/transport/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/transport/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/transport/__pycache__/THttpClient.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/transport/__pycache__/THttpClient.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/transport/__pycache__/TTransport.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/transport/__pycache__/TTransport.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/protocol/__pycache__/TCompactProtocol.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/protocol/__pycache__/TCompactProtocol.cpython-36.pyc -------------------------------------------------------------------------------- /thrift/protocol/fastbinary.cpython-35m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stya535/SOLO/HEAD/thrift/protocol/fastbinary.cpython-35m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /thrift/server/__init__.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | __all__ = ['TServer', 'TNonblockingServer'] 5 | -------------------------------------------------------------------------------- /Log_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "7480698417075": { 3 | "from": "ue0b00ae336031f1e931df706e11cd05a", 4 | "text": "Siap\" aja", 5 | "createdTime": 1518704530922 6 | } 7 | } -------------------------------------------------------------------------------- /thrift/transport/__init__.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | __all__ = ['TTransport', 'TSocket', 'THttpClient', 'TZlibTransport'] 5 | -------------------------------------------------------------------------------- /akad/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['ttypes', 'constants', 'AccountSupervisorService', 'AgeCheckService', 'BuddyManagementService', 'BuddyService', 'ChannelApplicationProvidedService', 'ChannelService', 'MessageService', 'ShopService', 'SnsAdaptorService', 'TalkService', 'UniversalNotificationService', 'CallService', 'AuthService', 'SquareService'] 2 | -------------------------------------------------------------------------------- /read.json: -------------------------------------------------------------------------------- 1 | { 2 | "ROM": { 3 | "c4b2765cee5458a6ad5b556782f88b1d0": {} 4 | }, 5 | "readMember": { 6 | "c4b2765cee5458a6ad5b556782f88b1d0": "" 7 | }, 8 | "readPoint": { 9 | "c4b2765cee5458a6ad5b556782f88b1d0": "7893371380452" 10 | }, 11 | "readTime": { 12 | "c4b2765cee5458a6ad5b556782f88b1d0": "21:22:36" 13 | } 14 | } -------------------------------------------------------------------------------- /akad/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.10.0) 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | # options string: py 7 | # 8 | 9 | from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException 10 | from thrift.protocol.TProtocol import TProtocolException 11 | import sys 12 | from .ttypes import * 13 | -------------------------------------------------------------------------------- /KIA/__init__.py: -------------------------------------------------------------------------------- 1 | from .client import LineClient 2 | from .channel import LineChannel 3 | from .poll import LinePoll 4 | from akad.ttypes import OpType 5 | 6 | __copyright__ = 'Copyright 2017 by Fadhiil Rachman' 7 | __version__ = '2.0.2' 8 | __license__ = 'BSD-3-Clause' 9 | __author__ = 'Fadhiil Rachman' 10 | __author_email__ = 'fadhiilrachman@gmail.com' 11 | __url__ = 'http://github.com/fadhiilrachman/line-py' 12 | 13 | __all__ = ['LineClient', 'LineChannel', 'LinePoll', 'OpType'] -------------------------------------------------------------------------------- /thrift/compat.py: -------------------------------------------------------------------------------- 1 | #COMPAT INI UNTUK STRINGIO KE BINARY 2 | #ACIL. MOD 3 | 4 | import sys 5 | 6 | if sys.version_info[0] == 2: 7 | 8 | from cStringIO import StringIO as BufferIO 9 | 10 | def binary_to_str(bin_val): 11 | return bin_val 12 | 13 | def str_to_binary(str_val): 14 | return str_val 15 | 16 | else: 17 | 18 | from io import BytesIO as BufferIO # noqa 19 | 20 | def binary_to_str(bin_val): 21 | return bin_val.decode('utf8') 22 | 23 | def str_to_binary(str_val): 24 | return bytes(str_val, 'utf8') 25 | -------------------------------------------------------------------------------- /thrift/TSCons.py: -------------------------------------------------------------------------------- 1 | #Inerval pyc scons 2 | 3 | from os import path 4 | from SCons.Builder import Builder 5 | from six.moves import map 6 | def scons_env(env, add=''): 7 | opath = path.dirname(path.abspath('$TARGET')) 8 | lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE' 9 | cppbuild = Builder(action=lstr) 10 | env.Append(BUILDERS={'ThriftCpp': cppbuild}) 11 | 12 | 13 | def gen_cpp(env, dir, file): 14 | scons_env(env) 15 | suffixes = ['_types.h', '_types.cpp'] 16 | targets = map(lambda s: 'gen-cpp/' + file + s, suffixes) 17 | return env.ThriftCpp(targets, dir + file + '.thrift') 18 | -------------------------------------------------------------------------------- /thrift/TSerialization.py: -------------------------------------------------------------------------------- 1 | #MODIFED BY PRANKBOT 2 | from .protocol import TBinaryProtocol 3 | from .transport import TTransport 4 | def serialize(thrift_object, 5 | protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()): 6 | transport = TTransport.TMemoryBuffer() 7 | protocol = protocol_factory.getProtocol(transport) 8 | thrift_object.write(protocol) 9 | return transport.getvalue() 10 | def deserialize(base, 11 | buf, 12 | protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()): 13 | transport = TTransport.TMemoryBuffer(buf) 14 | protocol = protocol_factory.getProtocol(transport) 15 | base.read(protocol) 16 | return base 17 | -------------------------------------------------------------------------------- /KIA/callback.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | class Callback(object): 3 | 4 | def __init__(self, callback): 5 | self.callback = callback 6 | 7 | def PinVerified(self, pin): 8 | self.callback("Input this PIN code '" + pin + "' on your LINE for smartphone in 2 minutes") 9 | 10 | def QrUrl(self, url, showQr=True): 11 | if showQr: 12 | notice="or scan this QR " 13 | else: 14 | notice="" 15 | self.callback("Open this link " + notice + "on your LINE for smartphone in 2 minutes\n" + url) 16 | if showQr: 17 | try: 18 | import pyqrcode 19 | url = pyqrcode.create(url) 20 | self.callback(url.terminal('green', 'white', 1)) 21 | except: 22 | pass 23 | 24 | def default(self, str): 25 | self.callback(str) -------------------------------------------------------------------------------- /thrift/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | __all__ = ['Thrift', 'TSCons'] 21 | -------------------------------------------------------------------------------- /sticker.json: -------------------------------------------------------------------------------- 1 | { 2 | "wkwk": { 3 | "STKID": "100", 4 | "STKPKGID": "1" 5 | }, 6 | "hehehe": { 7 | "STKID": "10", 8 | "STKPKGID": "1" 9 | }, 10 | "galon": { 11 | "STKID": "9", 12 | "STKPKGID": "1" 13 | }, 14 | "you": { 15 | "STKID": "7", 16 | "STKPKGID": "1" 17 | }, 18 | "hadeuh": { 19 | "STKID": "6", 20 | "STKPKGID": "1" 21 | }, 22 | "please": { 23 | "STKID": "4", 24 | "STKPKGID": "1" 25 | }, 26 | "haaa": { 27 | "STKID": "3", 28 | "STKPKGID": "1" 29 | }, 30 | "lol": { 31 | "STKID": "110", 32 | "STKPKGID": "1" 33 | }, 34 | "hmmm": { 35 | "STKID": "101", 36 | "STKPKGID": "1" 37 | }, 38 | "selfi": { 39 | "STKID": "18687408", 40 | "STKPKGID": "1520987" 41 | }, 42 | "omg": { 43 | "STKID": "18687401", 44 | "STKPKGID": "1520987" 45 | }, 46 | "wow": { 47 | "STKID": "18687397", 48 | "STKPKGID": "1520987" 49 | }, 50 | "woah": { 51 | "STKID": "18687404", 52 | "STKPKGID": "1520987" 53 | } 54 | } -------------------------------------------------------------------------------- /thrift/protocol/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | __all__ = ['fastbinary', 'TBase', 'TBinaryProtocol', 'TCompactProtocol', 21 | 'TJSONProtocol', 'TProtocol'] 22 | -------------------------------------------------------------------------------- /thrift/protocol/TMultiplexedProtocol.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from thrift.unverting import TMessageType 5 | from thrift.protocol import TProtocolDecorator 6 | SEPARATOR = ":" 7 | Dreamstuck = "Creator By:PrankBots\n" 8 | class TMultiplexedProtocol(TProtocolDecorator.TProtocolDecorator): 9 | def __init__(self, protocol, serviceName): 10 | TProtocolDecorator.TProtocolDecorator.__init__(self, protocol) 11 | self.serviceName = serviceName 12 | def writeMessageBegin(self, name, type, seqid): 13 | if (type == TMessageType.CALL or 14 | type == TMessageType.ONEWAY): 15 | self.protocol.writeMessageBegin( 16 | self.serviceName + Dreamstuck + SEPARATOR + name, 17 | type, 18 | seqid 19 | ) 20 | else: 21 | self.protocol.writeMessageBegin(name, type, seqid) 22 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 23 | #CREATOR BY : PRANKBOT 24 | #MOD BY ACIL -------------------------------------------------------------------------------- /setting.json: -------------------------------------------------------------------------------- 1 | { 2 | "restartPoint": {}, 3 | "restartBot": {}, 4 | "userAgent": {}, 5 | "keyCommand": "", 6 | "autoAdd": false, 7 | "autoJoin": false, 8 | "autoReject": false, 9 | "autoLeave": true, 10 | "autoRead": false, 11 | "server": {}, 12 | "changePicture": false, 13 | "changeGroupPicture": false, 14 | "autoJoinTicket": true, 15 | "Img": {}, 16 | "Images": {}, 17 | "Addimage": false, 18 | "ARAdmin": {}, 19 | "ARGfoto": {}, 20 | "ARSDadmin": false, 21 | "ARSDstaff": false, 22 | "ARSadmin": false, 23 | "ARSstaff": false, 24 | "ARStaff": {}, 25 | "ARautojoin": true, 26 | "ARautoread": false, 27 | "ARautoscan": false, 28 | "ARblacklist": {}, 29 | "ARdblacklist": false, 30 | "ARfoto": {}, 31 | "ARgreet": {}, 32 | "ARlimit": 5, 33 | "ARmessage": "Hallo...", 34 | "ARmessage1": "Chat with me", 35 | "ARprotcancel": {}, 36 | "ARprotinvite": {}, 37 | "ARprotkick": {}, 38 | "ARprotqr": {}, 39 | "ARreadMember": {}, 40 | "ARreadPoint": {}, 41 | "ARwblacklist": false 42 | } 43 | -------------------------------------------------------------------------------- /KIA/call.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from akad.ttypes import MediaType 3 | 4 | def loggedIn(func): 5 | def checkLogin(*args, **kwargs): 6 | if args[0].isLogin: 7 | return func(*args, **kwargs) 8 | else: 9 | args[0].callback.other("You want to call the function, you must login to LINE") 10 | return checkLogin 11 | 12 | class LineCall(object): 13 | isLogin = False 14 | client = None 15 | 16 | def __init__(self): 17 | self.isLogin = True 18 | 19 | @loggedIn 20 | def acquireCallRoute(self, to): 21 | return self.call.acquireCallRoute(to) 22 | 23 | @loggedIn 24 | def acquireGroupCallRoute(self, groupId, mediaType=MediaType.AUDIO): 25 | return self.call.acquireGroupCallRoute(groupId, mediaType) 26 | 27 | @loggedIn 28 | def getGroupCall(self, ChatMid): 29 | return self.call.getGroupCall(ChatMid) 30 | 31 | @loggedIn 32 | def inviteIntoGroupCall(self, chatId, contactIds=[], mediaType=MediaType.AUDIO): 33 | return self.call.inviteIntoGroupCall(chatId, contactIds, mediaType) -------------------------------------------------------------------------------- /publik.json: -------------------------------------------------------------------------------- 1 | { 2 | "restartPoint": {}, 3 | "restartBot": {}, 4 | "userAgent": {}, 5 | "keyCommand": "", 6 | "namecreator": "SADIS", 7 | "autoAdd": false, 8 | "autoJoin": false, 9 | "autoReject": True, 10 | "autoLeave": true, 11 | "autoRead": false, 12 | "server": {}, 13 | "changePicture": false, 14 | "changeGroupPicture": false, 15 | "autoJoinTicket": false, 16 | "Img": {}, 17 | "Images": {}, 18 | "Addimage": false, 19 | "ARAdmin": {}, 20 | "ARGfoto": {}, 21 | "ARSDadmin": false, 22 | "ARSDstaff": false, 23 | "ARSadmin": false, 24 | "ARSstaff": false, 25 | "ARStaff": {}, 26 | "ARautojoin": true, 27 | "ARautoread": false, 28 | "ARautoscan": false, 29 | "ARblacklist": {}, 30 | "ARdblacklist": false, 31 | "ARfoto": {}, 32 | "ARgreet": {}, 33 | "ARlimit": 1, 34 | "ARmessage": "Hallo...", 35 | "ARmessage1": "ADD ME", 36 | "ARprotcancel": {}, 37 | "ARprotinvite": {}, 38 | "ARprotkick": {}, 39 | "ARprotqr": {}, 40 | "ARreadMember": {}, 41 | "ARreadPoint": {}, 42 | "ARwblacklist": false 43 | } 44 | -------------------------------------------------------------------------------- /wait.json: -------------------------------------------------------------------------------- 1 | { 2 | "Mentiongift": false, 3 | "Mentionkick": false, 4 | "Respontag": "DUH KENA TAG LAGI AIM..", 5 | "Talkblacklist": {}, 6 | "Talkdblacklist": false, 7 | "Talkwblacklist": false, 8 | "addadmin": false, 9 | "addbots": false, 10 | "addstaff": false, 11 | "admin": {}, 12 | "autoAdd": true, 13 | "autoJoin": true, 14 | "autoLeave": false, 15 | "autoLeave1": false, 16 | "blacklist": {}, 17 | "bots": {}, 18 | "comment": "Like like & like", 19 | "contact": false, 20 | "dblacklist": false, 21 | "delladmin": false, 22 | "dellbots": false, 23 | "dellstaff": false, 24 | "detectMention": false, 25 | "leave": "Good Bye, See You Next Time 😃", 26 | "limit": 5, 27 | "mention": "NAH NGINTIP", 28 | "message": "Terimakasih sudah add saya 😃", 29 | "owner": {}, 30 | "selfbot": true, 31 | "staff": {}, 32 | "sticker": false, 33 | "talkban": true, 34 | "unsend": true, 35 | "wblacklist": false, 36 | "welcome": "Selamat datang ", 37 | "welcomeOn": false 38 | "protectantijsOn": true, 39 | "ghostOn": true, 40 | } 41 | -------------------------------------------------------------------------------- /thrift/protocol/TProtocolDecorator.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | import types 5 | from thrift.protocol.TProtocol import TProtocolBase 6 | class TProtocolDecorator(): 7 | def __init__(self, protocol): 8 | TProtocolBase(protocol) 9 | self.protocol = protocol 10 | def __getattr__(self, name): 11 | if hasattr(self.protocol, name): 12 | member = getattr(self.protocol, name) 13 | if type(member) in [ 14 | types.MethodType, 15 | types.FunctionType, 16 | types.LambdaType, 17 | types.BuiltinFunctionType, 18 | types.BuiltinMethodType, 19 | ]: 20 | return lambda *args, **kwargs: self._wrap(member, args, kwargs) 21 | else: 22 | return member 23 | raise AttributeError(name) 24 | def _wrap(self, func, args, kwargs): 25 | if isinstance(func, types.MethodType): 26 | result = func(*args, **kwargs) 27 | else: 28 | result = func(self.protocol, *args, **kwargs) 29 | return result 30 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 31 | #CREATOR BY : PRANKBOT 32 | #MOD BY ACIL -------------------------------------------------------------------------------- /KIA/client.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from akad.ttypes import Message 3 | from .auth import LineAuth 4 | from .models import LineModels 5 | from .talk import LineTalk 6 | from .square import LineSquare 7 | from .call import LineCall 8 | from random import randint 9 | 10 | import json 11 | 12 | class LineClient(LineAuth, LineModels, LineTalk, LineSquare, LineCall): 13 | 14 | customThrift = None 15 | 16 | def __init__(self, id=None, passwd=None, authToken=None, certificate=None, systemName=None, appName=None, showQr=False, keepLoggedIn=True, customThrift=None): 17 | 18 | LineAuth.__init__(self) 19 | if customThrift: 20 | self.customThrift = customThrift 21 | if not (authToken or id and passwd): 22 | self.qrLogin(keepLoggedIn=keepLoggedIn, systemName=systemName, appName=appName, showQr=showQr) 23 | if authToken: 24 | self.tokenLogin(authToken=authToken, appName=appName) 25 | if id and passwd: 26 | self.login(_id=id, passwd=passwd, certificate=certificate, systemName=systemName, appName=appName, keepLoggedIn=keepLoggedIn) 27 | 28 | self.profile = self.talk.getProfile() 29 | self.groups = self.talk.getGroupIdsJoined() 30 | 31 | LineModels.__init__(self) 32 | LineTalk.__init__(self) 33 | LineSquare.__init__(self) 34 | LineCall.__init__(self) -------------------------------------------------------------------------------- /thrift/boxup.py: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | from os import path 21 | from SCons.Builder import Builder 22 | from six.moves import map 23 | 24 | 25 | def scons_env(env, add=''): 26 | opath = path.dirname(path.abspath('$TARGET')) 27 | lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE' 28 | cppbuild = Builder(action=lstr) 29 | env.Append(BUILDERS={'ThriftCpp': cppbuild}) 30 | 31 | 32 | def gen_cpp(env, dir, file): 33 | scons_env(env) 34 | suffixes = ['_types.h', '_types.cpp'] 35 | targets = map(lambda s: 'gen-cpp/' + file + s, suffixes) 36 | return env.ThriftCpp(targets, dir + file + '.thrift') 37 | -------------------------------------------------------------------------------- /KIA/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from akad.ttypes import ApplicationType 3 | import re 4 | 5 | class Config(object): 6 | LINE_HOST_DOMAIN = 'https://gd2.line.naver.jp' 7 | LINE_OBS_DOMAIN = 'https://obs-sg.line-apps.com' 8 | LINE_TIMELINE_API = 'https://gd2.line.naver.jp/mh/api' 9 | LINE_TIMELINE_MH = 'https://gd2.line.naver.jp/mh' 10 | 11 | LINE_LOGIN_QUERY_PATH = '/api/v4p/rs' 12 | LINE_AUTH_QUERY_PATH = '/api/v4/TalkService.do' 13 | 14 | LINE_API_QUERY_PATH_FIR = '/S4' 15 | LINE_POLL_QUERY_PATH_FIR = '/P4' 16 | LINE_CALL_QUERY_PATH = '/V4' 17 | LINE_CERTIFICATE_PATH = '/Q' 18 | LINE_CHAN_QUERY_PATH = '/CH4' 19 | LINE_SQUARE_QUERY_PATH = '/SQS1' 20 | LINE_SHOP_QUERY_PATH = '/SHOP4' 21 | 22 | CHANNEL_ID = { 23 | 'LINE_TIMELINE': '1341209850', 24 | 'LINE_WEBTOON': '1401600689', 25 | 'LINE_TODAY': '1518712866', 26 | 'LINE_STORE': '1376922440', 27 | 'LINE_MUSIC': '1381425814', 28 | 'LINE_SERVICES': '1459630796' 29 | } 30 | 31 | APP_TYPE = ApplicationType._VALUES_TO_NAMES[368] 32 | APP_VER = '2.1.5' 33 | CARRIER = '51089, 1-0' 34 | SYSTEM_NAME = 'SELFBOT-BY:SADISv10' 35 | SYSTEM_VER = '8.22.17' 36 | IP_ADDR = '8.8.8.8' 37 | EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+") 38 | 39 | def __init__(self): 40 | self.APP_NAME = '%s\t%s\t%s\t%s' % (self.APP_TYPE, self.APP_VER, self.SYSTEM_NAME, self.SYSTEM_VER) 41 | self.USER_AGENT = 'Line/%s' % self.APP_VER 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Picture": false, 3 | "autoJoinTicket": true, 4 | "changePicture": false, 5 | "group": {}, 6 | "groupPicture": false, 7 | "userAgent": [ 8 | "Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0", 9 | "Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)", 10 | "Mozilla/5.0 (X11; U; Linux amd64; en-US; rv:5.0) Gecko/20110619 Firefox/5.0", 11 | "Mozilla/5.0 (X11; Linux) Gecko Firefox/5.0", 12 | "Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 FirePHP/0.5", 13 | "Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 Firefox/5.0", 14 | "Mozilla/5.0 (X11; Linux x86_64) Gecko Firefox/5.0", 15 | "Mozilla/5.0 (X11; Linux ppc; rv:5.0) Gecko/20100101 Firefox/5.0", 16 | "Mozilla/5.0 (X11; Linux AMD64) Gecko Firefox/5.0", 17 | "Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20100101 Firefox/5.0", 18 | "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 19 | "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20110619 Firefox/5.0", 20 | "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20100101 Firefox/5.0", 21 | "Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/5.0", 22 | "Mozilla/5.0 (Windows NT 6.1.1; rv:5.0) Gecko/20100101 Firefox/5.0", 23 | "Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 24 | "Mozilla/5.0 (Windows NT 5.1; U; rv:5.0) Gecko/20100101 Firefox/5.0", 25 | "Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/5.0", 26 | "Mozilla/5.0 (Windows NT 5.0; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 27 | "Mozilla/5.0 (Windows NT 5.0; rv:5.0) Gecko/20100101 Firefox/5.0" 28 | ] 29 | } -------------------------------------------------------------------------------- /sider.json: -------------------------------------------------------------------------------- 1 | { 2 | "ROM": { 3 | "c47104b752ef25bc4f736a9b90cd1786f": { 4 | "u36dd956b34fd7640d6c2cf3310af58e2": "u36dd956b34fd7640d6c2cf3310af58e2", 5 | "u451ad509b34dca9a31039d2b59ddcc2f": "u451ad509b34dca9a31039d2b59ddcc2f", 6 | "u51fc320fc185dfe327a7aa92ff41b5ef": "u51fc320fc185dfe327a7aa92ff41b5ef", 7 | "u687ea7692e107e54f9a9bb21aaac0699": "u687ea7692e107e54f9a9bb21aaac0699", 8 | "u70fba133d28424854375f560200ac556": "u70fba133d28424854375f560200ac556", 9 | "u740a4e05dae7f6efcef64873c20e2386": "u740a4e05dae7f6efcef64873c20e2386", 10 | "u7b01570c19c7c8ea3dc9fe6bf23e0768": "u7b01570c19c7c8ea3dc9fe6bf23e0768", 11 | "u8948f6a1f93c843ce03ccc4b94ad0cdb": "u8948f6a1f93c843ce03ccc4b94ad0cdb", 12 | "u8ba58acb6f4e4ab2c42a578bb387a034": "u8ba58acb6f4e4ab2c42a578bb387a034", 13 | "ua74eaace0359cc0fdb88bc375c76f01d": "ua74eaace0359cc0fdb88bc375c76f01d", 14 | "uc46a443e6cd78b40b0d8c7485f1159cf": "uc46a443e6cd78b40b0d8c7485f1159cf", 15 | "uc8eccbdec4645beb9ffec62be175893c": "uc8eccbdec4645beb9ffec62be175893c" 16 | }, 17 | "ce64ec8b91485e732cce2b8407a65a6f0": {} 18 | }, 19 | "readMember": { 20 | "c47104b752ef25bc4f736a9b90cd1786f": "u687ea7692e107e54f9a9bb21aaac0699u7b01570c19c7c8ea3dc9fe6bf23e0768u36dd956b34fd7640d6c2cf3310af58e2ua74eaace0359cc0fdb88bc375c76f01du8ba58acb6f4e4ab2c42a578bb387a034u740a4e05dae7f6efcef64873c20e2386u70fba133d28424854375f560200ac556uc46a443e6cd78b40b0d8c7485f1159cfu8948f6a1f93c843ce03ccc4b94ad0cdbu51fc320fc185dfe327a7aa92ff41b5efu451ad509b34dca9a31039d2b59ddcc2fuc8eccbdec4645beb9ffec62be175893c", 21 | "ce64ec8b91485e732cce2b8407a65a6f0": "" 22 | }, 23 | "readPoint": { 24 | "c47104b752ef25bc4f736a9b90cd1786f": "7358975705306", 25 | "ce64ec8b91485e732cce2b8407a65a6f0": "7359009901656" 26 | }, 27 | "readTime": { 28 | "c47104b752ef25bc4f736a9b90cd1786f": "03:52:03", 29 | "ce64ec8b91485e732cce2b8407a65a6f0": "04:09:30" 30 | } 31 | } -------------------------------------------------------------------------------- /KIA/poll.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .client import LineClient 3 | from types import * 4 | 5 | import os, sys, threading 6 | 7 | class LinePoll(object): 8 | OpInterrupt = {} 9 | client = None 10 | 11 | def __init__(self, client): 12 | if type(client) is not LineClient: 13 | raise Exception("You need to set LineClient instance to initialize LinePoll") 14 | self.client = client 15 | 16 | def fetchOperation(self, revision, count=1): 17 | return self.client.poll.fetchOperations(revision, count) 18 | 19 | def addOpInterruptWithDict(self, OpInterruptDict): 20 | self.OpInterrupt.update(OpInterruptDict) 21 | 22 | def addOpInterrupt(self, OperationType, DisposeFunc): 23 | self.OpInterrupt[OperationType] = DisposeFunc 24 | 25 | def execute(self, op, threading): 26 | try: 27 | if threading: 28 | _td = threading.Thread(target=self.OpInterrupt[op.type](op)) 29 | _td.daemon = False 30 | _td.start() 31 | else: 32 | self.OpInterrupt[op.type](op) 33 | except Exception as e: 34 | self.client.log(e) 35 | 36 | def setRevision(self, revision): 37 | self.client.revision = max(revision, self.client.revision) 38 | 39 | def singleTrace(self, count=1): 40 | try: 41 | operations = self.fetchOperation(self.client.revision, count=count) 42 | except KeyboardInterrupt: 43 | exit() 44 | except: 45 | return 46 | 47 | if operations is None: 48 | return [] 49 | else: 50 | return operations 51 | 52 | def trace(self, threading=False): 53 | try: 54 | operations = self.fetchOperation(self.client.revision) 55 | except KeyboardInterrupt: 56 | exit() 57 | except: 58 | return 59 | 60 | for op in operations: 61 | if op.type in self.OpInterrupt.keys(): 62 | self.execute(op, threading) 63 | self.setRevision(op.revision) -------------------------------------------------------------------------------- /thrift/server/THttpServer.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from six.moves import BaseHTTPServer 5 | from thrift.server import TServer 6 | from thrift.transport import TTransport 7 | class ResponseException(Exception): 8 | def __init__(self, handler): 9 | self.handler = handler 10 | class THttpServer(TServer.TServer): 11 | def __init__(self, 12 | processor, 13 | server_address, 14 | inputProtocolFactory, 15 | outputProtocolFactory=None, 16 | server_class=BaseHTTPServer.HTTPServer): 17 | if outputProtocolFactory is None: 18 | outputProtocolFactory = inputProtocolFactory 19 | TServer.TServer.__init__(self, processor, None, None, None, 20 | inputProtocolFactory, outputProtocolFactory) 21 | thttpserver = self 22 | class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler): 23 | def do_POST(self): 24 | itrans = TTransport.TFileObjectTransport(self.rfile) 25 | otrans = TTransport.TFileObjectTransport(self.wfile) 26 | itrans = TTransport.TBufferedTransport( 27 | itrans, int(self.headers['Content-Length'])) 28 | otrans = TTransport.TMemoryBuffer() 29 | iprot = thttpserver.inputProtocolFactory.getProtocol(itrans) 30 | oprot = thttpserver.outputProtocolFactory.getProtocol(otrans) 31 | try: 32 | thttpserver.processor.process(iprot, oprot) 33 | except ResponseException as exn: 34 | exn.handler(self) 35 | else: 36 | self.send_response(200) 37 | self.send_header("content-type", "application/x-thrift") 38 | self.end_headers() 39 | self.wfile.write(otrans.getvalue()) 40 | self.httpd = server_class(server_address, RequestHander) 41 | def serve(self): 42 | self.httpd.serve_forever() 43 | # MOD BY ACIL -------------------------------------------------------------------------------- /thrift/protocol/TBase.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from thrift.transport import TTransport 5 | class TBase(object): 6 | __slots__ = () 7 | def __repr__(self): 8 | L = ['%s=%r' % (key, getattr(self, key)) for key in self.__slots__] 9 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 10 | def __eq__(self, other): 11 | if not isinstance(other, self.__class__): 12 | return False 13 | for attr in self.__slots__: 14 | my_val = getattr(self, attr) 15 | other_val = getattr(other, attr) 16 | if my_val != other_val: 17 | return False 18 | return True 19 | def __ne__(self, other): 20 | return not (self == other) 21 | def read(self, iprot): 22 | if (iprot._fast_decode is not None and 23 | isinstance(iprot.trans, TTransport.CReadableTransport) and 24 | self.thrift_spec is not None): 25 | iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) 26 | else: 27 | iprot.readStruct(self, self.thrift_spec) 28 | def write(self, oprot): 29 | if (oprot._fast_encode is not None and self.thrift_spec is not None): 30 | oprot.trans.write( 31 | oprot._fast_encode(self, [self.__class__, self.thrift_spec])) 32 | else: 33 | oprot.writeStruct(self, self.thrift_spec) 34 | class TExceptionBase(TBase, Exception): 35 | pass 36 | class TFrozenBase(TBase): 37 | def __setitem__(self, *args): 38 | raise TypeError("MODIF BY PRANKBOTS") 39 | def __delitem__(self, *args): 40 | raise TypeError("MODIF BY PRANKBOTS") 41 | def __hash__(self, *args): 42 | return hash(self.__class__) ^ hash(self.__slots__) 43 | @classmethod 44 | def read(cls, iprot): 45 | if (iprot._fast_decode is not None and 46 | isinstance(iprot.trans, TTransport.CReadableTransport) and 47 | cls.thrift_spec is not None): 48 | self = cls() 49 | return iprot._fast_decode(None, iprot, 50 | [self.__class__, self.thrift_spec]) 51 | else: 52 | return iprot.readStruct(cls, cls.thrift_spec, True) 53 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 54 | #CREATOR BY : PRANKBOT 55 | #MOD BY ACIL -------------------------------------------------------------------------------- /KIA/session.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from thrift.transport import THttpClient 3 | from thrift.protocol import TCompactProtocol 4 | from akad import AuthService, TalkService, ChannelService, CallService, SquareService 5 | 6 | class Session: 7 | 8 | def __init__(self, url, headers, path=''): 9 | self.host = url + path 10 | self.headers = headers 11 | 12 | def Auth(self, isopen=True): 13 | self.transport = THttpClient.THttpClient(self.host) 14 | self.transport.setCustomHeaders(self.headers) 15 | 16 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 17 | self._auth = AuthService.Client(self.protocol) 18 | 19 | if isopen: 20 | self.transport.open() 21 | 22 | return self._auth 23 | 24 | def Talk(self, isopen=True): 25 | self.transport = THttpClient.THttpClient(self.host) 26 | self.transport.setCustomHeaders(self.headers) 27 | 28 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 29 | self._talk = TalkService.Client(self.protocol) 30 | 31 | if isopen: 32 | self.transport.open() 33 | 34 | return self._talk 35 | 36 | def Channel(self, isopen=True): 37 | self.transport = THttpClient.THttpClient(self.host) 38 | self.transport.setCustomHeaders(self.headers) 39 | 40 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 41 | self._channel = ChannelService.Client(self.protocol) 42 | 43 | if isopen: 44 | self.transport.open() 45 | 46 | return self._channel 47 | 48 | def Call(self, isopen=True): 49 | self.transport = THttpClient.THttpClient(self.host) 50 | self.transport.setCustomHeaders(self.headers) 51 | 52 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 53 | self._call = CallService.Client(self.protocol) 54 | 55 | if isopen: 56 | self.transport.open() 57 | 58 | return self._call 59 | 60 | def Square(self, isopen=True): 61 | self.transport = THttpClient.THttpClient(self.host) 62 | self.transport.setCustomHeaders(self.headers) 63 | 64 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 65 | self._square = SquareService.Client(self.protocol) 66 | 67 | if isopen: 68 | self.transport.open() 69 | 70 | return self._square -------------------------------------------------------------------------------- /thrift/TMultiplexedProcessor.py: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | from thrift.unverting import PrankbotProses, TMessageType, TException 21 | from thrift.protocol import TProtocolDecorator, TMultiplexedProtocol 22 | 23 | 24 | class TMultiplexedProcessor(PrankbotProses): 25 | def __init__(self): 26 | self.services = {} 27 | 28 | def registerProcessor(self, serviceName, processor): 29 | self.services[serviceName] = processor 30 | 31 | def process(self, iprot, oprot): 32 | (name, type, seqid) = iprot.readMessageBegin() 33 | if type != TMessageType.CALL and type != TMessageType.ONEWAY: 34 | raise TException("TMultiplex protocol only supports CALL & ONEWAY") 35 | 36 | index = name.find(TMultiplexedProtocol.SEPARATOR) 37 | if index < 0: 38 | raise TException("Service name not found in message name: " + name + ". Did you forget to use TMultiplexProtocol in your client?") 39 | 40 | serviceName = name[0:index] 41 | call = name[index + len(TMultiplexedProtocol.SEPARATOR):] 42 | if serviceName not in self.services: 43 | raise TException("Service name not found: " + serviceName + ". Did you forget to call registerProcessor()?") 44 | 45 | standardMessage = (call, type, seqid) 46 | return self.services[serviceName].process(StoredMessageProtocol(iprot, standardMessage), oprot) 47 | 48 | 49 | class StoredMessageProtocol(TProtocolDecorator.TProtocolDecorator): 50 | def __init__(self, protocol, messageBegin): 51 | TProtocolDecorator.TProtocolDecorator.__init__(self, protocol) 52 | self.messageBegin = messageBegin 53 | 54 | def readMessageBegin(self): 55 | return self.messageBegin 56 | -------------------------------------------------------------------------------- /KIA/server.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .config import Config 3 | import json, requests, urllib 4 | 5 | class LineServer(Config): 6 | _session = requests.session() 7 | channelHeaders = {} 8 | Headers = {} 9 | 10 | def __init__(self): 11 | self.Headers = {} 12 | self.channelHeaders = {} 13 | Config.__init__(self) 14 | 15 | def parseUrl(self, path): 16 | return self.LINE_HOST_DOMAIN + path 17 | 18 | def urlEncode(self, url, path, params=[]): 19 | try: # Works with python 2.x 20 | return url + path + '?' + urllib.urlencode(params) 21 | except: # Works with python 3.x 22 | return url + path + '?' + urllib.parse.urlencode(params) 23 | 24 | def getJson(self, url, allowHeader=False): 25 | if allowHeader is False: 26 | return json.loads(self._session.get(url).text) 27 | else: 28 | return json.loads(self._session.get(url, headers=self.Headers).text) 29 | 30 | def setHeadersWithDict(self, headersDict): 31 | self.Headers.update(headersDict) 32 | 33 | def setHeaders(self, argument, value): 34 | self.Headers[argument] = value 35 | 36 | def setChannelHeadersWithDict(self, headersDict): 37 | self.channelHeaders.update(headersDict) 38 | 39 | def setChannelHeaders(self, argument, value): 40 | self.channelHeaders[argument] = value 41 | 42 | def additionalHeaders(self, source, newSource): 43 | headerList={} 44 | headerList.update(source) 45 | headerList.update(newSource) 46 | return headerList 47 | 48 | def optionsContent(self, url, data=None, headers=None): 49 | if headers is None: 50 | headers=self.Headers 51 | return self._session.options(url, headers=headers, data=data) 52 | 53 | def postContent(self, url, data=None, files=None, headers=None): 54 | if headers is None: 55 | headers=self.Headers 56 | return self._session.post(url, headers=headers, data=data, files=files) 57 | 58 | def getContent(self, url, headers=None): 59 | if headers is None: 60 | headers=self.Headers 61 | return self._session.get(url, headers=headers, stream=True) 62 | 63 | def deleteContent(self, url, data=None, headers=None): 64 | if headers is None: 65 | headers=self.Headers 66 | return self._session.delete(url, headers=headers, data=data) 67 | 68 | def putContent(self, url, data=None, headers=None): 69 | if headers is None: 70 | headers=self.Headers 71 | return self._session.put(url, headers=headers, data=data) -------------------------------------------------------------------------------- /thrift/transport/sslcompat.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | import logging 5 | import sys 6 | from thrift.transport.TTransport import TTransportException 7 | logger = logging.getLogger(__name__) 8 | def legacy_validate_callback(cert, hostname): 9 | if 'subject' not in cert: 10 | raise TTransportException( 11 | TTransportException.NOT_OPEN, 12 | 'sert tidak ada di ssl dengan user name %s' % hostname) 13 | fields = cert['subject'] 14 | for field in fields: 15 | if not isinstance(field, tuple): 16 | continue 17 | cert_pair = field[0] 18 | if len(cert_pair) < 2: 19 | continue 20 | cert_key, cert_value = cert_pair[0:2] 21 | if cert_key != 'commonName': 22 | continue 23 | certhost = cert_value 24 | if certhost == hostname: 25 | return 26 | else: 27 | raise TTransportException( 28 | TTransportException.UNKNOWN, 29 | 'Hostname we connected to "%s" doesn\'t match certificate ' 30 | 'provided commonName "%s"' % (hostname, certhost)) 31 | raise TTransportException( 32 | TTransportException.UNKNOWN, 33 | 'Could not validate SSL certificate from host "%s". Cert=%s' 34 | % (hostname, cert)) 35 | def _optional_dependencies(): 36 | try: 37 | import ipaddress # noqa 38 | logger.debug('ipaddress module is available') 39 | ipaddr = True 40 | except ImportError: 41 | logger.warn('ipaddress module is unavailable') 42 | ipaddr = False 43 | if sys.hexversion < 0x030500F0: 44 | try: 45 | from backports.ssl_match_hostname import match_hostname, __version__ as ver 46 | ver = list(map(int, ver.split('.'))) 47 | logger.debug('backports.ssl_match_hostname module is available') 48 | match = match_hostname 49 | if ver[0] * 10 + ver[1] >= 35: 50 | return ipaddr, match 51 | else: 52 | logger.warn('backports.ssl_match_hostname module is too old') 53 | ipaddr = False 54 | except ImportError: 55 | logger.warn('backports.ssl_match_hostname is unavailable') 56 | ipaddr = False 57 | try: 58 | from ssl import match_hostname 59 | logger.debug('ssl.match_hostname is available') 60 | match = match_hostname 61 | except ImportError: 62 | logger.warn('using legacy validation callback') 63 | match = legacy_validate_callback 64 | return ipaddr, match 65 | _match_has_ipaddress, _match_hostname = _optional_dependencies() 66 | # MOD BY ACIL -------------------------------------------------------------------------------- /KIA/channel.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .client import LineClient 3 | from .timeline import LineTimeline 4 | from types import * 5 | 6 | class LineChannel(LineTimeline): 7 | isLogin = False 8 | channelId = None 9 | profileDetail = None 10 | 11 | client = None 12 | server = None 13 | 14 | channelAccessToken = None 15 | channelToken = None 16 | obsToken = None 17 | channelRefreshToken = None 18 | channelTokenExpiration = None 19 | 20 | def __init__(self, client, channelId=None): 21 | if type(client) is not LineClient: 22 | raise Exception("You need to set LineClient instance to initialize LineChannel") 23 | self.client = client 24 | self.server = client.server 25 | self.channelId = channelId 26 | self.login() 27 | 28 | def login(self): 29 | if self.channelId is None: 30 | self.channelId=self.server.CHANNEL_ID['LINE_TIMELINE'] 31 | result = self.approveChannelAndIssueChannelToken(self.channelId) 32 | 33 | self.channelAccessToken = result.channelAccessToken 34 | self.channelToken = result.token 35 | self.obsToken = result.obsToken 36 | self.channelRefreshToken = result.refreshToken 37 | self.channelTokenExpiration = result.expiration 38 | self.isLogin = True 39 | 40 | self.createSession() 41 | 42 | def createSession(self): 43 | if self.isLogin: 44 | self.server.setChannelHeadersWithDict({ 45 | 'Content-Type': 'application/json', 46 | 'User-Agent': self.server.USER_AGENT, 47 | 'X-Line-Mid': self.client.profile.mid, 48 | 'X-Line-Carrier': self.server.CARRIER, 49 | 'X-Line-Application': self.server.APP_NAME, 50 | 'X-Line-ChannelToken': self.channelAccessToken 51 | }) 52 | channelInfo = self.getChannelInfo(self.channelId) 53 | if self.channelId == self.server.CHANNEL_ID['LINE_TIMELINE']: 54 | LineTimeline.__init__(self) 55 | self.profileDetail = self.getProfileDetail() 56 | self.client.setChannelToModels(self) 57 | self.client.log('[%s] : Success login to %s' % (self.client.profile.displayName, channelInfo.name)) 58 | 59 | def approveChannelAndIssueChannelToken(self, channelId): 60 | return self.client.channel.approveChannelAndIssueChannelToken(channelId) 61 | 62 | def issueChannelToken(self, channelId): 63 | return self.client.channel.issueChannelToken(channelId) 64 | 65 | def getChannelInfo(self, channelId, locale='EN'): 66 | return self.client.channel.getChannelInfo(channelId, locale) 67 | 68 | def revokeChannel(self, channelId): 69 | return self.client.channel.revokeChannel(channelId) -------------------------------------------------------------------------------- /KIA/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from datetime import datetime 3 | from .object import LineObject 4 | from random import randint 5 | 6 | import json, shutil, time, os, base64, tempfile 7 | 8 | class LineModels(LineObject): 9 | 10 | _channel = None 11 | 12 | def __init__(self): 13 | LineObject.__init__(self) 14 | 15 | def setChannelToModels(self, channel): 16 | self._channel = channel 17 | 18 | """Text""" 19 | 20 | def log(self, text): 21 | print("[%s] %s" % (str(datetime.now()), text)) 22 | 23 | """File""" 24 | 25 | def saveFile(self, path, raw): 26 | with open(path, 'wb') as f: 27 | shutil.copyfileobj(raw, f) 28 | 29 | def deleteFile(self, path): 30 | if os.path.exists(path): 31 | os.remove(path) 32 | return True 33 | else: 34 | return False 35 | 36 | def downloadFileURL(self, fileUrl, returnAs='path', saveAs='', headers=None): 37 | if returnAs not in ['path','bool','bin']: 38 | raise Exception('Invalid returnAs value') 39 | if saveAs == '': 40 | saveAs = self.genTempFile() 41 | r = self.server.getContent(fileUrl, headers=headers) 42 | if r.status_code != 404: 43 | self.saveFile(saveAs, r.raw) 44 | if returnAs == 'path': 45 | return saveAs 46 | elif returnAs == 'bool': 47 | return True 48 | elif returnAs == 'bin': 49 | return r.raw 50 | else: 51 | raise Exception('Download file failure.') 52 | 53 | """Generator""" 54 | 55 | def genTempFile(self, returnAs='path'): 56 | try: 57 | if returnAs not in ['file','path']: 58 | raise Exception('Invalid returnAs value') 59 | fName, fPath = 'linepy-%s-%i.bin' % (int(time.time()), randint(0, 9)), tempfile.gettempdir() 60 | if returnAs == 'file': 61 | return fName 62 | elif returnAs == 'path': 63 | return os.path.join(fPath, fName) 64 | except: 65 | raise Exception('tempfile is required') 66 | 67 | def genOBSParams(self, newList, returnAs='json'): 68 | oldList = {'name': self.genTempFile('file'),'ver': '1.0'} 69 | if returnAs not in ['json','b64','default']: 70 | raise Exception('Invalid parameter returnAs') 71 | oldList.update(newList) 72 | if 'range' in oldList: 73 | new_range='bytes 0-%s\/%s' % ( str(oldList['range']-1), str(oldList['range']) ) 74 | oldList.update({'range': new_range}) 75 | if returnAs == 'json': 76 | oldList=json.dumps(oldList) 77 | return oldList 78 | elif returnAs == 'b64': 79 | oldList=json.dumps(oldList) 80 | return base64.b64encode(oldList.encode('utf-8')) 81 | elif returnAs == 'default': 82 | return oldList -------------------------------------------------------------------------------- /thrift/server/TProcessPoolServer.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | import logging 5 | from multiprocessing import Process, Value, Condition 6 | from .TServer import TServer 7 | from thrift.transport.TTransport import TTransportException 8 | logger = logging.getLogger(__name__) 9 | class TProcessPoolServer(TServer): 10 | def __init__(self, *args): 11 | TServer.__init__(self, *args) 12 | self.numWorkers = 10 13 | self.workers = [] 14 | self.isRunning = Value('b', False) 15 | self.stopCondition = Condition() 16 | self.postForkCallback = None 17 | def setPostForkCallback(self, callback): 18 | if not callable(callback): 19 | raise TypeError("This is not a callback!") 20 | self.postForkCallback = callback 21 | def setNumWorkers(self, num): 22 | """Set the number of worker threads that should be created""" 23 | self.numWorkers = num 24 | def workerProcess(self): 25 | """Loop getting clients from the shared queue and process them""" 26 | if self.postForkCallback: 27 | self.postForkCallback() 28 | while self.isRunning.value: 29 | try: 30 | client = self.serverTransport.accept() 31 | if not client: 32 | continue 33 | self.serveClient(client) 34 | except (KeyboardInterrupt, SystemExit): 35 | return 0 36 | except Exception as x: 37 | logger.exception(x) 38 | def serveClient(self, client): 39 | itrans = self.inputTransportFactory.getTransport(client) 40 | otrans = self.outputTransportFactory.getTransport(client) 41 | iprot = self.inputProtocolFactory.getProtocol(itrans) 42 | oprot = self.outputProtocolFactory.getProtocol(otrans) 43 | try: 44 | while True: 45 | self.processor.process(iprot, oprot) 46 | except TTransportException: 47 | pass 48 | except Exception as x: 49 | logger.exception(x) 50 | itrans.close() 51 | otrans.close() 52 | def serve(self): 53 | self.isRunning.value = True 54 | self.serverTransport.listen() 55 | for i in range(self.numWorkers): 56 | try: 57 | w = Process(target=self.workerProcess) 58 | w.daemon = True 59 | w.start() 60 | self.workers.append(w) 61 | except Exception as x: 62 | logger.exception(x) 63 | while True: 64 | self.stopCondition.acquire() 65 | try: 66 | self.stopCondition.wait() 67 | break 68 | except (SystemExit, KeyboardInterrupt): 69 | break 70 | except Exception as x: 71 | logger.exception(x) 72 | self.isRunning.value = False 73 | def stop(self): 74 | self.isRunning.value = False 75 | self.stopCondition.acquire() 76 | self.stopCondition.notify() 77 | self.stopCondition.release() 78 | # MOD BY ACIL 79 | # PRANKBOTS CREATOR -------------------------------------------------------------------------------- /temp.json: -------------------------------------------------------------------------------- 1 | { 2 | "addPict": [], 3 | "author": {}, 4 | "autoAdd": true, 5 | "autoJoin": false, 6 | "autoJoinTicket": true, 7 | "autoLeave": false, 8 | "autoPurge": [], 9 | "autoRead": true, 10 | "blacklist": {}, 11 | "changeGroupPicture": [], 12 | "changeGroupPicturePub": [], 13 | "changePicqr1": false, 14 | "changePicqr2": false, 15 | "changePicqr3": false, 16 | "changePicqr4": false, 17 | "changePicqr5": false, 18 | "changePicture": false, 19 | "changePicture1": false, 20 | "changePicture2": false, 21 | "changePicture3": false, 22 | "changePicture4": false, 23 | "changePicture5": false, 24 | "checkContact": false, 25 | "clock": [], 26 | "dblacklist": false, 27 | "dwhitelist": false, 28 | "icon_lock": {}, 29 | "keyCommand": "", 30 | "kick": false, 31 | "kickqr": false, 32 | "linkqrp": [], 33 | "mimic": { 34 | "copy": false, 35 | "status": true, 36 | "target": {} 37 | }, 38 | "pcancel": [], 39 | "pinvite": [], 40 | "pkick": [], 41 | "pname": [], 42 | "pro_name": {}, 43 | "respCall": false, 44 | "respMENTION": false, 45 | "respMENTIONpm": false, 46 | "responcall": true, 47 | "responcallgc": true, 48 | "responpm": false, 49 | "restartBot": null, 50 | "restartPoint": "c45040756c8074bff5a06c2e7c0b6a844", 51 | "server": "VPS", 52 | "simsimi": [], 53 | "siriMode": [], 54 | "timeRestart": "18000", 55 | "userAgent": [ 56 | "Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0", 57 | "Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)", 58 | "Mozilla/5.0 (X11; U; Linux amd64; en-US; rv:5.0) Gecko/20110619 Firefox/5.0", 59 | "Mozilla/5.0 (X11; Linux) Gecko Firefox/5.0", 60 | "Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 FirePHP/0.5", 61 | "Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 Firefox/5.0", 62 | "Mozilla/5.0 (X11; Linux x86_64) Gecko Firefox/5.0", 63 | "Mozilla/5.0 (X11; Linux ppc; rv:5.0) Gecko/20100101 Firefox/5.0", 64 | "Mozilla/5.0 (X11; Linux AMD64) Gecko Firefox/5.0", 65 | "Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20100101 Firefox/5.0", 66 | "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 67 | "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20110619 Firefox/5.0", 68 | "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20100101 Firefox/5.0", 69 | "Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/5.0", 70 | "Mozilla/5.0 (Windows NT 6.1.1; rv:5.0) Gecko/20100101 Firefox/5.0", 71 | "Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 72 | "Mozilla/5.0 (Windows NT 5.1; U; rv:5.0) Gecko/20100101 Firefox/5.0", 73 | "Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/5.0", 74 | "Mozilla/5.0 (Windows NT 5.0; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 75 | "Mozilla/5.0 (Windows NT 5.0; rv:5.0) Gecko/20100101 Firefox/5.0" 76 | ], 77 | "wblacklist": {}, 78 | "whitelist": {}, 79 | "winvite": false, 80 | "wlc": [ 81 | "c45040756c8074bff5a06c2e7c0b6a844" 82 | ], 83 | "wwhitelist": false 84 | } -------------------------------------------------------------------------------- /thrift/TRecursive.py: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | from __future__ import absolute_import 14 | from __future__ import division 15 | from __future__ import print_function 16 | from __future__ import unicode_literals 17 | 18 | from thrift.Thrift import TType 19 | 20 | TYPE_IDX = 1 21 | SPEC_ARGS_IDX = 3 22 | SPEC_ARGS_CLASS_REF_IDX = 0 23 | SPEC_ARGS_THRIFT_SPEC_IDX = 1 24 | 25 | 26 | def fix_spec(all_structs): 27 | """Wire up recursive references for all TStruct definitions inside of each thrift_spec.""" 28 | for struc in all_structs: 29 | spec = struc.thrift_spec 30 | for thrift_spec in spec: 31 | if thrift_spec is None: 32 | continue 33 | elif thrift_spec[TYPE_IDX] == TType.STRUCT: 34 | other = thrift_spec[SPEC_ARGS_IDX][SPEC_ARGS_CLASS_REF_IDX].thrift_spec 35 | thrift_spec[SPEC_ARGS_IDX][SPEC_ARGS_THRIFT_SPEC_IDX] = other 36 | elif thrift_spec[TYPE_IDX] in (TType.LIST, TType.SET): 37 | _fix_list_or_set(thrift_spec[SPEC_ARGS_IDX]) 38 | elif thrift_spec[TYPE_IDX] == TType.MAP: 39 | _fix_map(thrift_spec[SPEC_ARGS_IDX]) 40 | 41 | 42 | def _fix_list_or_set(element_type): 43 | # For a list or set, the thrift_spec entry looks like, 44 | # (1, TType.LIST, 'lister', (TType.STRUCT, [RecList, None], False), None, ), # 1 45 | # so ``element_type`` will be, 46 | # (TType.STRUCT, [RecList, None], False) 47 | if element_type[0] == TType.STRUCT: 48 | element_type[1][1] = element_type[1][0].thrift_spec 49 | elif element_type[0] in (TType.LIST, TType.SET): 50 | _fix_list_or_set(element_type[1]) 51 | elif element_type[0] == TType.MAP: 52 | _fix_map(element_type[1]) 53 | 54 | 55 | def _fix_map(element_type): 56 | # For a map of key -> value type, ``element_type`` will be, 57 | # (TType.I16, None, TType.STRUCT, [RecMapBasic, None], False), None, ) 58 | # which is just a normal struct definition. 59 | # 60 | # For a map of key -> list / set, ``element_type`` will be, 61 | # (TType.I16, None, TType.LIST, (TType.STRUCT, [RecMapList, None], False), False) 62 | # and we need to process the 3rd element as a list. 63 | # 64 | # For a map of key -> map, ``element_type`` will be, 65 | # (TType.I16, None, TType.MAP, (TType.I16, None, TType.STRUCT, 66 | # [RecMapMap, None], False), False) 67 | # and need to process 3rd element as a map. 68 | 69 | # Is the map key a struct? 70 | if element_type[0] == TType.STRUCT: 71 | element_type[1][1] = element_type[1][0].thrift_spec 72 | elif element_type[0] in (TType.LIST, TType.SET): 73 | _fix_list_or_set(element_type[1]) 74 | elif element_type[0] == TType.MAP: 75 | _fix_map(element_type[1]) 76 | 77 | # Is the map value a struct? 78 | if element_type[2] == TType.STRUCT: 79 | element_type[3][1] = element_type[3][0].thrift_spec 80 | elif element_type[2] in (TType.LIST, TType.SET): 81 | _fix_list_or_set(element_type[3]) 82 | elif element_type[2] == TType.MAP: 83 | _fix_map(element_type[3]) 84 | -------------------------------------------------------------------------------- /thrift/transport/TZlibTransport.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from __future__ import division 5 | import zlib 6 | from .TTransport import TTransportBase, CReadableTransport 7 | from ..compat import BufferIO 8 | class TZlibTransportFactory(object): 9 | # proses cache ke Zlibs 10 | _last_trans = None 11 | _last_z = None 12 | def getTransport(self, trans, compresslevel=9): 13 | if trans == self._last_trans: 14 | return self._last_z 15 | ztrans = TZlibTransport(trans, compresslevel) 16 | self._last_trans = trans 17 | self._last_z = ztrans 18 | return ztrans 19 | class TZlibTransport(TTransportBase, CReadableTransport): 20 | DEFAULT_BUFFSIZE = 4096 21 | def __init__(self, trans, compresslevel=9): 22 | self.__trans = trans 23 | self.compresslevel = compresslevel 24 | self.__rbuf = BufferIO() 25 | self.__wbuf = BufferIO() 26 | self._init_zlib() 27 | self._init_stats() 28 | def _reinit_buffers(self): 29 | self.__rbuf = BufferIO() 30 | self.__wbuf = BufferIO() 31 | def _init_stats(self): 32 | self.bytes_in = 0 33 | self.bytes_out = 0 34 | self.bytes_in_comp = 0 35 | self.bytes_out_comp = 0 36 | def _init_zlib(self): 37 | self._zcomp_read = zlib.decompressobj() 38 | self._zcomp_write = zlib.compressobj(self.compresslevel) 39 | def getCompRatio(self): 40 | r_percent, w_percent = (None, None) 41 | if self.bytes_in > 0: 42 | r_percent = self.bytes_in_comp / self.bytes_in 43 | if self.bytes_out > 0: 44 | w_percent = self.bytes_out_comp / self.bytes_out 45 | return (r_percent, w_percent) 46 | def getCompSavings(self): 47 | r_saved = self.bytes_in - self.bytes_in_comp 48 | w_saved = self.bytes_out - self.bytes_out_comp 49 | return (r_saved, w_saved) 50 | def isOpen(self): 51 | #transport open 52 | return self.__trans.isOpen() 53 | def open(self): 54 | # ini jalurnya 55 | self._init_stats() 56 | return self.__trans.open() 57 | def listen(self): 58 | self.__trans.listen() 59 | def accept(self): 60 | # menerima transport 61 | return self.__trans.accept() 62 | def close(self): 63 | #penutupan transport 64 | self._reinit_buffers() 65 | self._init_zlib() 66 | return self.__trans.close() 67 | def read(self, sz): 68 | ret = self.__rbuf.read(sz) 69 | if len(ret) > 0: 70 | return ret 71 | # kembali reaksi transport 72 | while True: 73 | if self.readComp(sz): 74 | break 75 | ret = self.__rbuf.read(sz) 76 | return ret 77 | def readComp(self, sz): 78 | zbuf = self.__trans.read(sz) 79 | zbuf = self._zcomp_read.unconsumed_tail + zbuf 80 | buf = self._zcomp_read.decompress(zbuf) 81 | self.bytes_in += len(zbuf) 82 | self.bytes_in_comp += len(buf) 83 | old = self.__rbuf.read() 84 | self.__rbuf = BufferIO(old + buf) 85 | if len(old) + len(buf) == 0: 86 | return False 87 | return True 88 | def write(self, buf): 89 | self.__wbuf.write(buf) 90 | def flush(self): 91 | wout = self.__wbuf.getvalue() 92 | if len(wout) > 0: 93 | zbuf = self._zcomp_write.compress(wout) 94 | self.bytes_out += len(wout) 95 | self.bytes_out_comp += len(zbuf) 96 | else: 97 | zbuf = '' 98 | ztail = self._zcomp_write.flush(zlib.Z_SYNC_FLUSH) 99 | self.bytes_out_comp += len(ztail) 100 | if (len(zbuf) + len(ztail)) > 0: 101 | self.__wbuf = BufferIO() 102 | self.__trans.write(zbuf + ztail) 103 | self.__trans.flush() 104 | @property 105 | def cstringio_buf(self): 106 | return self.__rbuf 107 | def cstringio_refill(self, partialread, reqlen): 108 | retstring = partialread 109 | if reqlen < self.DEFAULT_BUFFSIZE: 110 | retstring += self.read(self.DEFAULT_BUFFSIZE) 111 | while len(retstring) < reqlen: 112 | retstring += self.read(reqlen - len(retstring)) 113 | self.__rbuf = BufferIO(retstring) 114 | return self.__rbuf 115 | # JANGAN SOMBONG APA YANG KAMU PUNYA DAN APA YANG KAMU BISA 116 | # SEMUA MILIK ALLAH SWT -------------------------------------------------------------------------------- /thrift/transport/THttpClient.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from io import BytesIO 5 | import os 6 | import socket 7 | import sys 8 | import warnings 9 | import base64 10 | import time 11 | from six.moves import urllib 12 | from six.moves import http_client 13 | import six 14 | from .TTransport import TTransportBase 15 | class THttpClient(TTransportBase): 16 | def __init__(self, uri_or_host, port=None, path=None): 17 | if port is not None: 18 | warnings.warn( 19 | "gunakan THttpClient di sini('http://host:port/path') syntax", 20 | DeprecationWarning, 21 | stacklevel=2) 22 | self.host = uri_or_host 23 | self.port = port 24 | assert path 25 | self.path = path 26 | self.scheme = 'http' 27 | else: 28 | parsed = urllib.parse.urlparse(uri_or_host) 29 | self.scheme = parsed.scheme 30 | assert self.scheme in ('http', 'https') 31 | if self.scheme == 'http': 32 | self.port = parsed.port or http_client.HTTP_PORT 33 | elif self.scheme == 'https': 34 | self.port = parsed.port or http_client.HTTPS_PORT 35 | self.host = parsed.hostname 36 | self.path = parsed.path 37 | if parsed.query: 38 | self.path += '?%s' % parsed.query 39 | proxy = None 40 | self.realhost = self.realport = self.proxy_auth = None 41 | self.__wbuf = BytesIO() 42 | self.__http = None 43 | self.__http_response = None 44 | self.__timeout = None 45 | self.__custom_headers = None 46 | self.__time = time.time() 47 | self.__loop = 0 48 | @staticmethod 49 | def basic_proxy_auth_header(proxy): 50 | if proxy is None or not proxy.username: 51 | return None 52 | ap = "%s:%s" % (urllib.parse.unquote(proxy.username), 53 | urllib.parse.unquote(proxy.password)) 54 | cr = base64.b64encode(ap).strip() 55 | return "Basic " + cr 56 | def using_proxy(self): 57 | return self.realhost is not None 58 | def open(self): 59 | if self.scheme == 'http': 60 | self.__http = http_client.HTTPConnection(self.host, self.port) 61 | elif self.scheme == 'https': 62 | self.__http = http_client.HTTPSConnection(self.host, self.port) 63 | def close(self): 64 | self.__http.close() 65 | self.__http = None 66 | self.__http_response = None 67 | def isOpen(self): 68 | return self.__http is not None 69 | def setTimeout(self, ms): 70 | if not hasattr(socket, 'getdefaulttimeout'): 71 | raise NotImplementedError 72 | if ms is None: 73 | self.__timeout = None 74 | else: 75 | self.__timeout = ms / 1000.0 76 | def setCustomHeaders(self, headers): 77 | self.__custom_headers = headers 78 | def read(self, sz): 79 | return self.__http_response.read(sz) 80 | def write(self, buf): 81 | self.__wbuf.write(buf) 82 | def __withTimeout(f): 83 | def _f(*args, **kwargs): 84 | orig_timeout = socket.getdefaulttimeout() 85 | socket.setdefaulttimeout(args[0].__timeout) 86 | try: 87 | result = f(*args, **kwargs) 88 | finally: 89 | socket.setdefaulttimeout(orig_timeout) 90 | return result 91 | return _f 92 | def flush(self): 93 | if self.__loop <= 2: 94 | if self.isOpen(): self.close() 95 | self.open(); self.__loop += 1 96 | elif time.time() - self.__time > 90: 97 | self.close(); self.open(); self.__time = time.time() 98 | data = self.__wbuf.getvalue() 99 | self.__wbuf = BytesIO() 100 | self.__http.putrequest('POST', self.path) 101 | self.__http.putheader('Host', self.host) 102 | self.__http.putheader('Content-Type', 'application/x-thrift') 103 | self.__http.putheader('Content-Length', str(len(data))) 104 | if self.__custom_headers: 105 | for key, val in six.iteritems(self.__custom_headers): 106 | self.__http.putheader(key, val) 107 | self.__http.endheaders() 108 | self.__http.send(data) 109 | self.__http_response = self.__http.getresponse() 110 | self.code = self.__http_response.status 111 | self.message = self.__http_response.reason 112 | self.headers = self.__http_response.msg 113 | #THANKS CROT -------------------------------------------------------------------------------- /thrift/unverting.py: -------------------------------------------------------------------------------- 1 | # INI NYAMBUNG KE FROZEN 2 | # ACIL. MOD 3 | 4 | import sys 5 | class TType(object): 6 | STOP = 0 7 | VOID = 1 8 | BOOL = 2 9 | BYTE = 3 10 | I08 = 3 11 | DOUBLE = 4 12 | I16 = 6 13 | I32 = 8 14 | I64 = 10 15 | STRING = 11 16 | UTF7 = 11 17 | STRUCT = 12 18 | MAP = 13 19 | SET = 14 20 | LIST = 15 21 | UTF8 = 16 22 | UTF16 = 17 23 | _VALUES_TO_NAMES = ( 24 | 'STOP', 25 | 'VOID', 26 | 'BOOL', 27 | 'BYTE', 28 | 'DOUBLE', 29 | None, 30 | 'I16', 31 | None, 32 | 'I32', 33 | None, 34 | 'I64', 35 | 'STRING', 36 | 'STRUCT', 37 | 'MAP', 38 | 'SET', 39 | 'LIST', 40 | 'UTF8', 41 | 'UTF16', 42 | ) 43 | class TMessageType(object): 44 | CALL = 1 45 | REPLY = 2 46 | EXCEPTION = 3 47 | ONEWAY = 4 48 | class PrankbotProses(object): 49 | """ini prosesor nya""" 50 | 51 | def process(self, iprot, oprot): 52 | pass 53 | class TException(Exception): 54 | """ini Exception sob""" 55 | # INI SUPORT DI PYTHON2 ATAU PYTHON3 56 | if (2, 6, 0) <= sys.version_info < (3, 0): 57 | def _get_message(self): 58 | return self._message 59 | def _set_message(self, message): 60 | self._message = message 61 | message = property(_get_message, _set_message) 62 | def __init__(self, message=None): 63 | Exception.__init__(self, message) 64 | self.message = message 65 | class TApplicationException(TException): 66 | """INI LEVEL THRIFT NYA SOB""" 67 | UNKNOWN = 0 68 | UNKNOWN_METHOD = 1 69 | INVALID_MESSAGE_TYPE = 2 70 | WRONG_METHOD_NAME = 3 71 | BAD_SEQUENCE_ID = 4 72 | MISSING_RESULT = 5 73 | INTERNAL_ERROR = 6 74 | PROTOCOL_ERROR = 7 75 | INVALID_TRANSFORM = 8 76 | INVALID_PROTOCOL = 9 77 | UNSUPPORTED_CLIENT_TYPE = 10 78 | def __init__(self, type=UNKNOWN, message=None): 79 | TException.__init__(self, message) 80 | self.type = type 81 | def __str__(self): 82 | if self.message: 83 | return self.message 84 | elif self.type == self.UNKNOWN_METHOD: 85 | return 'TIDAK ADA METODE [0]' 86 | elif self.type == self.INVALID_MESSAGE_TYPE: 87 | return 'TIDAK ADA PESAN [0]' 88 | elif self.type == self.WRONG_METHOD_NAME: 89 | return 'NAMA TIDAK VALID' 90 | elif self.type == self.BAD_SEQUENCE_ID: 91 | return 'SQUENCE TIDAK SUPORT' 92 | elif self.type == self.MISSING_RESULT: 93 | return 'RESPON DI TAMPILKAN' 94 | elif self.type == self.INTERNAL_ERROR: 95 | return 'RUANG EROR' 96 | elif self.type == self.PROTOCOL_ERROR: 97 | return 'PROTOCOL EROR' 98 | elif self.type == self.INVALID_TRANSFORM: 99 | return 'TRANSFORM' 100 | elif self.type == self.INVALID_PROTOCOL: 101 | return 'INVALID PRO' 102 | elif self.type == self.UNSUPPORTED_CLIENT_TYPE: 103 | return 'CLIENT TIDAK SUPORT INI' 104 | else: 105 | return 'JANGAN SOMBONG DENGAN APA YANG KAU BISA. SEMUA MILIK ALLAH SWT' 106 | # MEMBACA LIBS 107 | def read(self, iprot): 108 | iprot.readStructBegin() 109 | while True: 110 | (fname, ftype, fid) = iprot.readFieldBegin() 111 | if ftype == TType.STOP: 112 | break 113 | if fid == 1: 114 | if ftype == TType.STRING: 115 | self.message = iprot.readString() 116 | else: 117 | iprot.skip(ftype) 118 | elif fid == 2: 119 | if ftype == TType.I32: 120 | self.type = iprot.readI32() 121 | else: 122 | iprot.skip(ftype) 123 | else: 124 | iprot.skip(ftype) 125 | iprot.readFieldEnd() 126 | iprot.readStructEnd() 127 | def write(self, oprot): 128 | oprot.writeStructBegin('TApplicationException') 129 | if self.message is not None: 130 | oprot.writeFieldBegin('message', TType.STRING, 1) 131 | oprot.writeString(self.message) 132 | oprot.writeFieldEnd() 133 | if self.type is not None: 134 | oprot.writeFieldBegin('type', TType.I32, 2) 135 | oprot.writeI32(self.type) 136 | oprot.writeFieldEnd() 137 | oprot.writeFieldStop() 138 | oprot.writeStructEnd() 139 | class TFrozenDict(dict): 140 | """PROZENDICT""" 141 | def __init__(self, *args, **kwargs): 142 | super(TFrozenDict, self).__init__(*args, **kwargs) 143 | # INI UNTUK MENGETAHUI DIMANA SC LU EROR DAN UNTUK MENSTOP RUN BOT LU 144 | self.__hashval = hash(TFrozenDict) ^ hash(tuple(sorted(self.items()))) 145 | def __setitem__(self, *args): 146 | raise TypeError("MODIF BY PRANKBOT") 147 | def __delitem__(self, *args): 148 | raise TypeError("MODIF BY PRANKBOT") 149 | def __hash__(self): 150 | return self.__hashval 151 | # SEKIAN DAN TRIMAKASIH. -------------------------------------------------------------------------------- /thrift/Thrift.py: -------------------------------------------------------------------------------- 1 | #python 3 2 | import sys 3 | class TType(object): 4 | STOP = 0 5 | VOID = 1 6 | BOOL = 2 7 | BYTE = 3 8 | I08 = 3 9 | DOUBLE = 4 10 | I16 = 6 11 | I32 = 8 12 | I64 = 10 13 | STRING = 11 14 | UTF7 = 11 15 | STRUCT = 12 16 | MAP = 13 17 | SET = 14 18 | LIST = 15 19 | UTF8 = 16 20 | UTF16 = 17 21 | 22 | _VALUES_TO_NAMES = ( 23 | 'STOP', 24 | 'VOID', 25 | 'BOOL', 26 | 'BYTE', 27 | 'DOUBLE', 28 | None, 29 | 'I16', 30 | None, 31 | 'I32', 32 | None, 33 | 'I64', 34 | 'STRING', 35 | 'STRUCT', 36 | 'MAP', 37 | 'SET', 38 | 'LIST', 39 | 'UTF8', 40 | 'UTF16', 41 | ) 42 | 43 | 44 | class TMessageType(object): 45 | CALL = 1 46 | REPLY = 2 47 | EXCEPTION = 3 48 | ONEWAY = 4 49 | 50 | 51 | class TProcessor(object): 52 | """Base class for procsessor, which works on two streams.""" 53 | 54 | def process(iprot, oprot): 55 | pass 56 | 57 | 58 | class TException(Exception): 59 | """Base class for all thrift exceptions.""" 60 | 61 | # BaseException.message is deprecated in Python v[2.6,3.0) 62 | if (2, 6, 0) <= sys.version_info < (3, 0): 63 | def _get_message(self): 64 | return self._message 65 | 66 | def _set_message(self, message): 67 | self._message = message 68 | message = property(_get_message, _set_message) 69 | 70 | def __init__(self, message=None): 71 | Exception.__init__(self, message) 72 | self.message = message 73 | 74 | 75 | class TApplicationException(TException): 76 | """Application level thrift exceptions.""" 77 | 78 | UNKNOWN = 0 79 | UNKNOWN_METHOD = 1 80 | INVALID_MESSAGE_TYPE = 2 81 | WRONG_METHOD_NAME = 3 82 | BAD_SEQUENCE_ID = 4 83 | MISSING_RESULT = 5 84 | INTERNAL_ERROR = 6 85 | PROTOCOL_ERROR = 7 86 | INVALID_TRANSFORM = 8 87 | INVALID_PROTOCOL = 9 88 | UNSUPPORTED_CLIENT_TYPE = 10 89 | 90 | def __init__(self, type=UNKNOWN, message=None): 91 | TException.__init__(self, message) 92 | self.type = type 93 | 94 | def __str__(self): 95 | if self.message: 96 | return self.message 97 | elif self.type == self.UNKNOWN_METHOD: 98 | return 'Unknown method' 99 | elif self.type == self.INVALID_MESSAGE_TYPE: 100 | return 'Invalid message type' 101 | elif self.type == self.WRONG_METHOD_NAME: 102 | return 'Wrong method name' 103 | elif self.type == self.BAD_SEQUENCE_ID: 104 | return 'Bad sequence ID' 105 | elif self.type == self.MISSING_RESULT: 106 | return 'Missing result' 107 | elif self.type == self.INTERNAL_ERROR: 108 | return 'Internal error' 109 | elif self.type == self.PROTOCOL_ERROR: 110 | return 'Protocol error' 111 | elif self.type == self.INVALID_TRANSFORM: 112 | return 'Invalid transform' 113 | elif self.type == self.INVALID_PROTOCOL: 114 | return 'Invalid protocol' 115 | elif self.type == self.UNSUPPORTED_CLIENT_TYPE: 116 | return 'Unsupported client type' 117 | else: 118 | return 'Default (unknown) TApplicationException' 119 | 120 | def read(self, iprot): 121 | iprot.readStructBegin() 122 | while True: 123 | (fname, ftype, fid) = iprot.readFieldBegin() 124 | if ftype == TType.STOP: 125 | break 126 | if fid == 1: 127 | if ftype == TType.STRING: 128 | self.message = iprot.readString() 129 | else: 130 | iprot.skip(ftype) 131 | elif fid == 2: 132 | if ftype == TType.I32: 133 | self.type = iprot.readI32() 134 | else: 135 | iprot.skip(ftype) 136 | else: 137 | iprot.skip(ftype) 138 | iprot.readFieldEnd() 139 | iprot.readStructEnd() 140 | 141 | def write(self, oprot): 142 | oprot.writeStructBegin('TApplicationException') 143 | if self.message is not None: 144 | oprot.writeFieldBegin('message', TType.STRING, 1) 145 | oprot.writeString(self.message) 146 | oprot.writeFieldEnd() 147 | if self.type is not None: 148 | oprot.writeFieldBegin('type', TType.I32, 2) 149 | oprot.writeI32(self.type) 150 | oprot.writeFieldEnd() 151 | oprot.writeFieldStop() 152 | oprot.writeStructEnd() 153 | 154 | 155 | class TFrozenDict(dict): 156 | """A dictionary that is "frozen" like a frozenset""" 157 | 158 | def __init__(self, *args, **kwargs): 159 | super(TFrozenDict, self).__init__(*args, **kwargs) 160 | # Sort the items so they will be in a consistent order. 161 | # XOR in the hash of the class so we don't collide with 162 | # the hash of a list of tuples. 163 | self.__hashval = hash(TFrozenDict) ^ hash(tuple(sorted(self.items()))) 164 | 165 | def __setitem__(self, *args): 166 | raise TypeError("Can't modify frozen TFreezableDict") 167 | 168 | def __delitem__(self, *args): 169 | raise TypeError("Can't modify frozen TFreezableDict") 170 | 171 | def __hash__(self): 172 | return self.__hashval 173 | -------------------------------------------------------------------------------- /thrift/transport/TSocket.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | import errno 5 | import logging 6 | import os 7 | import socket 8 | import sys 9 | from .TTransport import TTransportBase, TTransportException, TServerTransportBase 10 | logger = logging.getLogger(__name__) 11 | class TSocketBase(TTransportBase): 12 | def _resolveAddr(self): 13 | if self._unix_socket is not None: 14 | return [(socket.AF_UNIX, socket.SOCK_STREAM, None, None, 15 | self._unix_socket)] 16 | else: 17 | return socket.getaddrinfo(self.host, 18 | self.port, 19 | self._socket_family, 20 | socket.SOCK_STREAM, 21 | 0, 22 | socket.AI_PASSIVE | socket.AI_ADDRCONFIG) 23 | def close(self): 24 | if self.handle: 25 | self.handle.close() 26 | self.handle = None 27 | class TSocket(TSocketBase): 28 | def __init__(self, host='PrankBots', port=9090, unix_socket=None, socket_family=socket.AF_UNSPEC): 29 | self.host = host 30 | self.port = port 31 | self.handle = None 32 | self._unix_socket = unix_socket 33 | self._timeout = None 34 | self._socket_family = socket_family 35 | def setHandle(self, h): 36 | self.handle = h 37 | def isOpen(self): 38 | return self.handle is not None 39 | def setTimeout(self, ms): 40 | if ms is None: 41 | self._timeout = None 42 | else: 43 | self._timeout = ms / 1000.0 44 | if self.handle is not None: 45 | self.handle.settimeout(self._timeout) 46 | def _do_open(self, family, socktype): 47 | return socket.socket(family, socktype) 48 | @property 49 | def _address(self): 50 | return self._unix_socket if self._unix_socket else '%s:%d' % (self.host, self.port) 51 | def open(self): 52 | if self.handle: 53 | raise TTransportException(TTransportException.ALREADY_OPEN) 54 | try: 55 | addrs = self._resolveAddr() 56 | except socket.gaierror: 57 | msg = 'ip salah ' + str(self._address) 58 | logger.exception(msg) 59 | raise TTransportException(TTransportException.NOT_OPEN, msg) 60 | for family, socktype, _, _, sockaddr in addrs: 61 | handle = self._do_open(family, socktype) 62 | handle.settimeout(self._timeout) 63 | try: 64 | handle.connect(sockaddr) 65 | self.handle = handle 66 | return 67 | except socket.error: 68 | handle.close() 69 | logger.info('koneksi ke %s', sockaddr, exc_info=True) 70 | msg = 'house %s' % list(map(lambda a: a[4], 71 | addrs)) 72 | logger.error(msg) 73 | raise TTransportException(TTransportException.NOT_OPEN, msg) 74 | def read(self, sz): 75 | try: 76 | buff = self.handle.recv(sz) 77 | except socket.error as e: 78 | if (e.args[0] == errno.ECONNRESET and 79 | (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))): 80 | self.close() 81 | buff = '' 82 | else: 83 | raise 84 | if len(buff) == 0: 85 | raise TTransportException(type=TTransportException.END_OF_FILE, 86 | message='TSocket read 0 bytes') 87 | return buff 88 | def write(self, buff): 89 | if not self.handle: 90 | raise TTransportException(type=TTransportException.NOT_OPEN, 91 | message='Transport not open') 92 | sent = 0 93 | have = len(buff) 94 | while sent < have: 95 | plus = self.handle.send(buff) 96 | if plus == 0: 97 | raise TTransportException(type=TTransportException.END_OF_FILE, 98 | message='TSocket sent 0 bytes') 99 | sent += plus 100 | buff = buff[plus:] 101 | def flush(self): 102 | pass 103 | class TServerSocket(TSocketBase, TServerTransportBase): 104 | def __init__(self, host=None, port=9090, unix_socket=None, socket_family=socket.AF_UNSPEC): 105 | self.host = host 106 | self.port = port 107 | self._unix_socket = unix_socket 108 | self._socket_family = socket_family 109 | self.handle = None 110 | def listen(self): 111 | res0 = self._resolveAddr() 112 | socket_family = self._socket_family == socket.AF_UNSPEC and socket.AF_INET6 or self._socket_family 113 | for res in res0: 114 | if res[0] is socket_family or res is res0[-1]: 115 | break 116 | if self._unix_socket: 117 | tmp = socket.socket(res[0], res[1]) 118 | try: 119 | tmp.connect(res[4]) 120 | except socket.error as err: 121 | eno, message = err.args 122 | if eno == errno.ECONNREFUSED: 123 | os.unlink(res[4]) 124 | self.handle = socket.socket(res[0], res[1]) 125 | self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 126 | if hasattr(self.handle, 'settimeout'): 127 | self.handle.settimeout(None) 128 | self.handle.bind(res[4]) 129 | self.handle.listen(128) 130 | def accept(self): 131 | client, addr = self.handle.accept() 132 | result = TSocket() 133 | result.setHandle(client) 134 | return result 135 | # CROT BRO -------------------------------------------------------------------------------- /thrift/TTornado.py: -------------------------------------------------------------------------------- 1 | # ACIL. CREATOR 2 | # MODIFED BY : PRANKBOTS 3 | from __future__ import absolute_import 4 | import logging 5 | import socket 6 | import struct 7 | from .transport.TTransport import TTransportException, TTransportBase, TMemoryBuffer 8 | from io import BytesIO 9 | from collections import deque 10 | from contextlib import contextmanager 11 | from tornado import gen, iostream, ioloop, tcpserver, concurrent 12 | __all__ = ['TTornadoServer', 'TTornadoStreamTransport'] 13 | logger = logging.getLogger(__name__) 14 | class _Lock(object): 15 | def __init__(self): 16 | self._waiters = deque() 17 | def acquired(self): 18 | return len(self._waiters) > 0 19 | @gen.coroutine 20 | def acquire(self): 21 | blocker = self._waiters[-1] if self.acquired() else None 22 | future = concurrent.Future() 23 | self._waiters.append(future) 24 | if blocker: 25 | yield blocker 26 | raise gen.Return(self._lock_context()) 27 | def release(self): 28 | assert self.acquired(), 'TERKUNCI' 29 | future = self._waiters.popleft() 30 | future.set_result(None) 31 | @contextmanager 32 | def _lock_context(self): 33 | try: 34 | yield 35 | finally: 36 | self.release() 37 | class TTornadoStreamTransport(TTransportBase): 38 | """BAHAGIA LAH KAWAN""" 39 | def __init__(self, host, port, stream=None, io_loop=None): 40 | self.host = host 41 | self.port = port 42 | self.io_loop = io_loop or ioloop.IOLoop.current() 43 | self.__wbuf = BytesIO() 44 | self._read_lock = _Lock() 45 | # SERVER PROFT 46 | self.stream = stream 47 | def with_timeout(self, timeout, future): 48 | return gen.with_timeout(timeout, future, self.io_loop) 49 | @gen.coroutine 50 | def open(self, timeout=None): 51 | logger.debug('koneksi ke server') 52 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) 53 | self.stream = iostream.IOStream(sock) 54 | try: 55 | connect = self.stream.connect((self.host, self.port)) 56 | if timeout is not None: 57 | yield self.with_timeout(timeout, connect) 58 | else: 59 | yield connect 60 | except (socket.error, IOError, ioloop.TimeoutError) as e: 61 | message = 'could not connect to {}:{} ({})'.format(self.host, self.port, e) 62 | raise TTransportException( 63 | type=TTransportException.NOT_OPEN, 64 | message=message) 65 | raise gen.Return(self) 66 | def set_close_callback(self, callback): 67 | """tutup umpan balik""" 68 | self.stream.set_close_callback(callback) 69 | def close(self): 70 | self.stream.set_close_callback(None) 71 | self.stream.close() 72 | def read(self, _): 73 | assert False, "membaca kontibusi" 74 | @contextmanager 75 | def io_exception_context(self): 76 | try: 77 | yield 78 | except (socket.error, IOError) as e: 79 | raise TTransportException( 80 | type=TTransportException.END_OF_FILE, 81 | message=str(e)) 82 | except iostream.StreamBufferFullError as e: 83 | raise TTransportException( 84 | type=TTransportException.UNKNOWN, 85 | message=str(e)) 86 | @gen.coroutine 87 | def readFrame(self): 88 | # IOStream processes reads one at a time 89 | with (yield self._read_lock.acquire()): 90 | with self.io_exception_context(): 91 | frame_header = yield self.stream.read_bytes(4) 92 | if len(frame_header) == 0: 93 | raise iostream.StreamClosedError('Read zero bytes from stream') 94 | frame_length, = struct.unpack('!i', frame_header) 95 | frame = yield self.stream.read_bytes(frame_length) 96 | raise gen.Return(frame) 97 | def write(self, buf): 98 | self.__wbuf.write(buf) 99 | def flush(self): 100 | frame = self.__wbuf.getvalue() 101 | # reset wbuf before write/flush to preserve state on underlying failure 102 | frame_length = struct.pack('!i', len(frame)) 103 | self.__wbuf = BytesIO() 104 | with self.io_exception_context(): 105 | return self.stream.write(frame_length + frame) 106 | class TTornadoServer(tcpserver.TCPServer): 107 | def __init__(self, processor, iprot_factory, oprot_factory=None, 108 | *args, **kwargs): 109 | super(TTornadoServer, self).__init__(*args, **kwargs) 110 | self._processor = processor 111 | self._iprot_factory = iprot_factory 112 | self._oprot_factory = (oprot_factory if oprot_factory is not None 113 | else iprot_factory) 114 | @gen.coroutine 115 | def handle_stream(self, stream, address): 116 | host, port = address[:2] 117 | trans = TTornadoStreamTransport(host=host, port=port, stream=stream, 118 | io_loop=self.io_loop) 119 | oprot = self._oprot_factory.getProtocol(trans) 120 | try: 121 | while not trans.stream.closed(): 122 | try: 123 | frame = yield trans.readFrame() 124 | except TTransportException as e: 125 | if e.type == TTransportException.END_OF_FILE: 126 | break 127 | else: 128 | raise 129 | tr = TMemoryBuffer(frame) 130 | iprot = self._iprot_factory.getProtocol(tr) 131 | yield self._processor.process(iprot, oprot) 132 | except Exception: 133 | logger.exception('thrift mod by acil') 134 | trans.close() 135 | logger.info('menutup koneksi %s:%d', host, port) 136 | -------------------------------------------------------------------------------- /thrift/protocol/TBinaryProtocol.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from .TProtocol import TType, TProtocolBase, TProtocolException 5 | from struct import pack, unpack 6 | 7 | class TBinaryProtocol(TProtocolBase): 8 | VERSION_MASK = -65536 9 | VERSION_1 = -2147418112 10 | TYPE_MASK = 0x000000ff 11 | def __init__(self, trans, strictRead=False, strictWrite=True, **kwargs): 12 | TProtocolBase.__init__(self, trans) 13 | self.strictRead = strictRead 14 | self.strictWrite = strictWrite 15 | self.string_length_limit = kwargs.get('string_length_limit', None) 16 | self.container_length_limit = kwargs.get('container_length_limit', None) 17 | def _check_string_length(self, length): 18 | self._check_length(self.string_length_limit, length) 19 | def _check_container_length(self, length): 20 | self._check_length(self.container_length_limit, length) 21 | def writeMessageBegin(self, name, type, seqid): 22 | if self.strictWrite: 23 | self.writeI32(TBinaryProtocol.VERSION_1 | type) 24 | self.writeString(name) 25 | self.writeI32(seqid) 26 | else: 27 | self.writeString(name) 28 | self.writeByte(type) 29 | self.writeI32(seqid) 30 | def writeMessageEnd(self): 31 | pass 32 | def writeStructBegin(self, name): 33 | pass 34 | def writeStructEnd(self): 35 | pass 36 | def writeFieldBegin(self, name, type, id): 37 | self.writeByte(type) 38 | self.writeI16(id) 39 | def writeFieldEnd(self): 40 | pass 41 | def writeFieldStop(self): 42 | self.writeByte(TType.STOP) 43 | def writeMapBegin(self, ktype, vtype, size): 44 | self.writeByte(ktype) 45 | self.writeByte(vtype) 46 | self.writeI32(size) 47 | def writeMapEnd(self): 48 | pass 49 | def writeListBegin(self, etype, size): 50 | self.writeByte(etype) 51 | self.writeI32(size) 52 | def writeListEnd(self): 53 | pass 54 | def writeSetBegin(self, etype, size): 55 | self.writeByte(etype) 56 | self.writeI32(size) 57 | def writeSetEnd(self): 58 | pass 59 | def writeBool(self, bool): 60 | if bool: 61 | self.writeByte(1) 62 | else: 63 | self.writeByte(0) 64 | def writeByte(self, byte): 65 | buff = pack("!b", byte) 66 | self.trans.write(buff) 67 | def writeI16(self, i16): 68 | buff = pack("!h", i16) 69 | self.trans.write(buff) 70 | def writeI32(self, i32): 71 | buff = pack("!i", i32) 72 | self.trans.write(buff) 73 | def writeI64(self, i64): 74 | buff = pack("!q", i64) 75 | self.trans.write(buff) 76 | def writeDouble(self, dub): 77 | buff = pack("!d", dub) 78 | self.trans.write(buff) 79 | def writeBinary(self, str): 80 | self.writeI32(len(str)) 81 | self.trans.write(str) 82 | def readMessageBegin(self): 83 | sz = self.readI32() 84 | if sz < 0: 85 | version = sz & TBinaryProtocol.VERSION_MASK 86 | if version != TBinaryProtocol.VERSION_1: 87 | raise TProtocolException( 88 | type=TProtocolException.BAD_VERSION, 89 | message='Bad version in readMessageBegin: %d' % (sz)) 90 | type = sz & TBinaryProtocol.TYPE_MASK 91 | name = self.readString() 92 | seqid = self.readI32() 93 | else: 94 | if self.strictRead: 95 | raise TProtocolException(type=TProtocolException.BAD_VERSION, 96 | message='No protocol version header') 97 | name = self.trans.readAll(sz) 98 | type = self.readByte() 99 | seqid = self.readI32() 100 | return (name, type, seqid) 101 | def readMessageEnd(self): 102 | pass 103 | def readStructBegin(self): 104 | pass 105 | def readStructEnd(self): 106 | pass 107 | def readFieldBegin(self): 108 | type = self.readByte() 109 | if type == TType.STOP: 110 | return (None, type, 0) 111 | id = self.readI16() 112 | return (None, type, id) 113 | def readFieldEnd(self): 114 | pass 115 | def readMapBegin(self): 116 | ktype = self.readByte() 117 | vtype = self.readByte() 118 | size = self.readI32() 119 | self._check_container_length(size) 120 | return (ktype, vtype, size) 121 | def readMapEnd(self): 122 | pass 123 | def readListBegin(self): 124 | etype = self.readByte() 125 | size = self.readI32() 126 | self._check_container_length(size) 127 | return (etype, size) 128 | def readListEnd(self): 129 | pass 130 | def readSetBegin(self): 131 | etype = self.readByte() 132 | size = self.readI32() 133 | self._check_container_length(size) 134 | return (etype, size) 135 | def readSetEnd(self): 136 | pass 137 | def readBool(self): 138 | byte = self.readByte() 139 | if byte == 0: 140 | return False 141 | return True 142 | def readByte(self): 143 | buff = self.trans.readAll(1) 144 | val, = unpack('!b', buff) 145 | return val 146 | def readI16(self): 147 | buff = self.trans.readAll(2) 148 | val, = unpack('!h', buff) 149 | return val 150 | def readI32(self): 151 | buff = self.trans.readAll(4) 152 | val, = unpack('!i', buff) 153 | return val 154 | def readI64(self): 155 | buff = self.trans.readAll(8) 156 | val, = unpack('!q', buff) 157 | return val 158 | def readDouble(self): 159 | buff = self.trans.readAll(8) 160 | val, = unpack('!d', buff) 161 | return val 162 | def readBinary(self): 163 | size = self.readI32() 164 | self._check_string_length(size) 165 | s = self.trans.readAll(size) 166 | return s 167 | class TBinaryProtocolFactory(object): 168 | def __init__(self, strictRead=False, strictWrite=True, **kwargs): 169 | self.strictRead = strictRead 170 | self.strictWrite = strictWrite 171 | self.string_length_limit = kwargs.get('string_length_limit', None) 172 | self.container_length_limit = kwargs.get('container_length_limit', None) 173 | def getProtocol(self, trans): 174 | prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite, 175 | string_length_limit=self.string_length_limit, 176 | container_length_limit=self.container_length_limit) 177 | return prot 178 | class TBinaryProtocolAccelerated(TBinaryProtocol): 179 | pass 180 | def __init__(self, *args, **kwargs): 181 | fallback = kwargs.pop('fallback', True) 182 | super(TBinaryProtocolAccelerated, self).__init__(*args, **kwargs) 183 | try: 184 | from thrift.protocol import fastbinary 185 | except ImportError: 186 | if not fallback: 187 | raise 188 | else: 189 | self._fast_decode = fastbinary.decode_binary 190 | self._fast_encode = fastbinary.encode_binary 191 | class TBinaryProtocolAcceleratedFactory(object): 192 | def __init__(self, 193 | string_length_limit=None, 194 | container_length_limit=None, 195 | fallback=True): 196 | self.string_length_limit = string_length_limit 197 | self.container_length_limit = container_length_limit 198 | self._fallback = fallback 199 | def getProtocol(self, trans): 200 | return TBinaryProtocolAccelerated( 201 | trans, 202 | string_length_limit=self.string_length_limit, 203 | container_length_limit=self.container_length_limit, 204 | fallback=self._fallback) 205 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 206 | #CREATOR BY : PRANKBOT 207 | #MOD BY ACIL -------------------------------------------------------------------------------- /KIA/object.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from datetime import datetime 3 | import json, time, ntpath 4 | 5 | def loggedIn(func): 6 | def checkLogin(*args, **kwargs): 7 | if args[0].isLogin: 8 | return func(*args, **kwargs) 9 | else: 10 | args[0].callback.other("You want to call the function, you must login to LINE") 11 | return checkLogin 12 | 13 | class LineObject(object): 14 | 15 | def __init__(self): 16 | if self.isLogin == True: 17 | self.log("[%s] : Login success" % self.profile.displayName) 18 | 19 | """Group""" 20 | 21 | @loggedIn 22 | def updateGroupPicture(self, groupId, path): 23 | files = {'file': open(path, 'rb')} 24 | data = {'params': self.genOBSParams({'oid': groupId,'type': 'image'})} 25 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/g/upload.nhn', data=data, files=files) 26 | if r.status_code != 201: 27 | raise Exception('Update group picture failure.') 28 | return True 29 | 30 | """Personalize""" 31 | 32 | @loggedIn 33 | def updateProfilePicture(self, path, type='p'): 34 | files = {'file': open(path, 'rb')} 35 | params = {'oid': self.profile.mid,'type': 'image'} 36 | if type == 'vp': 37 | params.update({'ver': '2.0', 'cat': 'vp.mp4'}) 38 | data = {'params': self.genOBSParams(params)} 39 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/p/upload.nhn', data=data, files=files) 40 | if r.status_code != 201: 41 | raise Exception('Update profile picture failure.') 42 | return True 43 | 44 | @loggedIn 45 | def updateProfileVideoPicture(self, path): 46 | try: 47 | from ffmpy import FFmpeg 48 | files = {'file': open(path, 'rb')} 49 | data = {'params': self.genOBSParams({'oid': self.profile.mid,'ver': '2.0','type': 'video','cat': 'vp.mp4'})} 50 | r_vp = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/vp/upload.nhn', data=data, files=files) 51 | if r_vp.status_code != 201: 52 | raise Exception('Update profile video picture failure.') 53 | path_p = self.genTempFile('path') 54 | ff = FFmpeg(inputs={'%s' % path: None}, outputs={'%s' % path_p: ['-ss', '00:00:2', '-vframes', '1']}) 55 | ff.run() 56 | self.updateProfilePicture(path_p, 'vp') 57 | except: 58 | raise Exception('You should install FFmpeg and ffmpy from pypi') 59 | 60 | @loggedIn 61 | def updateProfileCover(self, path, returnAs='bool'): 62 | if len(self.server.channelHeaders) < 1: 63 | raise Exception('LineChannel instance is required for acquire this action.') 64 | else: 65 | if returnAs not in ['objId','bool']: 66 | raise Exception('Invalid returnAs value') 67 | objId = self.uploadObjHome(path, type='image', returnAs='objId') 68 | home = self._channel.updateProfileCoverById(objId) 69 | if returnAs == 'objId': 70 | return objId 71 | elif returnAs == 'bool': 72 | return True 73 | 74 | """Object""" 75 | 76 | @loggedIn 77 | def uploadObjTalk(self, path, type='image', returnAs='bool', objId=None, to=None): 78 | if returnAs not in ['objId','bool']: 79 | raise Exception('Invalid returnAs value') 80 | if type not in ['image','gif','video','audio','file']: 81 | raise Exception('Invalid type value') 82 | headers=None 83 | files = {'file': open(path, 'rb')} 84 | if type == 'image' or type == 'video' or type == 'audio' or type == 'file': 85 | e_p = self.server.LINE_OBS_DOMAIN + '/talk/m/upload.nhn' 86 | data = {'params': self.genOBSParams({'oid': objId,'size': len(open(path, 'rb').read()),'type': type})} 87 | elif type == 'gif': 88 | e_p = self.server.LINE_OBS_DOMAIN + '/r/talk/m/reqseq' 89 | files = None 90 | data = open(path, 'rb').read() 91 | params = { 92 | 'oid': 'reqseq', 93 | 'reqseq': '%s' % str(self.revision), 94 | 'tomid': '%s' % str(to), 95 | 'size': '%s' % str(len(data)), 96 | 'range': len(data), 97 | 'type': 'image' 98 | } 99 | headers = self.server.additionalHeaders(self.server.Headers, { 100 | 'Content-Type': 'image/gif', 101 | 'Content-Length': str(len(data)), 102 | 'x-obs-params': self.genOBSParams(params,'b64') 103 | }) 104 | r = self.server.postContent(e_p, data=data, headers=headers, files=files) 105 | if r.status_code != 201: 106 | raise Exception('Upload %s failure.' % type) 107 | if returnAs == 'objId': 108 | return objId 109 | elif returnAs == 'bool': 110 | return True 111 | 112 | @loggedIn 113 | def uploadObjHome(self, path, type='image', returnAs='bool', objId=None): 114 | if len(self.server.channelHeaders) < 1: 115 | raise Exception('LineChannel instance is required for acquire this action.') 116 | else: 117 | if returnAs not in ['objId','bool']: 118 | raise Exception('Invalid returnAs value') 119 | if type not in ['image','video','audio']: 120 | raise Exception('Invalid type value') 121 | if type == 'image': 122 | contentType = 'image/jpeg' 123 | elif type == 'video': 124 | contentType = 'video/mp4' 125 | elif type == 'audio': 126 | contentType = 'audio/mp3' 127 | if not objId: 128 | objId = int(time.time()) 129 | file = open(path, 'rb').read() 130 | params = { 131 | 'userid': '%s' % self.profile.mid, 132 | 'oid': '%s' % str(objId), 133 | 'range': len(file), 134 | 'type': type 135 | } 136 | hr = self.server.additionalHeaders(self.server.channelHeaders, { 137 | 'Content-Type': contentType, 138 | 'Content-Length': str(len(file)), 139 | 'x-obs-params': self.genOBSParams(params,'b64') 140 | }) 141 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/myhome/c/upload.nhn', headers=hr, data=file) 142 | if r.status_code != 201: 143 | raise Exception('Upload object home failure.') 144 | if returnAs == 'objId': 145 | return objId 146 | elif returnAs == 'bool': 147 | return True 148 | 149 | @loggedIn 150 | def downloadObjectMsg(self, messageId, returnAs='path', saveAs=''): 151 | if saveAs == '': 152 | saveAs = self.genTempFile('path') 153 | if returnAs not in ['path','bool','bin']: 154 | raise Exception('Invalid returnAs value') 155 | params = {'oid': messageId} 156 | url = self.server.urlEncode(self.server.LINE_OBS_DOMAIN, '/talk/m/download.nhn', params) 157 | r = self.server.getContent(url) 158 | if r.status_code == 200: 159 | self.saveFile(saveAs, r.raw) 160 | if returnAs == 'path': 161 | return saveAs 162 | elif returnAs == 'bool': 163 | return True 164 | elif returnAs == 'bin': 165 | return r.raw 166 | else: 167 | raise Exception('Download object failure.') 168 | 169 | @loggedIn 170 | def forwardObjectMsg(self, to, msgId, contentType='image'): 171 | if contentType not in ['image','video','audio']: 172 | raise Exception('Type not valid.') 173 | data = self.genOBSParams({'oid': 'reqseq','reqseq': self.revision,'type': contentType,'copyFrom': '/talk/m/%s' % msgId},'default') 174 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/m/copy.nhn', data=data) 175 | if r.status_code != 200: 176 | raise Exception('Forward object failure.') 177 | return True -------------------------------------------------------------------------------- /thrift/server/TServer.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from six.moves import queue 5 | import logging 6 | import os 7 | import threading 8 | from thrift.protocol import TBinaryProtocol 9 | from thrift.transport import TTransport 10 | logger = logging.getLogger(__name__) 11 | class TServer(object): 12 | def __init__(self, *args): 13 | if (len(args) == 2): 14 | self.__initArgs__(args[0], args[1], 15 | TTransport.TTransportFactoryBase(), 16 | TTransport.TTransportFactoryBase(), 17 | TBinaryProtocol.TBinaryProtocolFactory(), 18 | TBinaryProtocol.TBinaryProtocolFactory()) 19 | elif (len(args) == 4): 20 | self.__initArgs__(args[0], args[1], args[2], args[2], args[3], args[3]) 21 | elif (len(args) == 6): 22 | self.__initArgs__(args[0], args[1], args[2], args[3], args[4], args[5]) 23 | def __initArgs__(self, processor, serverTransport, 24 | inputTransportFactory, outputTransportFactory, 25 | inputProtocolFactory, outputProtocolFactory): 26 | self.processor = processor 27 | self.serverTransport = serverTransport 28 | self.inputTransportFactory = inputTransportFactory 29 | self.outputTransportFactory = outputTransportFactory 30 | self.inputProtocolFactory = inputProtocolFactory 31 | self.outputProtocolFactory = outputProtocolFactory 32 | def serve(self): 33 | pass 34 | class TSimpleServer(TServer): 35 | def __init__(self, *args): 36 | TServer.__init__(self, *args) 37 | def serve(self): 38 | self.serverTransport.listen() 39 | while True: 40 | client = self.serverTransport.accept() 41 | if not client: 42 | continue 43 | itrans = self.inputTransportFactory.getTransport(client) 44 | otrans = self.outputTransportFactory.getTransport(client) 45 | iprot = self.inputProtocolFactory.getProtocol(itrans) 46 | oprot = self.outputProtocolFactory.getProtocol(otrans) 47 | try: 48 | while True: 49 | self.processor.process(iprot, oprot) 50 | except TTransport.TTransportException: 51 | pass 52 | except Exception as x: 53 | logger.exception(x) 54 | itrans.close() 55 | otrans.close() 56 | class TThreadedServer(TServer): 57 | def __init__(self, *args, **kwargs): 58 | TServer.__init__(self, *args) 59 | self.daemon = kwargs.get("daemon", False) 60 | def serve(self): 61 | self.serverTransport.listen() 62 | while True: 63 | try: 64 | client = self.serverTransport.accept() 65 | if not client: 66 | continue 67 | t = threading.Thread(target=self.handle, args=(client,)) 68 | t.setDaemon(self.daemon) 69 | t.start() 70 | except KeyboardInterrupt: 71 | raise 72 | except Exception as x: 73 | logger.exception(x) 74 | def handle(self, client): 75 | itrans = self.inputTransportFactory.getTransport(client) 76 | otrans = self.outputTransportFactory.getTransport(client) 77 | iprot = self.inputProtocolFactory.getProtocol(itrans) 78 | oprot = self.outputProtocolFactory.getProtocol(otrans) 79 | try: 80 | while True: 81 | self.processor.process(iprot, oprot) 82 | except TTransport.TTransportException: 83 | pass 84 | except Exception as x: 85 | logger.exception(x) 86 | itrans.close() 87 | otrans.close() 88 | class TThreadPoolServer(TServer): 89 | def __init__(self, *args, **kwargs): 90 | TServer.__init__(self, *args) 91 | self.clients = queue.Queue() 92 | self.threads = 10 93 | self.daemon = kwargs.get("daemon", False) 94 | def setNumThreads(self, num): 95 | self.threads = num 96 | def serveThread(self): 97 | while True: 98 | try: 99 | client = self.clients.get() 100 | self.serveClient(client) 101 | except Exception as x: 102 | logger.exception(x) 103 | 104 | def serveClient(self, client): 105 | itrans = self.inputTransportFactory.getTransport(client) 106 | otrans = self.outputTransportFactory.getTransport(client) 107 | iprot = self.inputProtocolFactory.getProtocol(itrans) 108 | oprot = self.outputProtocolFactory.getProtocol(otrans) 109 | try: 110 | while True: 111 | self.processor.process(iprot, oprot) 112 | except TTransport.TTransportException: 113 | pass 114 | except Exception as x: 115 | logger.exception(x) 116 | itrans.close() 117 | otrans.close() 118 | def serve(self): 119 | for i in range(self.threads): 120 | try: 121 | t = threading.Thread(target=self.serveThread) 122 | t.setDaemon(self.daemon) 123 | t.start() 124 | except Exception as x: 125 | logger.exception(x) 126 | self.serverTransport.listen() 127 | while True: 128 | try: 129 | client = self.serverTransport.accept() 130 | if not client: 131 | continue 132 | self.clients.put(client) 133 | except Exception as x: 134 | logger.exception(x) 135 | class TForkingServer(TServer): 136 | def __init__(self, *args): 137 | TServer.__init__(self, *args) 138 | self.children = [] 139 | def serve(self): 140 | def try_close(file): 141 | try: 142 | file.close() 143 | except IOError as e: 144 | logger.warning(e, exc_info=True) 145 | self.serverTransport.listen() 146 | while True: 147 | client = self.serverTransport.accept() 148 | if not client: 149 | continue 150 | try: 151 | pid = os.fork() 152 | if pid: 153 | self.children.append(pid) 154 | self.collect_children() 155 | itrans = self.inputTransportFactory.getTransport(client) 156 | otrans = self.outputTransportFactory.getTransport(client) 157 | try_close(itrans) 158 | try_close(otrans) 159 | else: 160 | itrans = self.inputTransportFactory.getTransport(client) 161 | otrans = self.outputTransportFactory.getTransport(client) 162 | iprot = self.inputProtocolFactory.getProtocol(itrans) 163 | oprot = self.outputProtocolFactory.getProtocol(otrans) 164 | ecode = 0 165 | try: 166 | try: 167 | while True: 168 | self.processor.process(iprot, oprot) 169 | except TTransport.TTransportException: 170 | pass 171 | except Exception as e: 172 | logger.exception(e) 173 | ecode = 1 174 | finally: 175 | try_close(itrans) 176 | try_close(otrans) 177 | os._exit(ecode) 178 | except TTransport.TTransportException: 179 | pass 180 | except Exception as x: 181 | logger.exception(x) 182 | def collect_children(self): 183 | while self.children: 184 | try: 185 | pid, status = os.waitpid(0, os.WNOHANG) 186 | except os.error: 187 | pid = None 188 | 189 | if pid: 190 | self.children.remove(pid) 191 | else: 192 | break 193 | # MOD BY ACIL 194 | # CREATOR BY PRANKBOTS -------------------------------------------------------------------------------- /akad/UniversalNotificationService.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.10.0) 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | # options string: py 7 | # 8 | 9 | from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException 10 | from thrift.protocol.TProtocol import TProtocolException 11 | import sys 12 | import logging 13 | from .ttypes import * 14 | from thrift.Thrift import TProcessor 15 | from thrift.transport import TTransport 16 | 17 | 18 | class Iface(object): 19 | def notify(self, event): 20 | """ 21 | Parameters: 22 | - event 23 | """ 24 | pass 25 | 26 | 27 | class Client(Iface): 28 | def __init__(self, iprot, oprot=None): 29 | self._iprot = self._oprot = iprot 30 | if oprot is not None: 31 | self._oprot = oprot 32 | self._seqid = 0 33 | 34 | def notify(self, event): 35 | """ 36 | Parameters: 37 | - event 38 | """ 39 | self.send_notify(event) 40 | self.recv_notify() 41 | 42 | def send_notify(self, event): 43 | self._oprot.writeMessageBegin('notify', TMessageType.CALL, self._seqid) 44 | args = notify_args() 45 | args.event = event 46 | args.write(self._oprot) 47 | self._oprot.writeMessageEnd() 48 | self._oprot.trans.flush() 49 | 50 | def recv_notify(self): 51 | iprot = self._iprot 52 | (fname, mtype, rseqid) = iprot.readMessageBegin() 53 | if mtype == TMessageType.EXCEPTION: 54 | x = TApplicationException() 55 | x.read(iprot) 56 | iprot.readMessageEnd() 57 | raise x 58 | result = notify_result() 59 | result.read(iprot) 60 | iprot.readMessageEnd() 61 | if result.e is not None: 62 | raise result.e 63 | return 64 | 65 | 66 | class Processor(Iface, TProcessor): 67 | def __init__(self, handler): 68 | self._handler = handler 69 | self._processMap = {} 70 | self._processMap["notify"] = Processor.process_notify 71 | 72 | def process(self, iprot, oprot): 73 | (name, type, seqid) = iprot.readMessageBegin() 74 | if name not in self._processMap: 75 | iprot.skip(TType.STRUCT) 76 | iprot.readMessageEnd() 77 | x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) 78 | oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) 79 | x.write(oprot) 80 | oprot.writeMessageEnd() 81 | oprot.trans.flush() 82 | return 83 | else: 84 | self._processMap[name](self, seqid, iprot, oprot) 85 | return True 86 | 87 | def process_notify(self, seqid, iprot, oprot): 88 | args = notify_args() 89 | args.read(iprot) 90 | iprot.readMessageEnd() 91 | result = notify_result() 92 | try: 93 | self._handler.notify(args.event) 94 | msg_type = TMessageType.REPLY 95 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 96 | raise 97 | except UniversalNotificationServiceException as e: 98 | msg_type = TMessageType.REPLY 99 | result.e = e 100 | except Exception as ex: 101 | msg_type = TMessageType.EXCEPTION 102 | logging.exception(ex) 103 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 104 | oprot.writeMessageBegin("notify", msg_type, seqid) 105 | result.write(oprot) 106 | oprot.writeMessageEnd() 107 | oprot.trans.flush() 108 | 109 | # HELPER FUNCTIONS AND STRUCTURES 110 | 111 | 112 | class notify_args(object): 113 | """ 114 | Attributes: 115 | - event 116 | """ 117 | 118 | thrift_spec = ( 119 | None, # 0 120 | None, # 1 121 | (2, TType.STRUCT, 'event', (GlobalEvent, GlobalEvent.thrift_spec), None, ), # 2 122 | ) 123 | 124 | def __init__(self, event=None,): 125 | self.event = event 126 | 127 | def read(self, iprot): 128 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 129 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 130 | return 131 | iprot.readStructBegin() 132 | while True: 133 | (fname, ftype, fid) = iprot.readFieldBegin() 134 | if ftype == TType.STOP: 135 | break 136 | if fid == 2: 137 | if ftype == TType.STRUCT: 138 | self.event = GlobalEvent() 139 | self.event.read(iprot) 140 | else: 141 | iprot.skip(ftype) 142 | else: 143 | iprot.skip(ftype) 144 | iprot.readFieldEnd() 145 | iprot.readStructEnd() 146 | 147 | def write(self, oprot): 148 | if oprot._fast_encode is not None and self.thrift_spec is not None: 149 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 150 | return 151 | oprot.writeStructBegin('notify_args') 152 | if self.event is not None: 153 | oprot.writeFieldBegin('event', TType.STRUCT, 2) 154 | self.event.write(oprot) 155 | oprot.writeFieldEnd() 156 | oprot.writeFieldStop() 157 | oprot.writeStructEnd() 158 | 159 | def validate(self): 160 | return 161 | 162 | def __repr__(self): 163 | L = ['%s=%r' % (key, value) 164 | for key, value in self.__dict__.items()] 165 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 166 | 167 | def __eq__(self, other): 168 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 169 | 170 | def __ne__(self, other): 171 | return not (self == other) 172 | 173 | 174 | class notify_result(object): 175 | """ 176 | Attributes: 177 | - e 178 | """ 179 | 180 | thrift_spec = ( 181 | None, # 0 182 | (1, TType.STRUCT, 'e', (UniversalNotificationServiceException, UniversalNotificationServiceException.thrift_spec), None, ), # 1 183 | ) 184 | 185 | def __init__(self, e=None,): 186 | self.e = e 187 | 188 | def read(self, iprot): 189 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 190 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 191 | return 192 | iprot.readStructBegin() 193 | while True: 194 | (fname, ftype, fid) = iprot.readFieldBegin() 195 | if ftype == TType.STOP: 196 | break 197 | if fid == 1: 198 | if ftype == TType.STRUCT: 199 | self.e = UniversalNotificationServiceException() 200 | self.e.read(iprot) 201 | else: 202 | iprot.skip(ftype) 203 | else: 204 | iprot.skip(ftype) 205 | iprot.readFieldEnd() 206 | iprot.readStructEnd() 207 | 208 | def write(self, oprot): 209 | if oprot._fast_encode is not None and self.thrift_spec is not None: 210 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 211 | return 212 | oprot.writeStructBegin('notify_result') 213 | if self.e is not None: 214 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 215 | self.e.write(oprot) 216 | oprot.writeFieldEnd() 217 | oprot.writeFieldStop() 218 | oprot.writeStructEnd() 219 | 220 | def validate(self): 221 | return 222 | 223 | def __repr__(self): 224 | L = ['%s=%r' % (key, value) 225 | for key, value in self.__dict__.items()] 226 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 227 | 228 | def __eq__(self, other): 229 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 230 | 231 | def __ne__(self, other): 232 | return not (self == other) 233 | -------------------------------------------------------------------------------- /KIA/auth.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from akad.ttypes import IdentityProvider, LoginResultType, LoginRequest, LoginType 3 | from .server import LineServer 4 | from .session import Session 5 | from .callback import Callback 6 | 7 | import rsa, os 8 | 9 | class LineAuth(object): 10 | isLogin = False 11 | authToken = "" 12 | certificate = "" 13 | 14 | def __init__(self): 15 | self.server = LineServer() 16 | self.callback = Callback(self.defaultCallback) 17 | self.server.setHeadersWithDict({ 18 | 'User-Agent': self.server.USER_AGENT, 19 | 'X-Line-Application': self.server.APP_NAME, 20 | 'X-Line-Carrier': self.server.CARRIER 21 | }) 22 | 23 | def loadSession(self): 24 | self.talk = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_API_QUERY_PATH_FIR).Talk() 25 | self.poll = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_POLL_QUERY_PATH_FIR).Talk() 26 | self.call = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_CALL_QUERY_PATH).Call() 27 | self.channel = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_CHAN_QUERY_PATH).Channel() 28 | self.square = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_SQUARE_QUERY_PATH).Square() 29 | 30 | self.revision = self.poll.getLastOpRevision() 31 | self.isLogin = True 32 | 33 | def loginRequest(self, type, data): 34 | lReq = LoginRequest() 35 | if type == '0': 36 | lReq.type = LoginType.ID_CREDENTIAL 37 | lReq.identityProvider = data['identityProvider'] 38 | lReq.identifier = data['identifier'] 39 | lReq.password = data['password'] 40 | lReq.keepLoggedIn = data['keepLoggedIn'] 41 | lReq.accessLocation = data['accessLocation'] 42 | lReq.systemName = data['systemName'] 43 | lReq.certificate = data['certificate'] 44 | lReq.e2eeVersion = data['e2eeVersion'] 45 | elif type == '1': 46 | lReq.type = LoginType.QRCODE 47 | lReq.keepLoggedIn = data['keepLoggedIn'] 48 | if 'identityProvider' in data: 49 | lReq.identityProvider = data['identityProvider'] 50 | if 'accessLocation' in data: 51 | lReq.accessLocation = data['accessLocation'] 52 | if 'systemName' in data: 53 | lReq.systemName = data['systemName'] 54 | lReq.verifier = data['verifier'] 55 | lReq.e2eeVersion = data['e2eeVersion'] 56 | else: 57 | lReq=False 58 | return lReq 59 | 60 | def login(self, _id, passwd, certificate=None, systemName=None, appName=None, keepLoggedIn=True): 61 | if systemName is None: 62 | systemName=self.server.SYSTEM_NAME 63 | if self.server.EMAIL_REGEX.match(_id): 64 | self.provider = IdentityProvider.LINE # LINE 65 | else: 66 | self.provider = IdentityProvider.NAVER_KR # NAVER 67 | 68 | if appName is None: 69 | appName=self.server.APP_NAME 70 | self.server.setHeaders('X-Line-Application', appName) 71 | self.tauth = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_AUTH_QUERY_PATH).Talk(isopen=False) 72 | 73 | rsaKey = self.tauth.getRSAKeyInfo(self.provider) 74 | 75 | message = (chr(len(rsaKey.sessionKey)) + rsaKey.sessionKey + 76 | chr(len(_id)) + _id + 77 | chr(len(passwd)) + passwd).encode('utf-8') 78 | pub_key = rsa.PublicKey(int(rsaKey.nvalue, 16), int(rsaKey.evalue, 16)) 79 | try: 80 | # Works with python 2.7 81 | crypto = rsa.encrypt(message, pub_key).encode('hex') 82 | except: 83 | # Works with python 3.x 84 | crypto = rsa.encrypt(message, pub_key).hex() 85 | 86 | try: 87 | with open(_id + '.crt', 'r') as f: 88 | self.certificate = f.read() 89 | except: 90 | if certificate is not None: 91 | self.certificate = certificate 92 | if os.path.exists(certificate): 93 | with open(certificate, 'r') as f: 94 | self.certificate = f.read() 95 | 96 | self.auth = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_LOGIN_QUERY_PATH).Auth(isopen=False) 97 | 98 | lReq = self.loginRequest('0', { 99 | 'identityProvider': self.provider, 100 | 'identifier': rsaKey.keynm, 101 | 'password': crypto, 102 | 'keepLoggedIn': keepLoggedIn, 103 | 'accessLocation': self.server.IP_ADDR, 104 | 'systemName': systemName, 105 | 'certificate': self.certificate, 106 | 'e2eeVersion': 0 107 | }) 108 | 109 | result = self.auth.loginZ(lReq) 110 | 111 | if result.type == LoginResultType.REQUIRE_DEVICE_CONFIRM: 112 | self.callback.PinVerified(result.pinCode) 113 | 114 | self.server.setHeaders('X-Line-Access', result.verifier) 115 | getAccessKey = self.server.getJson(self.server.parseUrl(self.server.LINE_CERTIFICATE_PATH), allowHeader=True) 116 | 117 | self.auth = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_LOGIN_QUERY_PATH).Auth(isopen=False) 118 | 119 | try: 120 | lReq = self.loginRequest('1', { 121 | 'keepLoggedIn': keepLoggedIn, 122 | 'verifier': getAccessKey['result']['verifier'], 123 | 'e2eeVersion': 0 124 | }) 125 | result = self.auth.loginZ(lReq) 126 | except: 127 | raise Exception("Login failed") 128 | 129 | if result.type == LoginResultType.SUCCESS: 130 | if result.certificate is not None: 131 | with open(_id + '.crt', 'w') as f: 132 | f.write(result.certificate) 133 | self.certificate = result.certificate 134 | if result.authToken is not None: 135 | self.tokenLogin(result.authToken, appName) 136 | else: 137 | return False 138 | else: 139 | raise Exception("Login failed") 140 | 141 | elif result.type == LoginResultType.REQUIRE_QRCODE: 142 | self.qrLogin(keepLoggedIn, systemName, appName) 143 | pass 144 | 145 | elif result.type == LoginResultType.SUCCESS: 146 | self.certificate = result.certificate 147 | self.tokenLogin(result.authToken, appName) 148 | 149 | def qrLogin(self, keepLoggedIn=True, systemName=None, appName=None, showQr=False): 150 | if systemName is None: 151 | systemName=self.server.SYSTEM_NAME 152 | if appName is None: 153 | appName=self.server.APP_NAME 154 | self.server.setHeaders('X-Line-Application', appName) 155 | 156 | self.tauth = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_AUTH_QUERY_PATH).Talk(isopen=False) 157 | qrCode = self.tauth.getAuthQrcode(keepLoggedIn, systemName) 158 | 159 | self.callback.QrUrl("line://au/q/" + qrCode.verifier, showQr) 160 | self.server.setHeaders('X-Line-Access', qrCode.verifier) 161 | 162 | getAccessKey = self.server.getJson(self.server.parseUrl(self.server.LINE_CERTIFICATE_PATH), allowHeader=True) 163 | 164 | self.auth = Session(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_LOGIN_QUERY_PATH).Auth(isopen=False) 165 | 166 | try: 167 | lReq = self.loginRequest('1', { 168 | 'keepLoggedIn': keepLoggedIn, 169 | 'systemName': systemName, 170 | 'identityProvider': IdentityProvider.LINE, 171 | 'verifier': getAccessKey['result']['verifier'], 172 | 'accessLocation': self.server.IP_ADDR, 173 | 'e2eeVersion': 0 174 | }) 175 | result = self.auth.loginZ(lReq) 176 | except: 177 | raise Exception("Login failed") 178 | 179 | if result.type == LoginResultType.SUCCESS: 180 | if result.authToken is not None: 181 | self.tokenLogin(result.authToken, appName) 182 | else: 183 | return False 184 | else: 185 | raise Exception("Login failed") 186 | 187 | def tokenLogin(self, authToken=None, appName=None): 188 | if authToken is None: 189 | raise Exception('Please provide Auth Token') 190 | if appName is None: 191 | appName=self.server.APP_NAME 192 | self.server.setHeadersWithDict({ 193 | 'X-Line-Application': appName, 194 | 'X-Line-Access': authToken 195 | }) 196 | self.authToken = authToken 197 | self.loadSession() 198 | 199 | def defaultCallback(self, str): 200 | print(str) 201 | 202 | def logout(self): 203 | self.auth.logoutZ() -------------------------------------------------------------------------------- /thrift/transport/TTransport.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from struct import pack, unpack 5 | from thrift.unverting import TException 6 | from ..compat import BufferIO 7 | class TTransportException(TException): 8 | UNKNOWN = 0 9 | NOT_OPEN = 1 10 | ALREADY_OPEN = 2 11 | TIMED_OUT = 3 12 | END_OF_FILE = 4 13 | NEGATIVE_SIZE = 5 14 | SIZE_LIMIT = 6 15 | def __init__(self, type=UNKNOWN, message=None): 16 | TException.__init__(self, message) 17 | self.type = type 18 | class TTransportBase(object): 19 | def isOpen(self): 20 | pass 21 | def open(self): 22 | pass 23 | def close(self): 24 | pass 25 | def read(self, sz): 26 | pass 27 | def readAll(self, sz): 28 | buff = b'' 29 | have = 0 30 | while (have < sz): 31 | chunk = self.read(sz - have) 32 | chunkLen = len(chunk) 33 | have += chunkLen 34 | buff += chunk 35 | if chunkLen == 0: 36 | raise EOFError() 37 | return buff 38 | def write(self, buf): 39 | pass 40 | def flush(self): 41 | pass 42 | class CReadableTransport(object): 43 | @property 44 | def cstringio_buf(self): 45 | pass 46 | def cstringio_refill(self, partialread, reqlen): 47 | pass 48 | class TServerTransportBase(object): 49 | def listen(self): 50 | pass 51 | def accept(self): 52 | pass 53 | def close(self): 54 | pass 55 | class TTransportFactoryBase(object): 56 | def getTransport(self, trans): 57 | return trans 58 | class TBufferedTransportFactory(object): 59 | def getTransport(self, trans): 60 | buffered = TBufferedTransport(trans) 61 | return buffered 62 | class TBufferedTransport(TTransportBase, CReadableTransport): 63 | DEFAULT_BUFFER = 4096 64 | def __init__(self, trans, rbuf_size=DEFAULT_BUFFER): 65 | self.__trans = trans 66 | self.__wbuf = BufferIO() 67 | self.__rbuf = BufferIO(b'') 68 | self.__rbuf_size = rbuf_size 69 | def isOpen(self): 70 | return self.__trans.isOpen() 71 | def open(self): 72 | return self.__trans.open() 73 | def close(self): 74 | return self.__trans.close() 75 | def read(self, sz): 76 | ret = self.__rbuf.read(sz) 77 | if len(ret) != 0: 78 | return ret 79 | self.__rbuf = BufferIO(self.__trans.read(max(sz, self.__rbuf_size))) 80 | return self.__rbuf.read(sz) 81 | 82 | def write(self, buf): 83 | try: 84 | self.__wbuf.write(buf) 85 | except Exception as e: 86 | self.__wbuf = BufferIO() 87 | raise e 88 | def flush(self): 89 | out = self.__wbuf.getvalue() 90 | self.__wbuf = BufferIO() 91 | self.__trans.write(out) 92 | self.__trans.flush() 93 | @property 94 | def cstringio_buf(self): 95 | return self.__rbuf 96 | def cstringio_refill(self, partialread, reqlen): 97 | retstring = partialread 98 | if reqlen < self.__rbuf_size: 99 | retstring += self.__trans.read(self.__rbuf_size) 100 | if len(retstring) < reqlen: 101 | retstring += self.__trans.readAll(reqlen - len(retstring)) 102 | self.__rbuf = BufferIO(retstring) 103 | return self.__rbuf 104 | class TMemoryBuffer(TTransportBase, CReadableTransport): 105 | def __init__(self, value=None, offset=0): 106 | if value is not None: 107 | self._buffer = BufferIO(value) 108 | else: 109 | self._buffer = BufferIO() 110 | if offset: 111 | self._buffer.seek(offset) 112 | def isOpen(self): 113 | return not self._buffer.closed 114 | def open(self): 115 | pass 116 | def close(self): 117 | self._buffer.close() 118 | def read(self, sz): 119 | return self._buffer.read(sz) 120 | def write(self, buf): 121 | self._buffer.write(buf) 122 | def flush(self): 123 | pass 124 | def getvalue(self): 125 | return self._buffer.getvalue() 126 | @property 127 | def cstringio_buf(self): 128 | return self._buffer 129 | def cstringio_refill(self, partialread, reqlen): 130 | raise EOFError() 131 | class TFramedTransportFactory(object): 132 | def getTransport(self, trans): 133 | framed = TFramedTransport(trans) 134 | return framed 135 | class TFramedTransport(TTransportBase, CReadableTransport): 136 | def __init__(self, trans,): 137 | self.__trans = trans 138 | self.__rbuf = BufferIO(b'') 139 | self.__wbuf = BufferIO() 140 | def isOpen(self): 141 | return self.__trans.isOpen() 142 | def open(self): 143 | return self.__trans.open() 144 | def close(self): 145 | return self.__trans.close() 146 | def read(self, sz): 147 | ret = self.__rbuf.read(sz) 148 | if len(ret) != 0: 149 | return ret 150 | self.readFrame() 151 | return self.__rbuf.read(sz) 152 | def readFrame(self): 153 | buff = self.__trans.readAll(4) 154 | sz, = unpack('!i', buff) 155 | self.__rbuf = BufferIO(self.__trans.readAll(sz)) 156 | def write(self, buf): 157 | self.__wbuf.write(buf) 158 | def flush(self): 159 | wout = self.__wbuf.getvalue() 160 | wsz = len(wout) 161 | self.__wbuf = BufferIO() 162 | buf = pack("!i", wsz) + wout 163 | self.__trans.write(buf) 164 | self.__trans.flush() 165 | @property 166 | def cstringio_buf(self): 167 | return self.__rbuf 168 | def cstringio_refill(self, prefix, reqlen): 169 | while len(prefix) < reqlen: 170 | self.readFrame() 171 | prefix += self.__rbuf.getvalue() 172 | self.__rbuf = BufferIO(prefix) 173 | return self.__rbuf 174 | class TFileObjectTransport(TTransportBase): 175 | def __init__(self, fileobj): 176 | self.fileobj = fileobj 177 | def isOpen(self): 178 | return True 179 | def close(self): 180 | self.fileobj.close() 181 | def read(self, sz): 182 | return self.fileobj.read(sz) 183 | def write(self, buf): 184 | self.fileobj.write(buf) 185 | def flush(self): 186 | self.fileobj.flush() 187 | class TSaslClientTransport(TTransportBase, CReadableTransport): 188 | START = 1 189 | OK = 2 190 | BAD = 3 191 | ERROR = 4 192 | COMPLETE = 5 193 | def __init__(self, transport, host, service, mechanism='GSSAPI', 194 | **sasl_kwargs): 195 | from puresasl.client import SASLClient 196 | self.transport = transport 197 | self.sasl = SASLClient(host, service, mechanism, **sasl_kwargs) 198 | self.__wbuf = BufferIO() 199 | self.__rbuf = BufferIO(b'') 200 | def open(self): 201 | if not self.transport.isOpen(): 202 | self.transport.open() 203 | self.send_sasl_msg(self.START, self.sasl.mechanism) 204 | self.send_sasl_msg(self.OK, self.sasl.process()) 205 | while True: 206 | status, challenge = self.recv_sasl_msg() 207 | if status == self.OK: 208 | self.send_sasl_msg(self.OK, self.sasl.process(challenge)) 209 | elif status == self.COMPLETE: 210 | if not self.sasl.complete: 211 | raise TTransportException( 212 | TTransportException.NOT_OPEN, 213 | "importing server.. this " 214 | "sudah dilakukan") 215 | else: 216 | break 217 | else: 218 | raise TTransportException( 219 | TTransportException.NOT_OPEN, 220 | "statistik: %d (%s)" 221 | % (status, challenge)) 222 | def send_sasl_msg(self, status, body): 223 | header = pack(">BI", status, len(body)) 224 | self.transport.write(header + body) 225 | self.transport.flush() 226 | def recv_sasl_msg(self): 227 | header = self.transport.readAll(5) 228 | status, length = unpack(">BI", header) 229 | if length > 0: 230 | payload = self.transport.readAll(length) 231 | else: 232 | payload = "" 233 | return status, payload 234 | def write(self, data): 235 | self.__wbuf.write(data) 236 | def flush(self): 237 | data = self.__wbuf.getvalue() 238 | encoded = self.sasl.wrap(data) 239 | self.transport.write(''.join((pack("!i", len(encoded)), encoded))) 240 | self.transport.flush() 241 | self.__wbuf = BufferIO() 242 | def read(self, sz): 243 | ret = self.__rbuf.read(sz) 244 | if len(ret) != 0: 245 | return ret 246 | self._read_frame() 247 | return self.__rbuf.read(sz) 248 | def _read_frame(self): 249 | header = self.transport.readAll(4) 250 | length, = unpack('!i', header) 251 | encoded = self.transport.readAll(length) 252 | self.__rbuf = BufferIO(self.sasl.unwrap(encoded)) 253 | def close(self): 254 | self.sasl.dispose() 255 | self.transport.close() 256 | @property 257 | def cstringio_buf(self): 258 | return self.__rbuf 259 | def cstringio_refill(self, prefix, reqlen): 260 | while len(prefix) < reqlen: 261 | self._read_frame() 262 | prefix += self.__rbuf.getvalue() 263 | self.__rbuf = BufferIO(prefix) 264 | return self.__rbuf 265 | # CREATED BY ACIL MODIF. -------------------------------------------------------------------------------- /thrift/server/TNonblockingServer.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | import logging 5 | import select 6 | import socket 7 | import struct 8 | import threading 9 | from collections import deque 10 | from six.moves import queue 11 | from thrift.transport import TTransport 12 | from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory 13 | __all__ = ['TNonblockingServer'] 14 | logger = logging.getLogger(__name__) 15 | class Worker(threading.Thread): 16 | def __init__(self, queue): 17 | threading.Thread.__init__(self) 18 | self.queue = queue 19 | def run(self): 20 | while True: 21 | try: 22 | processor, iprot, oprot, otrans, callback = self.queue.get() 23 | if processor is None: 24 | break 25 | processor.process(iprot, oprot) 26 | callback(True, otrans.getvalue()) 27 | except Exception: 28 | logger.exception("proses...", exc_info=True) 29 | callback(False, b'') 30 | WAIT_LEN = 0 31 | WAIT_MESSAGE = 1 32 | WAIT_PROCESS = 2 33 | SEND_ANSWER = 3 34 | CLOSED = 4 35 | def locked(func): 36 | def nested(self, *args, **kwargs): 37 | self.lock.acquire() 38 | try: 39 | return func(self, *args, **kwargs) 40 | finally: 41 | self.lock.release() 42 | return nested 43 | def socket_exception(func): 44 | def read(self, *args, **kwargs): 45 | try: 46 | return func(self, *args, **kwargs) 47 | except socket.error: 48 | logger.debug('ignoring socket exception', exc_info=True) 49 | self.close() 50 | return read 51 | class Message(object): 52 | def __init__(self, offset, len_, header): 53 | self.offset = offset 54 | self.len = len_ 55 | self.buffer = None 56 | self.is_header = header 57 | @property 58 | def end(self): 59 | return self.offset + self.len 60 | class Connection(object): 61 | def __init__(self, new_socket, wake_up): 62 | self.socket = new_socket 63 | self.socket.setblocking(False) 64 | self.status = WAIT_LEN 65 | self.len = 0 66 | self.received = deque() 67 | self._reading = Message(0, 4, True) 68 | self._rbuf = b'' 69 | self._wbuf = b'' 70 | self.lock = threading.Lock() 71 | self.wake_up = wake_up 72 | self.remaining = False 73 | @socket_exception 74 | def read(self): 75 | assert self.status in (WAIT_LEN, WAIT_MESSAGE) 76 | assert not self.received 77 | buf_size = 8192 78 | first = True 79 | done = False 80 | while not done: 81 | read = self.socket.recv(buf_size) 82 | rlen = len(read) 83 | done = rlen < buf_size 84 | self._rbuf += read 85 | if first and rlen == 0: 86 | if self.status != WAIT_LEN or self._rbuf: 87 | logger.error('cloud tidak terbaca') 88 | else: 89 | logger.debug('client sudah tidak konek') 90 | self.close() 91 | while len(self._rbuf) >= self._reading.end: 92 | if self._reading.is_header: 93 | mlen, = struct.unpack('!i', self._rbuf[:4]) 94 | self._reading = Message(self._reading.end, mlen, False) 95 | self.status = WAIT_MESSAGE 96 | else: 97 | self._reading.buffer = self._rbuf 98 | self.received.append(self._reading) 99 | self._rbuf = self._rbuf[self._reading.end:] 100 | self._reading = Message(0, 4, True) 101 | first = False 102 | if self.received: 103 | self.status = WAIT_PROCESS 104 | break 105 | self.remaining = not done 106 | @socket_exception 107 | def write(self): 108 | assert self.status == SEND_ANSWER 109 | sent = self.socket.send(self._wbuf) 110 | if sent == len(self._wbuf): 111 | self.status = WAIT_LEN 112 | self._wbuf = b'' 113 | self.len = 0 114 | else: 115 | self._wbuf = self.message[sent:] 116 | @locked 117 | def ready(self, all_ok, message): 118 | assert self.status == WAIT_PROCESS 119 | if not all_ok: 120 | self.close() 121 | self.wake_up() 122 | return 123 | self.len = 0 124 | if len(message) == 0: 125 | self._wbuf = b'' 126 | self.status = WAIT_LEN 127 | else: 128 | self._wbuf = struct.pack('!i', len(message)) + message 129 | self.status = SEND_ANSWER 130 | self.wake_up() 131 | @locked 132 | def is_writeable(self): 133 | """Return True if connection should be added to write list of select""" 134 | return self.status == SEND_ANSWER 135 | @locked 136 | def is_readable(self): 137 | """Return True if connection should be added to read list of select""" 138 | return self.status in (WAIT_LEN, WAIT_MESSAGE) 139 | @locked 140 | def is_closed(self): 141 | """Returns True if connection is closed.""" 142 | return self.status == CLOSED 143 | 144 | def fileno(self): 145 | """Returns the file descriptor of the associated socket.""" 146 | return self.socket.fileno() 147 | def close(self): 148 | """Closes connection""" 149 | self.status = CLOSED 150 | self.socket.close() 151 | class TNonblockingServer(object): 152 | """Non-blocking server.""" 153 | def __init__(self, 154 | processor, 155 | lsocket, 156 | inputProtocolFactory=None, 157 | outputProtocolFactory=None, 158 | threads=10): 159 | self.processor = processor 160 | self.socket = lsocket 161 | self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory() 162 | self.out_protocol = outputProtocolFactory or self.in_protocol 163 | self.threads = int(threads) 164 | self.clients = {} 165 | self.tasks = queue.Queue() 166 | self._read, self._write = socket.socketpair() 167 | self.prepared = False 168 | self._stop = False 169 | def setNumThreads(self, num): 170 | assert not self.prepared, "Can't change number of threads after start" 171 | self.threads = num 172 | def prepare(self): 173 | if self.prepared: 174 | return 175 | self.socket.listen() 176 | for _ in range(self.threads): 177 | thread = Worker(self.tasks) 178 | thread.setDaemon(True) 179 | thread.start() 180 | self.prepared = True 181 | def wake_up(self): 182 | self._write.send(b'1') 183 | def stop(self): 184 | self._stop = True 185 | self.wake_up() 186 | def _select(self): 187 | readable = [self.socket.handle.fileno(), self._read.fileno()] 188 | writable = [] 189 | remaining = [] 190 | for i, connection in list(self.clients.items()): 191 | if connection.is_readable(): 192 | readable.append(connection.fileno()) 193 | if connection.remaining or connection.received: 194 | remaining.append(connection.fileno()) 195 | if connection.is_writeable(): 196 | writable.append(connection.fileno()) 197 | if connection.is_closed(): 198 | del self.clients[i] 199 | if remaining: 200 | return remaining, [], [], False 201 | else: 202 | return select.select(readable, writable, readable) + (True,) 203 | 204 | def handle(self): 205 | assert self.prepared, "You have to call prepare before handle" 206 | rset, wset, xset, selected = self._select() 207 | for readable in rset: 208 | if readable == self._read.fileno(): 209 | self._read.recv(1024) 210 | elif readable == self.socket.handle.fileno(): 211 | try: 212 | client = self.socket.accept() 213 | if client: 214 | self.clients[client.handle.fileno()] = Connection(client.handle, 215 | self.wake_up) 216 | except socket.error: 217 | logger.debug('eror disini ', exc_info=True) 218 | else: 219 | connection = self.clients[readable] 220 | if selected: 221 | connection.read() 222 | if connection.received: 223 | connection.status = WAIT_PROCESS 224 | msg = connection.received.popleft() 225 | itransport = TTransport.TMemoryBuffer(msg.buffer, msg.offset) 226 | otransport = TTransport.TMemoryBuffer() 227 | iprot = self.in_protocol.getProtocol(itransport) 228 | oprot = self.out_protocol.getProtocol(otransport) 229 | self.tasks.put([self.processor, iprot, oprot, 230 | otransport, connection.ready]) 231 | for writeable in wset: 232 | self.clients[writeable].write() 233 | for oob in xset: 234 | self.clients[oob].close() 235 | del self.clients[oob] 236 | def close(self): 237 | """NUTUP SERVER""" 238 | for _ in range(self.threads): 239 | self.tasks.put([None, None, None, None, None]) 240 | self.socket.close() 241 | self.prepared = False 242 | def serve(self): 243 | self._stop = False 244 | self.prepare() 245 | while not self._stop: 246 | self.handle() 247 | # MOD BY ACIL -------------------------------------------------------------------------------- /thrift/transport/TTwisted.py: -------------------------------------------------------------------------------- 1 | # MODIF BY ACIL 2 | # SUPORT CREATOR BY PRANKBOTS 3 | from io import BytesIO 4 | import struct 5 | from zope.interface import implementer, Interface, Attribute 6 | from twisted.internet.protocol import ServerFactory, ClientFactory, \ 7 | connectionDone 8 | from twisted.internet import defer 9 | from twisted.internet.threads import deferToThread 10 | from twisted.protocols import basic 11 | from twisted.web import server, resource, http 12 | from thrift.transport import TTransport 13 | class TMessageSenderTransport(TTransport.TTransportBase): 14 | def __init__(self): 15 | self.__wbuf = BytesIO() 16 | def write(self, buf): 17 | self.__wbuf.write(buf) 18 | def flush(self): 19 | msg = self.__wbuf.getvalue() 20 | self.__wbuf = BytesIO() 21 | return self.sendMessage(msg) 22 | def sendMessage(self, message): 23 | raise NotImplementedError 24 | class TCallbackTransport(TMessageSenderTransport): 25 | def __init__(self, func): 26 | TMessageSenderTransport.__init__(self) 27 | self.func = func 28 | def sendMessage(self, message): 29 | return self.func(message) 30 | class ThriftClientProtocol(basic.Int32StringReceiver): 31 | MAX_LENGTH = 2 ** 31 - 1 32 | def __init__(self, client_class, iprot_factory, oprot_factory=None): 33 | self._client_class = client_class 34 | self._iprot_factory = iprot_factory 35 | if oprot_factory is None: 36 | self._oprot_factory = iprot_factory 37 | else: 38 | self._oprot_factory = oprot_factory 39 | self.recv_map = {} 40 | self.started = defer.Deferred() 41 | def dispatch(self, msg): 42 | self.sendString(msg) 43 | def connectionMade(self): 44 | tmo = TCallbackTransport(self.dispatch) 45 | self.client = self._client_class(tmo, self._oprot_factory) 46 | self.started.callback(self.client) 47 | def connectionLost(self, reason=connectionDone): 48 | if self.client: 49 | tex = TTransport.TTransportException( 50 | type=TTransport.TTransportException.END_OF_FILE, 51 | message='Connection closed (%s)' % reason) 52 | while self.client._reqs: 53 | _, v = self.client._reqs.popitem() 54 | v.errback(tex) 55 | del self.client._reqs 56 | self.client = None 57 | def stringReceived(self, frame): 58 | tr = TTransport.TMemoryBuffer(frame) 59 | iprot = self._iprot_factory.getProtocol(tr) 60 | (fname, mtype, rseqid) = iprot.readMessageBegin() 61 | try: 62 | method = self.recv_map[fname] 63 | except KeyError: 64 | method = getattr(self.client, 'recv_' + fname) 65 | self.recv_map[fname] = method 66 | method(iprot, mtype, rseqid) 67 | class ThriftSASLClientProtocol(ThriftClientProtocol): 68 | START = 1 69 | OK = 2 70 | BAD = 3 71 | ERROR = 4 72 | COMPLETE = 5 73 | MAX_LENGTH = 2 ** 31 - 1 74 | def __init__(self, client_class, iprot_factory, oprot_factory=None, 75 | host=None, service=None, mechanism='GSSAPI', **sasl_kwargs): 76 | from puresasl.client import SASLClient 77 | self.SASLCLient = SASLClient 78 | ThriftClientProtocol.__init__(self, client_class, iprot_factory, oprot_factory) 79 | self._sasl_negotiation_deferred = None 80 | self._sasl_negotiation_status = None 81 | self.client = None 82 | if host is not None: 83 | self.createSASLClient(host, service, mechanism, **sasl_kwargs) 84 | def createSASLClient(self, host, service, mechanism, **kwargs): 85 | self.sasl = self.SASLClient(host, service, mechanism, **kwargs) 86 | def dispatch(self, msg): 87 | encoded = self.sasl.wrap(msg) 88 | len_and_encoded = ''.join((struct.pack('!i', len(encoded)), encoded)) 89 | ThriftClientProtocol.dispatch(self, len_and_encoded) 90 | @defer.inlineCallbacks 91 | def connectionMade(self): 92 | self._sendSASLMessage(self.START, self.sasl.mechanism) 93 | initial_message = yield deferToThread(self.sasl.process) 94 | self._sendSASLMessage(self.OK, initial_message) 95 | while True: 96 | status, challenge = yield self._receiveSASLMessage() 97 | if status == self.OK: 98 | response = yield deferToThread(self.sasl.process, challenge) 99 | self._sendSASLMessage(self.OK, response) 100 | elif status == self.COMPLETE: 101 | if not self.sasl.complete: 102 | msg = "PROSES " \ 103 | "FINISH" 104 | raise TTransport.TTransportException(msg, message=msg) 105 | else: 106 | break 107 | else: 108 | msg = "STATUS: %d (%s)" % (status, challenge) 109 | raise TTransport.TTransportException(msg, message=msg) 110 | self._sasl_negotiation_deferred = None 111 | ThriftClientProtocol.connectionMade(self) 112 | def _sendSASLMessage(self, status, body): 113 | if body is None: 114 | body = "" 115 | header = struct.pack(">BI", status, len(body)) 116 | self.transport.write(header + body) 117 | def _receiveSASLMessage(self): 118 | self._sasl_negotiation_deferred = defer.Deferred() 119 | self._sasl_negotiation_status = None 120 | return self._sasl_negotiation_deferred 121 | def connectionLost(self, reason=connectionDone): 122 | if self.client: 123 | ThriftClientProtocol.connectionLost(self, reason) 124 | def dataReceived(self, data): 125 | if self._sasl_negotiation_deferred: 126 | self._sasl_negotiation_status, = struct.unpack("B", data[0]) 127 | ThriftClientProtocol.dataReceived(self, data[1:]) 128 | else: 129 | ThriftClientProtocol.dataReceived(self, data) 130 | def stringReceived(self, frame): 131 | if self._sasl_negotiation_deferred: 132 | response = (self._sasl_negotiation_status, frame) 133 | self._sasl_negotiation_deferred.callback(response) 134 | else: 135 | decoded_frame = self.sasl.unwrap(frame[4:]) 136 | ThriftClientProtocol.stringReceived(self, decoded_frame) 137 | class ThriftServerProtocol(basic.Int32StringReceiver): 138 | MAX_LENGTH = 2 ** 31 - 1 139 | def dispatch(self, msg): 140 | self.sendString(msg) 141 | def processError(self, error): 142 | self.transport.loseConnection() 143 | def processOk(self, _, tmo): 144 | msg = tmo.getvalue() 145 | if len(msg) > 0: 146 | self.dispatch(msg) 147 | def stringReceived(self, frame): 148 | tmi = TTransport.TMemoryBuffer(frame) 149 | tmo = TTransport.TMemoryBuffer() 150 | iprot = self.factory.iprot_factory.getProtocol(tmi) 151 | oprot = self.factory.oprot_factory.getProtocol(tmo) 152 | d = self.factory.processor.process(iprot, oprot) 153 | d.addCallbacks(self.processOk, self.processError, 154 | callbackArgs=(tmo,)) 155 | class IThriftServerFactory(Interface): 156 | processor = Attribute("unverting processor") 157 | iprot_factory = Attribute("Input protocol factory") 158 | oprot_factory = Attribute("Output protocol factory") 159 | class IThriftClientFactory(Interface): 160 | client_class = Attribute("unverting client class") 161 | iprot_factory = Attribute("Input protocol factory") 162 | oprot_factory = Attribute("Output protocol factory") 163 | @implementer(IThriftServerFactory) 164 | class ThriftServerFactory(ServerFactory): 165 | protocol = ThriftServerProtocol 166 | def __init__(self, processor, iprot_factory, oprot_factory=None): 167 | self.processor = processor 168 | self.iprot_factory = iprot_factory 169 | if oprot_factory is None: 170 | self.oprot_factory = iprot_factory 171 | else: 172 | self.oprot_factory = oprot_factory 173 | @implementer(IThriftClientFactory) 174 | class ThriftClientFactory(ClientFactory): 175 | protocol = ThriftClientProtocol 176 | def __init__(self, client_class, iprot_factory, oprot_factory=None): 177 | self.client_class = client_class 178 | self.iprot_factory = iprot_factory 179 | if oprot_factory is None: 180 | self.oprot_factory = iprot_factory 181 | else: 182 | self.oprot_factory = oprot_factory 183 | def buildProtocol(self, addr): 184 | p = self.protocol(self.client_class, self.iprot_factory, 185 | self.oprot_factory) 186 | p.factory = self 187 | return p 188 | class ThriftResource(resource.Resource): 189 | allowedMethods = ('POST',) 190 | def __init__(self, processor, inputProtocolFactory, 191 | outputProtocolFactory=None): 192 | resource.Resource.__init__(self) 193 | self.inputProtocolFactory = inputProtocolFactory 194 | if outputProtocolFactory is None: 195 | self.outputProtocolFactory = inputProtocolFactory 196 | else: 197 | self.outputProtocolFactory = outputProtocolFactory 198 | self.processor = processor 199 | def getChild(self, path, request): 200 | return self 201 | def _cbProcess(self, _, request, tmo): 202 | msg = tmo.getvalue() 203 | request.setResponseCode(http.OK) 204 | request.setHeader("content-type", "application/x-thrift") 205 | request.write(msg) 206 | request.finish() 207 | def render_POST(self, request): 208 | request.content.seek(0, 0) 209 | data = request.content.read() 210 | tmi = TTransport.TMemoryBuffer(data) 211 | tmo = TTransport.TMemoryBuffer() 212 | iprot = self.inputProtocolFactory.getProtocol(tmi) 213 | oprot = self.outputProtocolFactory.getProtocol(tmo) 214 | d = self.processor.process(iprot, oprot) 215 | d.addCallback(self._cbProcess, request, tmo) 216 | return server.NOT_DONE_YET 217 | 218 | # CEK KONEKSI INI SBENRNYA DISINU -------------------------------------------------------------------------------- /KIA/square.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from akad.ttypes import * 3 | 4 | def loggedIn(func): 5 | def checkLogin(*args, **kwargs): 6 | if args[0].isLogin: 7 | return func(*args, **kwargs) 8 | else: 9 | args[0].callback.other("You want to call the function, you must login to LINE") 10 | return checkLogin 11 | 12 | class LineSquare(object): 13 | isLogin = False 14 | 15 | def __init__(self): 16 | self.isLogin = True 17 | 18 | @loggedIn 19 | def searchSquareMembers(self, squareMid, continuationToken=None, limit=50): 20 | rq = SearchSquareMembersRequest() 21 | rq.squareMid = squareMid 22 | rq.searchOption = SquareMemberSearchOption() 23 | rq.continuationToken = continuationToken 24 | rq.limit = limit 25 | return self.square.searchSquareMembers(rq) 26 | 27 | @loggedIn 28 | def findSquareByInvitationTicket(self, invitationTicket): 29 | rq = FindSquareByInvitationTicketRequest() 30 | rq.invitationTicket = invitationTicket 31 | return self.square.findSquareByInvitationTicket(rq) 32 | 33 | @loggedIn 34 | def approveSquareMembers(self, squareMid, requestedMemberMids=[]): 35 | rq = ApproveSquareMembersRequest() 36 | rq.squareMid = squareMid 37 | rq.requestedMemberMids = requestedMemberMids 38 | return self.square.approveSquareMembers(rq) 39 | 40 | @loggedIn 41 | def destroySquareMessage(self, squareChatMid, messageId): 42 | rq = DestroyMessageRequest() 43 | rq.squareChatMid = squareChatMid 44 | rq.messageId = messageId 45 | return self.square.destroyMessage(rq) 46 | 47 | @loggedIn 48 | def deleteSquare(self, mid): 49 | rq = DeleteSquareRequest() 50 | rq.mid = mid 51 | rq.revision = self.client.revision 52 | return self.square.deleteSquare(rq) 53 | 54 | @loggedIn 55 | def deleteSquareChat(self, squareChatMid): 56 | rq = DeleteSquareChatRequest() 57 | rq.squareChatMid = squareChatMid 58 | rq.revision = self.client.revision 59 | return self.square.deleteSquareChat(request) 60 | 61 | @loggedIn 62 | def createSquare(self, name, categoryID, welcomeMessage='', profileImageObsHash='', desc='', searchable=True, type=1, ableToUseInvitationTicket=True): 63 | rq = CreateSquareRequest() 64 | rq.square = Square() 65 | rq.square.name = name 66 | rq.square.categoryID = categoryID 67 | rq.square.welcomeMessage = welcomeMessage 68 | rq.square.profileImageObsHash = profileImageObsHash 69 | rq.square.desc = desc 70 | rq.square.searchable = searchable 71 | rq.square.type = type 72 | rq.square.ableToUseInvitationTicket = ableToUseInvitationTicket 73 | rq.creator = SquareMember() 74 | return self.square.createSquare(rq) 75 | 76 | @loggedIn 77 | def createSquareChat(self, squareMid, name, squareMemberMids): 78 | rq = CreateSquareChatRequest() 79 | rq.reqSeq = self.client.revision 80 | rq.squareChat = SquareChat() 81 | rq.squareChat.squareMid = squareMid 82 | rq.squareChat.name = name 83 | rq.squareMemberMids = squareMemberMids 84 | return self.square.createSquareChat(request) 85 | 86 | @loggedIn 87 | def fetchSquareChatEvents(self, subscriptionId, squareChatMid, syncToken=None, limit=50, direction=2): 88 | rq = FetchSquareChatEventsRequest() 89 | rq.subscriptionId = subscriptionId 90 | rq.squareChatMid = squareChatMid 91 | rq.syncToken = syncToken 92 | rq.limit = limit 93 | rq.direction = direction 94 | return self.square.fetchSquareChatEvents(rq) 95 | 96 | @loggedIn 97 | def fetchMyEvents(self, subscriptionId, syncToken=None, continuationToken=None, limit=50): 98 | rq = FetchMyEventsRequest() 99 | rq.subscriptionId = subscriptionId 100 | rq.syncToken = syncToken 101 | rq.continuationToken = continuationToken 102 | rq.limit = limit 103 | return self.square.fetchMyEvents(rq) 104 | 105 | @loggedIn 106 | def markAsRead(self, squareChatMid, messageId): 107 | rq = MarkAsReadRequest() 108 | rq.squareChatMid = squareChatMid 109 | rq.messageId = messageId 110 | return self.square.markAsRead(rq) 111 | 112 | @loggedIn 113 | def getSquareAuthority(self, squareMid): 114 | rq = GetSquareAuthorityRequest() 115 | rq.squareMid = squareMid 116 | return self.square.getSquareAuthority(rq) 117 | 118 | @loggedIn 119 | def leaveSquare(self, squareMid): 120 | rq = LeaveSquareRequest() 121 | rq.squareMid = squareMid 122 | return self.square.leaveSquare(rq) 123 | 124 | @loggedIn 125 | def leaveSquareChat(self, squareChatMid, squareChatMemberRevision, sayGoodbye=False): 126 | rq = LeaveSquareChatRequest() 127 | rq.squareChatMid = squareChatMid 128 | rq.sayGoodbye = sayGoodbye 129 | rq.squareChatMemberRevision = squareChatMemberRevision 130 | return self.square.leaveSquareChat(rq) 131 | 132 | @loggedIn 133 | def joinSquareChat(self, squareChatMid): 134 | rq = JoinSquareChatRequest() 135 | rq.squareChatMid = squareChatMid 136 | return self.square.joinSquareChat(rq) 137 | 138 | @loggedIn 139 | def joinSquare(self, squareMid, displayName, profileImageObsHash): 140 | rq = JoinSquareRequest() 141 | rq.squareMid = squareMid 142 | rq.member = SquareMember() 143 | rq.member.squareMid = squareMid 144 | rq.member.displayName = displayName 145 | rq.member.profileImageObsHash = profileImageObsHash 146 | return self.square.joinSquareChat(rq) 147 | 148 | @loggedIn 149 | def inviteToSquare(self, squareMid, squareChatMid, invitees=[]): 150 | rq = InviteToSquareRequest() 151 | rq.squareMid = squareMid 152 | rq.invitees = invitees 153 | rq.squareChatMid = squareChatMid 154 | return self.square.inviteToSquare(rq) 155 | 156 | @loggedIn 157 | def inviteToSquareChat(self, squareChatMid, inviteeMids=[]): 158 | rq = InviteToSquareChatRequest() 159 | rq.inviteeMids = inviteeMids 160 | rq.squareChatMid = squareChatMid 161 | return self.square.inviteToSquareChat(rq) 162 | 163 | @loggedIn 164 | def getSquareMember(self, squareMemberMid): 165 | rq = GetSquareMemberRequest() 166 | rq.squareMemberMid = squareMemberMid 167 | return self.square.getSquareMember(rq) 168 | 169 | @loggedIn 170 | def getSquareMembers(self, mids=[]): 171 | rq = GetSquareMembersRequest() 172 | rq.mids = mids 173 | return self.square.getSquareMembers(rq) 174 | 175 | @loggedIn 176 | def getSquareMemberRelation(self, squareMid, targetSquareMemberMid): 177 | rq = GetSquareMemberRelationRequest() 178 | rq.squareMid = squareMid 179 | rq.targetSquareMemberMid = targetSquareMemberMid 180 | return self.square.getSquareMemberRelation(rq) 181 | 182 | @loggedIn 183 | def getSquareMemberRelations(self, state=1, continuationToken=None, limit=50): 184 | rq = GetSquareMemberRelationsRequest() 185 | rq.state = state # 1 NONE, 2 BLOCKED 186 | rq.continuationToken = continuationToken 187 | rq.limit = limit 188 | return self.square.getSquareMemberRelations(rq) 189 | 190 | @loggedIn 191 | def getSquareChatMembers(self, squareChatMid, continuationToken=None, limit=50): 192 | rq = GetSquareChatMembersRequest() 193 | rq.squareChatMid = squareChatMid 194 | rq.continuationToken = continuationToken 195 | rq.limit = limit 196 | return self.square.getSquareChatMembers(rq) 197 | 198 | @loggedIn 199 | def getSquareChatStatus(self, squareChatMid): 200 | rq = GetSquareChatStatusRequest() 201 | rq.squareChatMid = squareChatMid 202 | return self.square.getSquareChatStatus(rq) 203 | 204 | @loggedIn 205 | def getSquareChat(self, squareChatMid): 206 | rq = GetSquareChatStatusRequest() 207 | rq.squareChatMid = squareChatMid 208 | return self.square.getSquareChat(rq) 209 | 210 | @loggedIn 211 | def getSquare(self, mid): 212 | return self.square.getSquare(mid) 213 | 214 | @loggedIn 215 | def sendSquareMessage(self, squareChatMid, text, contentMetadata={}, contentType=0): 216 | rq = SendMessageRequest() 217 | rq.squareChatMid = squareChatMid 218 | rq.squareMessage = SquareMessage() 219 | msg = Message() 220 | msg.to = squareChatMid 221 | msg.text = text 222 | msg.contentType, msg.contentMetadata = contentType, contentMetadata 223 | rq.squareMessage.message = msg 224 | rq.squareMessage.fromType = 4 225 | if to not in self.client._messageReq: 226 | self.client._messageReq[to] = -1 227 | self.client._messageReq[to] += 1 228 | rq.squareMessage.squareMessageRevision = self.client._messageReq[to] 229 | return self.square.sendMessage(rq) 230 | 231 | @loggedIn 232 | def getJoinedSquares(self, continuationToken=None, limit=50): 233 | rq = GetJoinedSquaresRequest() 234 | rq.continuationToken = continuationToken 235 | rq.limit = limit 236 | return self.square.getJoinedSquares(rq) 237 | 238 | @loggedIn 239 | def getJoinableSquareChats(self, squareMid, continuationToken=None, limit=50): 240 | rq = GetJoinableSquareChatsRequest() 241 | rq.squareMid = squareMid 242 | rq.continuationToken = continuationToken 243 | rq.limit = limit 244 | return self.square.getJoinableSquareChats(rq) 245 | 246 | @loggedIn 247 | def getInvitationTicketUrl(self, mid): 248 | rq = GetInvitationTicketUrlRequest() 249 | rq.mid = mid 250 | return self.square.getInvitationTicketUrl(rq) -------------------------------------------------------------------------------- /KIA/timeline.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from datetime import datetime 3 | import json, time, base64 4 | 5 | def loggedIn(func): 6 | def checkLogin(*args, **kwargs): 7 | if args[0].isLogin: 8 | return func(*args, **kwargs) 9 | else: 10 | args[0].callback.other("You want to call the function, you must login to LINE") 11 | return checkLogin 12 | 13 | class LineTimeline(object): 14 | 15 | def __init__(self): 16 | if self.isLogin == True and self.channelId == self.server.CHANNEL_ID['LINE_TIMELINE']: 17 | self.client.log('[%s] : LineTimeline attached' % self.client.profile.displayName) 18 | 19 | """Timeline""" 20 | 21 | @loggedIn 22 | def getFeed(self, postLimit=10, commentLimit=1, likeLimit=1, order='TIME'): 23 | params = {'postLimit': postLimit, 'commentLimit': commentLimit, 'likeLimit': likeLimit, 'order': order} 24 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v27/feed/list.json', params) 25 | r = self.server.getContent(url, headers=self.server.channelHeaders) 26 | return r.json() 27 | 28 | @loggedIn 29 | def getHomeProfile(self, mid=None, postLimit=10, commentLimit=1, likeLimit=1): 30 | if mid is None: 31 | mid = self.client.profile.mid 32 | params = {'homeId': mid, 'postLimit': postLimit, 'commentLimit': commentLimit, 'likeLimit': likeLimit, 'sourceType': 'LINE_PROFILE_COVER'} 33 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v27/post/list.json', params) 34 | r = self.server.getContent(url, headers=self.server.channelHeaders) 35 | return r.json() 36 | 37 | @loggedIn 38 | def getProfileDetail(self, mid=None): 39 | if mid is None: 40 | mid = self.client.profile.mid 41 | params = {'userMid': mid} 42 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v1/userpopup/getDetail.json', params) 43 | r = self.server.getContent(url, headers=self.server.channelHeaders) 44 | return r.json() 45 | 46 | @loggedIn 47 | def updateProfileCoverById(self, objId): 48 | params = {'coverImageId': objId} 49 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v39/home/updateCover.json', params) 50 | r = self.server.getContent(url, headers=self.server.timelineHeaders) 51 | return r.json() 52 | 53 | @loggedIn 54 | def getProfileCoverId(self, mid=None): 55 | if mid is None: 56 | mid = self.profile.mid 57 | home = self.getProfileDetail(mid) 58 | return home['result']['objectId'] 59 | 60 | @loggedIn 61 | def getProfileCoverURL(self, mid=None): 62 | if mid is None: 63 | mid = self.profile.mid 64 | home = self.getProfileDetail(mid) 65 | params = {'userid': mid, 'oid': home['result']['objectId']} 66 | return self.server.urlEncode(self.server.LINE_OBS_DOMAIN, '/myhome/c/download.nhn', params) 67 | 68 | """Post""" 69 | 70 | @loggedIn 71 | def createPost(self, text): 72 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 73 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v33/post/create.json', params) 74 | payload = {'postInfo': {'readPermission': {'type': 'ALL'}}, 'sourceType': 'TIMELINE', 'contents': {'text': text}} 75 | data = json.dumps(payload) 76 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 77 | return r.json() 78 | 79 | @loggedIn 80 | def createComment(self, mid, postId, text): 81 | if mid is None: 82 | mid = self.client.profile.mid 83 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 84 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v33/comment/create.json', params) 85 | data = {'commentText': text, 'activityExternalId': postId, 'actorId': mid} 86 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 87 | return r.json() 88 | 89 | @loggedIn 90 | def deleteComment(self, mid, postId, commentId): 91 | if mid is None: 92 | mid = self.client.profile.mid 93 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 94 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v33/comment/delete.json', params) 95 | data = {'commentId': commentId, 'activityExternalId': postId, 'actorId': mid} 96 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 97 | return r.json() 98 | 99 | @loggedIn 100 | def likePost(self, mid, postId, likeType=1001): 101 | if mid is None: 102 | mid = self.client.profile.mid 103 | if likeType not in [1001,1002,1003,1004,1005,1006]: 104 | raise Exception('Invalid parameter likeType') 105 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 106 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v33/like/create.json', params) 107 | data = {'likeType': likeType, 'activityExternalId': postId, 'actorId': mid} 108 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 109 | return r.json() 110 | 111 | @loggedIn 112 | def unlikePost(self, mid, postId): 113 | if mid is None: 114 | mid = self.client.profile.mid 115 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 116 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v33/like/cancel.json', params) 117 | data = {'activityExternalId': postId, 'actorId': mid} 118 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 119 | return r.json() 120 | 121 | """Group Post""" 122 | 123 | @loggedIn 124 | def createGroupPost(self, mid, text): 125 | payload = {'postInfo': {'readPermission': {'homeId': mid}}, 'sourceType': 'TIMELINE', 'contents': {'text': text}} 126 | data = json.dumps(payload) 127 | r = self.server.postContent(self.server.LINE_TIMELINE_API + '/v27/post/create.json', data=data, headers=self.server.channelHeaders) 128 | return r.json() 129 | 130 | @loggedIn 131 | def createGroupAlbum(self, mid, name): 132 | data = json.dumps({'title': name, 'type': 'image'}) 133 | params = {'homeId': mid,'count': '1','auto': '0'} 134 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/album.json', params) 135 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 136 | if r.status_code != 201: 137 | raise Exception('Create a new album failure.') 138 | return True 139 | 140 | @loggedIn 141 | def deleteGroupAlbum(self, mid, albumId): 142 | params = {'homeId': mid} 143 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/album/%s' % albumId, params) 144 | r = self.server.deleteContent(url, headers=self.server.channelHeaders) 145 | if r.status_code != 201: 146 | raise Exception('Delete album failure.') 147 | return True 148 | 149 | @loggedIn 150 | def getGroupPost(self, mid, postLimit=10, commentLimit=1, likeLimit=1): 151 | params = {'homeId': mid, 'commentLimit': commentLimit, 'likeLimit': likeLimit, 'sourceType': 'TALKROOM'} 152 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v27/post/list.json', params) 153 | r = self.server.getContent(url, headers=self.server.channelHeaders) 154 | return r.json() 155 | 156 | """Group Album""" 157 | 158 | @loggedIn 159 | def getGroupAlbum(self, mid): 160 | params = {'homeId': mid, 'type': 'g', 'sourceType': 'TALKROOM'} 161 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/albums.json', params) 162 | r = self.server.getContent(url, headers=self.server.channelHeaders) 163 | return r.json() 164 | 165 | @loggedIn 166 | def changeGroupAlbumName(self, mid, albumId, name): 167 | data = json.dumps({'title': name}) 168 | params = {'homeId': mid} 169 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/album/%s' % albumId, params) 170 | r = self.server.putContent(url, data=data, headers=self.server.channelHeaders) 171 | if r.status_code != 201: 172 | raise Exception('Change album name failure.') 173 | return True 174 | 175 | @loggedIn 176 | def addImageToAlbum(self, mid, albumId, path): 177 | file = open(path, 'rb').read() 178 | params = { 179 | 'oid': int(time.time()), 180 | 'quality': '90', 181 | 'range': len(file), 182 | 'type': 'image' 183 | } 184 | hr = self.server.additionalHeaders(self.server.channelHeaders, { 185 | 'Content-Type': 'image/jpeg', 186 | 'X-Line-Mid': mid, 187 | 'X-Line-Album': albumId, 188 | 'x-obs-params': self.genOBSParams(params,'b64') 189 | }) 190 | r = self.server.getContent(self.server.LINE_OBS_DOMAIN + '/album/a/upload.nhn', data=file, headers=hr) 191 | if r.status_code != 201: 192 | raise Exception('Add image to album failure.') 193 | return r.json() 194 | 195 | @loggedIn 196 | def getImageGroupAlbum(self, mid, albumId, objId, returnAs='path', saveAs=''): 197 | if saveAs == '': 198 | saveAs = self.genTempFile('path') 199 | if returnAs not in ['path','bool','bin']: 200 | raise Exception('Invalid returnAs value') 201 | hr = self.server.additionalHeaders(self.server.channelHeaders, { 202 | 'Content-Type': 'image/jpeg', 203 | 'X-Line-Mid': mid, 204 | 'X-Line-Album': albumId 205 | }) 206 | params = {'ver': '1.0', 'oid': objId} 207 | url = self.server.urlEncode(self.server.LINE_OBS_DOMAIN, '/album/a/download.nhn', params) 208 | r = self.server.getContent(url, headers=hr) 209 | if r.status_code == 200: 210 | self.saveFile(saveAs, r.raw) 211 | if returnAs == 'path': 212 | return saveAs 213 | elif returnAs == 'bool': 214 | return True 215 | elif returnAs == 'bin': 216 | return r.raw 217 | else: 218 | raise Exception('Download image album failure.') 219 | 220 | """Contact""" 221 | 222 | @loggedIn 223 | def getProfileCoverURL(self, mid=None): 224 | if mid is None: 225 | mid = self.client.profile.mid 226 | home = self.getProfileDetail(mid) 227 | params = {'userid': mid, 'oid': home['result']['objectId']} 228 | return self.server.urlEncode(self.server.LINE_OBS_DOMAIN, '/myhome/c/download.nhn', params) -------------------------------------------------------------------------------- /thrift/protocol/TProtocol.py: -------------------------------------------------------------------------------- 1 | #LICENCE : http://www.apache.org/licenses/LICENSE-2.0 2 | #CREATOR BY : PRANKBOT 3 | #MOD BY ACIL 4 | from thrift.unverting import TException, TType, TFrozenDict 5 | from thrift.transport.TTransport import TTransportException 6 | from ..compat import binary_to_str, str_to_binary 7 | import six 8 | import sys 9 | from itertools import islice 10 | from six.moves import zip 11 | class TProtocolException(TException): 12 | UNKNOWN = 0 13 | INVALID_DATA = 1 14 | NEGATIVE_SIZE = 2 15 | SIZE_LIMIT = 3 16 | BAD_VERSION = 4 17 | NOT_IMPLEMENTED = 5 18 | DEPTH_LIMIT = 6 19 | def __init__(self, type=UNKNOWN, message=None): 20 | TException.__init__(self, message) 21 | self.type = type 22 | class TProtocolBase(object): 23 | def __init__(self, trans): 24 | self.trans = trans 25 | self._fast_decode = None 26 | self._fast_encode = None 27 | @staticmethod 28 | def _check_length(limit, length): 29 | if length < 0: 30 | raise TTransportException(TTransportException.NEGATIVE_SIZE, 31 | 'Negative length: %d' % length) 32 | if limit is not None and length > limit: 33 | raise TTransportException(TTransportException.SIZE_LIMIT, 34 | 'Length exceeded max allowed: %d' % limit) 35 | def writeMessageBegin(self, name, ttype, seqid): 36 | pass 37 | def writeMessageEnd(self): 38 | pass 39 | def writeStructBegin(self, name): 40 | pass 41 | def writeStructEnd(self): 42 | pass 43 | def writeFieldBegin(self, name, ttype, fid): 44 | pass 45 | def writeFieldEnd(self): 46 | pass 47 | def writeFieldStop(self): 48 | pass 49 | def writeMapBegin(self, ktype, vtype, size): 50 | pass 51 | def writeMapEnd(self): 52 | pass 53 | def writeListBegin(self, etype, size): 54 | pass 55 | def writeListEnd(self): 56 | pass 57 | def writeSetBegin(self, etype, size): 58 | pass 59 | def writeSetEnd(self): 60 | pass 61 | def writeBool(self, bool_val): 62 | pass 63 | def writeByte(self, byte): 64 | pass 65 | def writeI16(self, i16): 66 | pass 67 | def writeI32(self, i32): 68 | pass 69 | def writeI64(self, i64): 70 | pass 71 | def writeDouble(self, dub): 72 | pass 73 | def writeString(self, str_val): 74 | self.writeBinary(str_to_binary(str_val)) 75 | def writeBinary(self, str_val): 76 | pass 77 | def writeUtf8(self, str_val): 78 | self.writeString(str_val.encode('utf8')) 79 | def readMessageBegin(self): 80 | pass 81 | def readMessageEnd(self): 82 | pass 83 | def readStructBegin(self): 84 | pass 85 | def readStructEnd(self): 86 | pass 87 | def readFieldBegin(self): 88 | pass 89 | def readFieldEnd(self): 90 | pass 91 | def readMapBegin(self): 92 | pass 93 | def readMapEnd(self): 94 | pass 95 | def readListBegin(self): 96 | pass 97 | def readListEnd(self): 98 | pass 99 | def readSetBegin(self): 100 | pass 101 | def readSetEnd(self): 102 | pass 103 | def readBool(self): 104 | pass 105 | def readByte(self): 106 | pass 107 | def readI16(self): 108 | pass 109 | def readI32(self): 110 | pass 111 | def readI64(self): 112 | pass 113 | def readDouble(self): 114 | pass 115 | def readString(self): 116 | return binary_to_str(self.readBinary()) 117 | def readBinary(self): 118 | pass 119 | def readUtf8(self): 120 | return self.readString().decode('utf8') 121 | def skip(self, ttype): 122 | if ttype == TType.STOP: 123 | return 124 | elif ttype == TType.BOOL: 125 | self.readBool() 126 | elif ttype == TType.BYTE: 127 | self.readByte() 128 | elif ttype == TType.I16: 129 | self.readI16() 130 | elif ttype == TType.I32: 131 | self.readI32() 132 | elif ttype == TType.I64: 133 | self.readI64() 134 | elif ttype == TType.DOUBLE: 135 | self.readDouble() 136 | elif ttype == TType.STRING: 137 | self.readString() 138 | elif ttype == TType.STRUCT: 139 | name = self.readStructBegin() 140 | while True: 141 | (name, ttype, id) = self.readFieldBegin() 142 | if ttype == TType.STOP: 143 | break 144 | self.skip(ttype) 145 | self.readFieldEnd() 146 | self.readStructEnd() 147 | elif ttype == TType.MAP: 148 | (ktype, vtype, size) = self.readMapBegin() 149 | for i in range(size): 150 | self.skip(ktype) 151 | self.skip(vtype) 152 | self.readMapEnd() 153 | elif ttype == TType.SET: 154 | (etype, size) = self.readSetBegin() 155 | for i in range(size): 156 | self.skip(etype) 157 | self.readSetEnd() 158 | elif ttype == TType.LIST: 159 | (etype, size) = self.readListBegin() 160 | for i in range(size): 161 | self.skip(etype) 162 | self.readListEnd() 163 | _TTYPE_HANDLERS = ( 164 | (None, None, False), 165 | (None, None, False), 166 | ('readBool', 'writeBool', False), 167 | ('readByte', 'writeByte', False), 168 | ('readDouble', 'writeDouble', False), 169 | (None, None, False), 170 | ('readI16', 'writeI16', False), 171 | (None, None, False), 172 | ('readI32', 'writeI32', False), 173 | (None, None, False), 174 | ('readI64', 'writeI64', False), 175 | ('readString', 'writeString', False), 176 | ('readContainerStruct', 'writeContainerStruct', True), 177 | ('readContainerMap', 'writeContainerMap', True), 178 | ('readContainerSet', 'writeContainerSet', True), 179 | ('readContainerList', 'writeContainerList', True), 180 | (None, None, False), 181 | (None, None, False) 182 | ) 183 | def _ttype_handlers(self, ttype, spec): 184 | if spec == 'BINARY': 185 | if ttype != TType.STRING: 186 | raise TProtocolException(type=TProtocolException.INVALID_DATA, 187 | message='EROR DI %d' % ttype) 188 | return ('readBinary', 'writeBinary', False) 189 | if sys.version_info[0] == 2 and spec == 'UTF8': 190 | if ttype != TType.STRING: 191 | raise TProtocolException(type=TProtocolException.INVALID_DATA, 192 | message='EROR DI %d' % ttype) 193 | return ('readUtf8', 'writeUtf8', False) 194 | return self._TTYPE_HANDLERS[ttype] if ttype < len(self._TTYPE_HANDLERS) else (None, None, False) 195 | def _read_by_ttype(self, ttype, spec, espec): 196 | reader_name, _, is_container = self._ttype_handlers(ttype, espec) 197 | if reader_name is None: 198 | raise TProtocolException(type=TProtocolException.INVALID_DATA, 199 | message='EROR DI %d' % (ttype)) 200 | reader_func = getattr(self, reader_name) 201 | read = (lambda: reader_func(espec)) if is_container else reader_func 202 | while True: 203 | yield read() 204 | def readFieldByTType(self, ttype, spec): 205 | return next(self._read_by_ttype(ttype, spec, spec)) 206 | def readContainerList(self, spec): 207 | ttype, tspec, is_immutable = spec 208 | (list_type, list_len) = self.readListBegin() 209 | elems = islice(self._read_by_ttype(ttype, spec, tspec), list_len) 210 | results = (tuple if is_immutable else list)(elems) 211 | self.readListEnd() 212 | return results 213 | def readContainerSet(self, spec): 214 | ttype, tspec, is_immutable = spec 215 | (set_type, set_len) = self.readSetBegin() 216 | elems = islice(self._read_by_ttype(ttype, spec, tspec), set_len) 217 | results = (frozenset if is_immutable else set)(elems) 218 | self.readSetEnd() 219 | return results 220 | def readContainerStruct(self, spec): 221 | (obj_class, obj_spec) = spec 222 | obj = obj_class() 223 | obj.read(self) 224 | return obj 225 | def readContainerMap(self, spec): 226 | ktype, kspec, vtype, vspec, is_immutable = spec 227 | (map_ktype, map_vtype, map_len) = self.readMapBegin() 228 | keys = self._read_by_ttype(ktype, spec, kspec) 229 | vals = self._read_by_ttype(vtype, spec, vspec) 230 | keyvals = islice(zip(keys, vals), map_len) 231 | results = (TFrozenDict if is_immutable else dict)(keyvals) 232 | self.readMapEnd() 233 | return results 234 | def readStruct(self, obj, thrift_spec, is_immutable=False): 235 | if is_immutable: 236 | fields = {} 237 | self.readStructBegin() 238 | while True: 239 | (fname, ftype, fid) = self.readFieldBegin() 240 | if ftype == TType.STOP: 241 | break 242 | try: 243 | field = thrift_spec[fid] 244 | except IndexError: 245 | self.skip(ftype) 246 | else: 247 | if field is not None and ftype == field[1]: 248 | fname = field[2] 249 | fspec = field[3] 250 | val = self.readFieldByTType(ftype, fspec) 251 | if is_immutable: 252 | fields[fname] = val 253 | else: 254 | setattr(obj, fname, val) 255 | else: 256 | self.skip(ftype) 257 | self.readFieldEnd() 258 | self.readStructEnd() 259 | if is_immutable: 260 | return obj(**fields) 261 | def writeContainerStruct(self, val, spec): 262 | val.write(self) 263 | def writeContainerList(self, val, spec): 264 | ttype, tspec, _ = spec 265 | self.writeListBegin(ttype, len(val)) 266 | for _ in self._write_by_ttype(ttype, val, spec, tspec): 267 | pass 268 | self.writeListEnd() 269 | def writeContainerSet(self, val, spec): 270 | ttype, tspec, _ = spec 271 | self.writeSetBegin(ttype, len(val)) 272 | for _ in self._write_by_ttype(ttype, val, spec, tspec): 273 | pass 274 | self.writeSetEnd() 275 | def writeContainerMap(self, val, spec): 276 | ktype, kspec, vtype, vspec, _ = spec 277 | self.writeMapBegin(ktype, vtype, len(val)) 278 | for _ in zip(self._write_by_ttype(ktype, six.iterkeys(val), spec, kspec), 279 | self._write_by_ttype(vtype, six.itervalues(val), spec, vspec)): 280 | pass 281 | self.writeMapEnd() 282 | def writeStruct(self, obj, thrift_spec): 283 | self.writeStructBegin(obj.__class__.__name__) 284 | for field in thrift_spec: 285 | if field is None: 286 | continue 287 | fname = field[2] 288 | val = getattr(obj, fname) 289 | if val is None: 290 | continue 291 | fid = field[0] 292 | ftype = field[1] 293 | fspec = field[3] 294 | self.writeFieldBegin(fname, ftype, fid) 295 | self.writeFieldByTType(ftype, val, fspec) 296 | self.writeFieldEnd() 297 | self.writeFieldStop() 298 | self.writeStructEnd() 299 | def _write_by_ttype(self, ttype, vals, spec, espec): 300 | _, writer_name, is_container = self._ttype_handlers(ttype, espec) 301 | writer_func = getattr(self, writer_name) 302 | write = (lambda v: writer_func(v, espec)) if is_container else writer_func 303 | for v in vals: 304 | yield write(v) 305 | def writeFieldByTType(self, ttype, val, spec): 306 | next(self._write_by_ttype(ttype, [val], spec, spec)) 307 | def checkIntegerLimits(i, bits): 308 | if bits == 8 and (i < -128 or i > 127): 309 | raise TProtocolException(TProtocolException.INVALID_DATA, 310 | "i8 requires -128 <= number <= 127") 311 | elif bits == 16 and (i < -32768 or i > 32767): 312 | raise TProtocolException(TProtocolException.INVALID_DATA, 313 | "i16 requires -32768 <= number <= 32767") 314 | elif bits == 32 and (i < -2147483648 or i > 2147483647): 315 | raise TProtocolException(TProtocolException.INVALID_DATA, 316 | "i32 requires -2147483648 <= number <= 2147483647") 317 | elif bits == 64 and (i < -9223372036854775808 or i > 9223372036854775807): 318 | raise TProtocolException(TProtocolException.INVALID_DATA, 319 | "i64 requires -9223372036854775808 <= number <= 9223372036854775807") 320 | class TProtocolFactory(object): 321 | def getProtocol(self, trans): 322 | pass 323 | -------------------------------------------------------------------------------- /KIA/talk.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from akad.ttypes import Message 3 | from random import randint 4 | 5 | import json, ntpath 6 | 7 | def loggedIn(func): 8 | def checkLogin(*args, **kwargs): 9 | if args[0].isLogin: 10 | return func(*args, **kwargs) 11 | else: 12 | args[0].callback.other("You want to call the function, you must login to LINE") 13 | return checkLogin 14 | 15 | class LineTalk(object): 16 | isLogin = False 17 | _messageReq = {} 18 | _unsendMessageReq = 0 19 | 20 | def __init__(self): 21 | self.isLogin = True 22 | 23 | """User""" 24 | 25 | @loggedIn 26 | def getProfile(self): 27 | return self.talk.getProfile() 28 | 29 | @loggedIn 30 | def getSettings(self): 31 | return self.talk.getSettings() 32 | 33 | @loggedIn 34 | def getUserTicket(self): 35 | return self.talk.getUserTicket() 36 | 37 | @loggedIn 38 | def updateProfile(self, profileObject): 39 | return self.talk.updateProfile(0, profileObject) 40 | 41 | @loggedIn 42 | def updateSettings(self, settingObject): 43 | return self.talk.updateSettings(0, settingObject) 44 | 45 | @loggedIn 46 | def updateProfileAttribute(self, attrId, value): 47 | return self.talk.updateProfileAttribute(0, attrId, value) 48 | 49 | """Operation""" 50 | 51 | @loggedIn 52 | def fetchOperation(self, revision, count): 53 | return self.talk.fetchOperations(revision, count) 54 | 55 | @loggedIn 56 | def getLastOpRevision(self): 57 | return self.talk.getLastOpRevision() 58 | 59 | """Message""" 60 | 61 | @loggedIn 62 | def sendMessage(self, to, text, contentMetadata={}, contentType=0): 63 | msg = Message() 64 | msg.to, msg._from = to, self.profile.mid 65 | msg.text = text 66 | msg.contentType, msg.contentMetadata = contentType, contentMetadata 67 | if to not in self._messageReq: 68 | self._messageReq[to] = -1 69 | self._messageReq[to] += 1 70 | return self.talk.sendMessage(self._messageReq[to], msg) 71 | 72 | """ Usage: 73 | @to Integer 74 | @text String 75 | @dataMid List of user Mid 76 | """ 77 | @loggedIn 78 | def sendText(self, Tomid, text): 79 | msg = Message() 80 | msg.to = Tomid 81 | msg.text = text 82 | 83 | return self.talk.sendMessage(0, msg) 84 | 85 | @loggedIn 86 | def sendMessage1(self, messageObject): 87 | return self.talk.sendMessage(0,messageObject) 88 | 89 | @loggedIn 90 | def sendMessageWithMention(self, to, text='', dataMid=[]): 91 | arr = [] 92 | list_text='' 93 | if '[list]' in text.lower(): 94 | i=0 95 | for l in dataMid: 96 | list_text+='\n@[list-'+str(i)+']' 97 | i=i+1 98 | text=text.replace('[list]', list_text) 99 | elif '[list-' in text.lower(): 100 | text=text 101 | else: 102 | i=0 103 | for l in dataMid: 104 | list_text+=' @[list-'+str(i)+']' 105 | i=i+1 106 | text=text+list_text 107 | i=0 108 | for l in dataMid: 109 | mid=l 110 | name='@[list-'+str(i)+']' 111 | ln_text=text.replace('\n',' ') 112 | if ln_text.find(name): 113 | line_s=int(ln_text.index(name)) 114 | line_e=(int(line_s)+int(len(name))) 115 | arrData={'S': str(line_s), 'E': str(line_e), 'M': mid} 116 | arr.append(arrData) 117 | i=i+1 118 | contentMetadata={'MENTION':str('{"MENTIONEES":' + json.dumps(arr).replace(' ','') + '}')} 119 | return self.sendMessage(to, text, contentMetadata) 120 | 121 | @loggedIn 122 | def sendSticker(self, to, packageId, stickerId): 123 | contentMetadata = { 124 | 'STKVER': '100', 125 | 'STKPKGID': packageId, 126 | 'STKID': stickerId 127 | } 128 | return self.sendMessage(to, '', contentMetadata, 7) 129 | 130 | @loggedIn 131 | def sendContact(self, to, mid): 132 | contentMetadata = {'mid': mid} 133 | return self.sendMessage(to, '', contentMetadata, 13) 134 | 135 | @loggedIn 136 | def sendGift(self, productId, productType): 137 | if productType not in ['theme','sticker']: 138 | raise Exception('Invalid productType value') 139 | contentMetadata = { 140 | 'MSGTPL': str(randint(0, 12)), 141 | 'PRDTYPE': productType.upper(), 142 | 'STKPKGID' if productType == 'sticker' else 'PRDID': productId 143 | } 144 | return self.sendMessage(to, '', contentMetadata, 9) 145 | 146 | @loggedIn 147 | def unsendMessage(self, messageId): 148 | self._unsendMessageReq += 1 149 | return self.talk.unsendMessage(self._unsendMessageReq, messageId) 150 | 151 | @loggedIn 152 | def requestResendMessage(self, senderMid, messageId): 153 | return self.talk.requestResendMessage(self.revision, senderMid, messageId) 154 | 155 | @loggedIn 156 | def respondResendMessage(self, receiverMid, originalMessageId, resendMessage, errorCode): 157 | return self.talk.respondResendMessage(self.revision, receiverMid, originalMessageId, resendMessage, errorCode) 158 | 159 | @loggedIn 160 | def removeMessage(self, messageId): 161 | return self.talk.removeMessage(messageId) 162 | 163 | @loggedIn 164 | def removeAllMessages(self, lastMessageId): 165 | return self.talk.removeAllMessages(0, lastMessageId) 166 | 167 | @loggedIn 168 | def sendChatChecked(self, consumer, messageId): 169 | return self.talk.sendChatChecked(0, consumer, messageId) 170 | 171 | @loggedIn 172 | def sendEvent(self, messageObject): 173 | return self.talk.sendEvent(0, messageObject) 174 | 175 | @loggedIn 176 | def getLastReadMessageIds(self, chatId): 177 | return self.talk.getLastReadMessageIds(0,chatId) 178 | 179 | """Object""" 180 | 181 | @loggedIn 182 | def sendImage(self, to, path): 183 | objectId = self.sendMessage(to=to, text=None, contentType = 1).id 184 | return self.uploadObjTalk(path=path, type='image', returnAs='bool', objId=objectId) 185 | 186 | @loggedIn 187 | def sendImageWithURL(self, to, url): 188 | path = self.downloadFileURL(url, 'path') 189 | return self.sendImage(to, path) 190 | 191 | @loggedIn 192 | def sendGIF(self, to, path): 193 | return self.uploadObjTalk(path=path, type='gif', returnAs='bool', to=to) 194 | 195 | @loggedIn 196 | def sendGIFWithURL(self, to, url): 197 | path = self.downloadFileURL(url, 'path') 198 | return self.sendGIF(to, path) 199 | 200 | @loggedIn 201 | def sendVideo(self, to, path): 202 | objectId = self.sendMessage(to=to, text=None, contentMetadata={'VIDLEN': '60000','DURATION': '60000'}, contentType = 2).id 203 | return self.uploadObjTalk(path=path, type='video', returnAs='bool', objId=objectId) 204 | 205 | @loggedIn 206 | def sendVideoWithURL(self, to, url): 207 | path = self.downloadFileURL(url, 'path') 208 | return self.sendVideo(to, path) 209 | 210 | @loggedIn 211 | def sendAudio(self, to, path): 212 | objectId = self.sendMessage(to=to, text=None, contentType = 3).id 213 | return self.uploadObjTalk(path=path, type='audio', returnAs='bool', objId=objectId) 214 | 215 | @loggedIn 216 | def sendAudioWithURL(self, to, url): 217 | path = self.downloadFileURL(url, 'path') 218 | return self.sendAudio(to, path) 219 | 220 | @loggedIn 221 | def sendFile(self, to, path, file_name=''): 222 | if file_name == '': 223 | file_name = ntpath.basename(path) 224 | file_size = len(open(path, 'rb').read()) 225 | objectId = self.sendMessage(to=to, text=None, contentMetadata={'FILE_NAME': str(file_name),'FILE_SIZE': str(file_size)}, contentType = 14).id 226 | return self.uploadObjTalk(path=path, type='file', returnAs='bool', objId=objectId) 227 | 228 | @loggedIn 229 | def sendFileWithURL(self, to, url, fileName=''): 230 | path = self.downloadFileURL(url, 'path') 231 | return self.sendFile(to, path, fileName) 232 | 233 | """Contact""" 234 | 235 | @loggedIn 236 | def blockContact(self, mid): 237 | return self.talk.blockContact(0, mid) 238 | 239 | @loggedIn 240 | def unblockContact(self, mid): 241 | return self.talk.unblockContact(0, mid) 242 | 243 | @loggedIn 244 | def findAndAddContactsByMid(self, mid): 245 | return self.talk.findAndAddContactsByMid(0, mid) 246 | 247 | @loggedIn 248 | def findAndAddContactsByUserid(self, userid): 249 | return self.talk.findAndAddContactsByUserid(0, userid) 250 | 251 | @loggedIn 252 | def findContactsByUserid(self, userid): 253 | return self.talk.findContactByUserid(userid) 254 | 255 | @loggedIn 256 | def findContactByTicket(self, ticketId): 257 | return self.talk.findContactByUserTicket(ticketId) 258 | 259 | @loggedIn 260 | def getAllContactIds(self): 261 | return self.talk.getAllContactIds() 262 | 263 | @loggedIn 264 | def getBlockedContactIds(self): 265 | return self.talk.getBlockedContactIds() 266 | 267 | @loggedIn 268 | def getContact(self, mid): 269 | return self.talk.getContact(mid) 270 | 271 | @loggedIn 272 | def getContacts(self, midlist): 273 | return self.talk.getContacts(midlist) 274 | 275 | @loggedIn 276 | def getFavoriteMids(self): 277 | return self.talk.getFavoriteMids() 278 | 279 | @loggedIn 280 | def getHiddenContactMids(self): 281 | return self.talk.getHiddenContactMids() 282 | 283 | @loggedIn 284 | def reissueUserTicket(self, expirationTime=100, maxUseCount=100): 285 | return self.talk.reissueUserTicket(expirationTime, maxUseCount) 286 | 287 | @loggedIn 288 | def cloneContactProfile(self, mid): 289 | contact = self.getContact(mid) 290 | profile = self.profile 291 | profile.displayName = contact.displayName 292 | profile.statusMessage = contact.statusMessage 293 | profile.pictureStatus = contact.pictureStatus 294 | self.updateProfileAttribute(8, profile.pictureStatus) 295 | return self.updateProfile(profile) 296 | 297 | """Group""" 298 | 299 | @loggedIn 300 | def getChatRoomAnnouncementsBulk(self, chatRoomMids): 301 | return self.talk.getChatRoomAnnouncementsBulk(chatRoomMids) 302 | 303 | @loggedIn 304 | def getChatRoomAnnouncements(self, chatRoomMid): 305 | return self.talk.getChatRoomAnnouncements(chatRoomMid) 306 | 307 | @loggedIn 308 | def createChatRoomAnnouncement(self, chatRoomMid, type, contents): 309 | return self.talk.createChatRoomAnnouncement(self.revision, chatRoomMid, type, contents) 310 | 311 | @loggedIn 312 | def removeChatRoomAnnouncement(self, chatRoomMid, announcementSeq): 313 | return self.talk.removeChatRoomAnnouncement(self.revision, chatRoomMid, announcementSeq) 314 | 315 | @loggedIn 316 | def getGroupWithoutMembers(self, groupId): 317 | return self.talk.getGroupWithoutMembers(groupId) 318 | 319 | @loggedIn 320 | def findGroupByTicket(self, ticketId): 321 | return self.talk.findGroupByTicket(ticketId) 322 | 323 | @loggedIn 324 | def acceptGroupInvitation(self, groupId): 325 | return self.talk.acceptGroupInvitation(0, groupId) 326 | 327 | @loggedIn 328 | def acceptGroupInvitationByTicket(self, groupId, ticketId): 329 | return self.talk.acceptGroupInvitationByTicket(0, groupId, ticketId) 330 | 331 | @loggedIn 332 | def cancelGroupInvitation(self, groupId, contactIds): 333 | return self.talk.cancelGroupInvitation(0, groupId, contactIds) 334 | 335 | @loggedIn 336 | def createGroup(self, name, midlist): 337 | return self.talk.createGroup(0, name, midlist) 338 | 339 | @loggedIn 340 | def getGroup(self, groupId): 341 | return self.talk.getGroup(groupId) 342 | 343 | @loggedIn 344 | def getGroups(self, groupIds): 345 | return self.talk.getGroups(groupIds) 346 | 347 | @loggedIn 348 | def getGroupIdsInvited(self): 349 | return self.talk.getGroupIdsInvited() 350 | 351 | @loggedIn 352 | def getGroupIdsJoined(self): 353 | return self.talk.getGroupIdsJoined() 354 | 355 | @loggedIn 356 | def inviteIntoGroup(self, groupId, midlist): 357 | return self.talk.inviteIntoGroup(0, groupId, midlist) 358 | 359 | @loggedIn 360 | def kickoutFromGroup(self, groupId, midlist): 361 | return self.talk.kickoutFromGroup(0, groupId, midlist) 362 | 363 | @loggedIn 364 | def leaveGroup(self, groupId): 365 | return self.talk.leaveGroup(0, groupId) 366 | 367 | @loggedIn 368 | def rejectGroupInvitation(self, groupId): 369 | return self.talk.rejectGroupInvitation(0, groupId) 370 | 371 | @loggedIn 372 | def reissueGroupTicket(self, groupId): 373 | return self.talk.reissueGroupTicket(groupId) 374 | 375 | @loggedIn 376 | def updateGroup(self, groupObject): 377 | return self.talk.updateGroup(0, groupObject) 378 | 379 | """Room""" 380 | 381 | @loggedIn 382 | def createRoom(self, midlist): 383 | return self.talk.createRoom(0, midlist) 384 | 385 | @loggedIn 386 | def getRoom(self, roomId): 387 | return self.talk.getRoom(roomId) 388 | 389 | @loggedIn 390 | def inviteIntoRoom(self, roomId, midlist): 391 | return self.talk.inviteIntoRoom(0, roomId, midlist) 392 | 393 | @loggedIn 394 | def leaveRoom(self, roomId): 395 | return self.talk.leaveRoom(0, roomId) 396 | 397 | """Call""" 398 | 399 | @loggedIn 400 | def acquireCallTalkRoute(self, to): 401 | return self.talk.acquireCallRoute(to) --------------------------------------------------------------------------------