├── .gitignore ├── LINETCR ├── Api │ ├── LineTracer.py │ ├── Poll.py │ ├── Talk.py │ ├── __init__.py │ └── channel.py ├── LineApi.py ├── __init__.py ├── lib │ ├── __init__.py │ └── curve │ │ ├── LineService.py │ │ ├── __init__.py │ │ ├── constants.py │ │ └── ttypes.py └── server.py ├── README.md └── line-tcr.py /.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 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 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 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | -------------------------------------------------------------------------------- /LINETCR/Api/LineTracer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .LineClient import LineClient 4 | from types import * 5 | from ..lib.curve.ttypes import OpType 6 | from ..Net.LineServer import url 7 | 8 | 9 | class LineTracer(object): 10 | OpInterrupt = {} 11 | client = None 12 | 13 | def __init__(self, client): 14 | if type(client) is not LineClient: 15 | raise Exception( 16 | "You need to set LineClient instance to initialize LineTracer") 17 | 18 | self.client = client 19 | self.client.endPoint(url.LONG_POLLING) 20 | 21 | def addOpInterruptWithDict(self, OpInterruptDict): 22 | """To add Operation with Callback function {Optype.NOTIFIED_INTO_GROUP: func}""" 23 | self.OpInterrupt.update(OpInterruptDict) 24 | 25 | def addOpInterrupt(self, OperationType, DisposeFunc): 26 | self.OpInterrupt[OperationType] = DisposeFunc 27 | 28 | def execute(self): 29 | try: 30 | operations = self.client.fetchOperation(self.client.revision, 10) 31 | #print "=======================================================" 32 | # print operations 33 | #print "=======================================================" 34 | except EOFError: 35 | return 36 | except KeyboardInterrupt: 37 | exit() 38 | except: 39 | return 40 | 41 | for op in operations: 42 | if op.type in self.OpInterrupt.keys(): 43 | #print "=======================================================" 44 | #print str(op.type) + "[" + str(op) + "]" 45 | #print "=======================================================" 46 | self.OpInterrupt[op.type](op) 47 | 48 | self.client.revision = max(op.revision, self.client.revision) 49 | -------------------------------------------------------------------------------- /LINETCR/Api/Poll.py: -------------------------------------------------------------------------------- 1 | import os, sys, time 2 | path = os.path.join(os.path.dirname(__file__), '../lib/') 3 | sys.path.insert(0, path) 4 | 5 | from thrift.transport import THttpClient 6 | from thrift.protocol import TCompactProtocol 7 | 8 | from curve import LineService 9 | from curve.ttypes import * 10 | 11 | class Poll: 12 | 13 | client = None 14 | 15 | auth_query_path = "/api/v4/TalkService.do"; 16 | http_query_path = "/S4"; 17 | polling_path = "/P4"; 18 | host = "gd2.line.naver.jp"; 19 | port = 443; 20 | 21 | UA = "Line/6.0.0 iPad4,1 9.0.2" 22 | LA = "IOSIPAD\t7.14.0\tiPhone OS\t10.12.0" 23 | 24 | rev = 0 25 | 26 | def __init__(self, authToken): 27 | self.transport = THttpClient.THttpClient('https://gd2.line.naver.jp:443'+ self.http_query_path) 28 | self.transport.setCustomHeaders({ 29 | "User-Agent" : self.UA, 30 | "X-Line-Application" : self.LA, 31 | "X-Line-Access": authToken 32 | }); 33 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport); 34 | self.client = LineService.Client(self.protocol) 35 | self.rev = self.client.getLastOpRevision() 36 | self.transport.path = self.polling_path 37 | self.transport.open() 38 | 39 | def stream(self, sleep=50000): 40 | #usleep = lambda x: time.sleep(x/1000000.0) 41 | while True: 42 | try: 43 | Ops = self.client.fetchOps(self.rev, 5) 44 | except EOFError: 45 | raise Exception("It might be wrong revision\n" + str(self.rev)) 46 | 47 | for Op in Ops: 48 | # print Op.type 49 | if (Op.type != OpType.END_OF_OPERATION): 50 | self.rev = max(self.rev, Op.revision) 51 | return Op 52 | 53 | #usleep(sleep) 54 | -------------------------------------------------------------------------------- /LINETCR/Api/Talk.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os, sys 3 | path = os.path.join(os.path.dirname(__file__), '../lib/') 4 | sys.path.insert(0, path) 5 | 6 | import requests, rsa 7 | 8 | from thrift.transport import THttpClient 9 | from thrift.protocol import TCompactProtocol 10 | 11 | from curve import LineService 12 | from curve.ttypes import * 13 | 14 | class Talk: 15 | client = None 16 | auth_query_path = "/api/v4/TalkService.do"; 17 | http_query_path = "/S4"; 18 | wait_for_mobile_path = "/Q"; 19 | host = "gd2.line.naver.jp"; 20 | port = 443; 21 | 22 | UA = "Line/6.0.0 iPad4,1 9.0.2" 23 | LA = "IOSIPAD\t7.14.0\tiPhone OS\t10.12.0" 24 | 25 | authToken = None 26 | cert = None 27 | 28 | def __init__(self): 29 | self.transport = THttpClient.THttpClient('https://gd2.line.naver.jp:443'+self.auth_query_path) 30 | self.transport.setCustomHeaders({ 31 | "User-Agent" : self.UA, 32 | "X-Line-Application" : self.LA, 33 | }) 34 | self.transport.open() 35 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport); 36 | self.client = LineService.Client(self.protocol) 37 | 38 | def login(self, mail, passwd, cert=None, callback=None): 39 | self.transport.path = self.auth_query_path 40 | rsakey = self.client.getRSAKeyInfo(IdentityProvider.LINE) 41 | crypt = self.__crypt(mail, passwd, rsakey) 42 | 43 | result = self.client.loginWithIdentityCredentialForCertificate( 44 | IdentityProvider.LINE, 45 | rsakey.keynm, 46 | crypt, 47 | True, 48 | '127.0.0.1', 49 | 'http://dg.b9dm.com/KoenoKatachi.mp4', 50 | cert 51 | ) 52 | 53 | if result.type == 3: 54 | callback(result.pinCode) 55 | header = {"X-Line-Access": result.verifier} 56 | r = requests.get(url="https://" + self.host + self.wait_for_mobile_path, headers=header) 57 | 58 | result = self.client.loginWithVerifierForCerificate(r.json()["result"]["verifier"]) 59 | self.transport.setCustomHeaders({ 60 | "X-Line-Application" : self.LA, 61 | "User-Agent" : self.UA, 62 | "X-Line-Access" : result.authToken 63 | }) 64 | 65 | self.authToken = result.authToken 66 | self.cert = result.certificate 67 | self.transport.path = self.http_query_path 68 | 69 | elif result.type == 1: 70 | self.authToken = result.authToken 71 | self.cert = result.certificate 72 | self.transport.setCustomHeaders({ 73 | "X-Line-Application" : self.LA, 74 | "User-Agent" : self.UA, 75 | "X-Line-Access" : result.authToken 76 | }) 77 | self.transport.path = self.http_query_path 78 | 79 | def TokenLogin(self, authToken): 80 | self.transport.setCustomHeaders({ 81 | "X-Line-Application" : self.LA, 82 | "User-Agent" : self.UA, 83 | "X-Line-Access" : authToken, 84 | }) 85 | self.authToken = authToken 86 | self.transport.path = self.http_query_path 87 | 88 | def qrLogin(self, callback): 89 | self.transport.path = self.auth_query_path 90 | 91 | qr = self.client.getAuthQrcode(True, "Ard Bot") 92 | callback("Copy to Line and Click\nYour LINK QR is: line://au/q/" + qr.verifier) 93 | 94 | r = requests.get("https://" + self.host + self.wait_for_mobile_path, headers={ 95 | "X-Line-Application": self.LA, 96 | "X-Line-Access": qr.verifier, 97 | }) 98 | 99 | vr = r.json()["result"]["verifier"] 100 | lr = self.client.loginWithVerifierForCerificate(vr) 101 | self.transport.setCustomHeaders({ 102 | "X-Line-Application" : self.LA, 103 | "User-Agent" : self.UA, 104 | "X-Line-Access": lr.authToken 105 | }) 106 | self.authToken = lr.authToken 107 | self.cert = lr.certificate 108 | self.transport.path = self.http_query_path 109 | 110 | 111 | def __crypt(self, mail, passwd, RSA): 112 | message = (chr(len(RSA.sessionKey)) + RSA.sessionKey + 113 | chr(len(mail)) + mail + 114 | chr(len(passwd)) + passwd).encode('utf-8') 115 | 116 | pub_key = rsa.PublicKey(int(RSA.nvalue, 16), int(RSA.evalue, 16)) 117 | crypto = rsa.encrypt(message, pub_key).encode('hex') 118 | 119 | return crypto 120 | -------------------------------------------------------------------------------- /LINETCR/Api/__init__.py: -------------------------------------------------------------------------------- 1 | from Talk import Talk 2 | from Poll import Poll 3 | from channel import Channel 4 | -------------------------------------------------------------------------------- /LINETCR/Api/channel.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os, sys, json 3 | path = os.path.join(os.path.dirname(__file__), '../lib/') 4 | sys.path.insert(0, path) 5 | import requests 6 | 7 | from thrift.transport import THttpClient 8 | from thrift.protocol import TCompactProtocol 9 | 10 | from curve import LineService 11 | from curve.ttypes import * 12 | import tempfile 13 | 14 | class Channel: 15 | 16 | host = "gd2.line.naver.jp" 17 | http_query_path = "/S4" 18 | channel_query_path = "/CH4" 19 | 20 | UA = "Line/6.0.0 iPad4,1 9.0.2" 21 | LA = "IOSIPAD\t7.14.0\tiPhone OS\t10.12.0" 22 | 23 | authToken = None 24 | mid = None 25 | channel_access_token = None 26 | token = None 27 | obs_token = None 28 | refresh_token = None 29 | 30 | def __init__(self, authToken): 31 | self.authToken = authToken 32 | self.transport = THttpClient.THttpClient('https://gd2.line.naver.jp:443'+self.http_query_path) 33 | self.transport.setCustomHeaders({ "User-Agent" : self.UA, 34 | "X-Line-Application" : self.LA, 35 | "X-Line-Access": self.authToken 36 | }) 37 | self.transport.open() 38 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 39 | self.client = LineService.Client(self.protocol) 40 | self.mid = self.client.getProfile().mid 41 | self.transport.path = self.channel_query_path 42 | 43 | def login(self): 44 | result = self.client.issueChannelToken("1341209950") 45 | 46 | self.channel_access_token = result.channelAccessToken 47 | self.token = result.token 48 | self.obs_token = result.obsToken 49 | self.refresh_token = result.refreshToken 50 | 51 | print "channelAccessToken:" + result.channelAccessToken 52 | print "token:" + result.token 53 | print "obs_token:" + result.obsToken 54 | print "refreshToken:" + result.refreshToken 55 | 56 | def new_post(self, text): 57 | 58 | header = { 59 | "Content-Type": "application/json", 60 | "User-Agent" : self.UA, 61 | "X-Line-Mid" : self.mid, 62 | "x-lct" : self.channel_access_token, 63 | } 64 | 65 | payload = { 66 | "postInfo" : { "readPermission" : { "type" : "ALL" } }, 67 | "sourceType" : "TIMELINE", 68 | "contents" : { "text" : text } 69 | } 70 | 71 | r = requests.post( 72 | "http://" + self.host + "/mh/api/v24/post/create.json", 73 | headers = header, 74 | data = json.dumps(payload) 75 | ) 76 | 77 | return r.json() 78 | 79 | def postPhoto(self,text,path): 80 | header = { 81 | "Content-Type": "application/json", 82 | "User-Agent" : self.UA, 83 | "X-Line-Mid" : self.mid, 84 | "x-lct" : self.channel_access_token, 85 | } 86 | 87 | payload = { 88 | "postInfo" : { "readPermission" : { "type" : "ALL" } }, 89 | "sourceType" : "TIMELINE", 90 | "contents" : { "text" : text ,"media" : [{u'objectId': u'F57144CF9ECC4AD2E162E68554D1A8BD1a1ab0t04ff07f6'}]} 91 | } 92 | r = requests.post( 93 | "http://" + self.host + "/mh/api/v24/post/create.json", 94 | headers = header, 95 | data = json.dumps(payload) 96 | ) 97 | 98 | return r.json() 99 | 100 | def like(self, mid, postid, likeType=1001): 101 | 102 | header = { 103 | "Content-Type" : "application/json", 104 | "X-Line-Mid" : self.mid, 105 | "x-lct" : self.channel_access_token, 106 | } 107 | 108 | payload = { 109 | "likeType" : likeType, 110 | "activityExternalId" : postid, 111 | "actorId" : mid 112 | } 113 | 114 | r = requests.post( 115 | "http://" + self.host + "/mh/api/v23/like/create.json?homeId=" + mid, 116 | headers = header, 117 | data = json.dumps(payload) 118 | ) 119 | 120 | return r.json() 121 | 122 | def comment(self, mid, postid, text): 123 | header = { 124 | "Content-Type" : "application/json", 125 | "X-Line-Mid" : self.mid, 126 | "x-lct" : self.channel_access_token, 127 | } 128 | 129 | payload = { 130 | "commentText" : text, 131 | "activityExternalId" : postid, 132 | "actorId" : mid 133 | } 134 | 135 | r = requests.post( 136 | "http://" + self.host + "/mh/api/v23/comment/create.json?homeId=" + mid, 137 | headers = header, 138 | data = json.dumps(payload) 139 | ) 140 | 141 | return r.json() 142 | 143 | def activity(self, limit=20): 144 | 145 | header = { 146 | "Content-Type" : "application/json", 147 | "X-Line-Mid" : self.mid, 148 | "x-lct" : self.channel_access_token, 149 | } 150 | 151 | r = requests.get( 152 | "http://" + self.host + "/tl/mapi/v21/activities?postLimit=" + str(limit), 153 | headers = header 154 | ) 155 | return r.json() 156 | def getAlbum(self, gid): 157 | 158 | header = { 159 | "Content-Type" : "application/json", 160 | "X-Line-Mid" : self.mid, 161 | "x-lct": self.channel_access_token, 162 | 163 | } 164 | 165 | r = requests.get( 166 | "http://" + self.host + "/mh/album/v3/albums?type=g&sourceType=TALKROOM&homeId=" + gid, 167 | headers = header 168 | ) 169 | return r.json() 170 | def changeAlbumName(self,gid,name,albumId): 171 | header = { 172 | "Content-Type" : "application/json", 173 | "X-Line-Mid" : self.mid, 174 | "x-lct": self.channel_access_token, 175 | 176 | } 177 | payload = { 178 | "title": name 179 | } 180 | r = requests.put( 181 | "http://" + self.host + "/mh/album/v3/album/" + albumId + "?homeId=" + gid, 182 | headers = header, 183 | data = json.dumps(payload), 184 | ) 185 | return r.json() 186 | def deleteAlbum(self,gid,albumId): 187 | header = { 188 | "Content-Type" : "application/json", 189 | "X-Line-Mid" : self.mid, 190 | "x-lct": self.channel_access_token, 191 | 192 | } 193 | r = requests.delete( 194 | "http://" + self.host + "/mh/album/v3/album/" + albumId + "?homeId=" + gid, 195 | headers = header, 196 | ) 197 | return r.json() 198 | def getNote(self,gid, commentLimit, likeLimit): 199 | header = { 200 | "Content-Type" : "application/json", 201 | "X-Line-Mid" : self.mid, 202 | "x-lct": self.channel_access_token, 203 | 204 | } 205 | r = requests.get( 206 | "http://" + self.host + "/mh/api/v27/post/list.json?homeId=" + gid + "&commentLimit=" + commentLimit + "&sourceType=TALKROOM&likeLimit=" + likeLimit, 207 | headers = header 208 | ) 209 | return r.json() 210 | 211 | def postNote(self, gid, text): 212 | header = { 213 | "Content-Type": "application/json", 214 | "User-Agent" : self.UA, 215 | "X-Line-Mid" : self.mid, 216 | "x-lct" : self.channel_access_token, 217 | } 218 | payload = {"postInfo":{"readPermission":{"homeId":gid}}, 219 | "sourceType":"GROUPHOME", 220 | "contents":{"text":text} 221 | } 222 | r = requests.post( 223 | "http://" + self.host + "/mh/api/v27/post/create.json", 224 | headers = header, 225 | data = json.dumps(payload) 226 | ) 227 | return r.json() 228 | 229 | def getDetail(self, mid): 230 | header = { 231 | "Content-Type": "application/json", 232 | "User-Agent" : self.UA, 233 | "X-Line-Mid" : self.mid, 234 | "x-lct" : self.channel_access_token, 235 | } 236 | 237 | r = requests.get( 238 | "http://" + self.host + "/ma/api/v1/userpopup/getDetail.json?userMid=" + mid, 239 | headers = header 240 | ) 241 | return r.json() 242 | 243 | def getHome(self,mid): 244 | header = { 245 | "Content-Type": "application/json", 246 | "User-Agent" : self.UA, 247 | "X-Line-Mid" : self.mid, 248 | "x-lct" : self.channel_access_token, 249 | } 250 | 251 | r = requests.get( 252 | "http://" + self.host + "/mh/api/v27/post/list.json?homeId=" + mid + "&commentLimit=2&sourceType=LINE_PROFILE_COVER&likeLimit=6", 253 | headers = header 254 | ) 255 | return r.json() 256 | def getCover(self,mid): 257 | h = self.getHome(mid) 258 | objId = h["result"]["homeInfo"]["objectId"] 259 | return "http://dl.profile.line-cdn.net/myhome/c/download.nhn?userid=" + mid + "&oid=" + objId 260 | def createAlbum(self,gid,name): 261 | header = { 262 | "Content-Type": "application/json", 263 | "User-Agent" : self.UA, 264 | "X-Line-Mid" : self.mid, 265 | "x-lct" : self.channel_access_token, 266 | } 267 | payload = { 268 | "type" : "image", 269 | "title" : name 270 | } 271 | r = requests.post( 272 | "http://" + self.host + "/mh/album/v3/album?count=1&auto=0&homeId=" + gid, 273 | headers = header, 274 | data = json.dumps(payload) 275 | ) 276 | return r.json() 277 | 278 | def createAlbum2(self,gid,name,path,oid): 279 | header = { 280 | "Content-Type": "application/json", 281 | "User-Agent" : self.UA, 282 | "X-Line-Mid" : self.mid, 283 | "x-lct" : self.channel_access_token, 284 | } 285 | payload = { 286 | "type" : "image", 287 | "title" : name 288 | } 289 | r = requests.post( 290 | "http://" + self.host + "/mh/album/v3/album?count=1&auto=0&homeId=" + gid, 291 | headers = header, 292 | data = json.dumps(payload) 293 | ) 294 | #albumId = r.json()["result"]["items"][0]["id"] 295 | 296 | 297 | #h = { 298 | # "Content-Type": "application/x-www-form-urlencoded", 299 | # "User-Agent" : self.UA, 300 | # "X-Line-Mid" : gid, 301 | # "X-Line-Album" : albumId, 302 | # "x-lct" : self.channel_access_token, 303 | #"x-obs-host" : "obs-jp.line-apps.com:443", 304 | 305 | #} 306 | #print r.json() 307 | #files = { 308 | # 'file': open(path, 'rb'), 309 | #} 310 | #p = { 311 | # "userid" : gid, 312 | # "type" : "image", 313 | # "oid" : oid, 314 | # "ver" : "1.0" 315 | #} 316 | #data = { 317 | # 'params': json.dumps(p) 318 | #} 319 | #r = requests.post( 320 | #"http://obs-jp.line-apps.com/oa/album/a/object_info.nhn:443", 321 | #headers = h, 322 | #data = data, 323 | #files = files 324 | #) 325 | return r.json() 326 | #cl.createAlbum("cea9d61ba824e937aaf91637991ac934b","ss3ai","kawamuki.png") 327 | -------------------------------------------------------------------------------- /LINETCR/LineApi.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from Api import Poll, Talk, channel 3 | from lib.curve.ttypes import * 4 | from random import randint 5 | import requests,tempfile 6 | import shutil 7 | import json 8 | def def_callback(str): 9 | print(str) 10 | 11 | class LINE: 12 | 13 | mid = None 14 | authToken = None 15 | cert = None 16 | channel_access_token = None 17 | token = None 18 | obs_token = None 19 | refresh_token = None 20 | 21 | 22 | def __init__(self): 23 | self.Talk = Talk() 24 | self._session = requests.session() 25 | 26 | def login(self, mail=None, passwd=None, cert=None, token=None, qr=False, callback=None): 27 | if callback is None: 28 | callback = def_callback 29 | resp = self.__validate(mail,passwd,cert,token,qr) 30 | if resp == 1: 31 | self.Talk.login(mail, passwd, callback=callback) 32 | elif resp == 2: 33 | self.Talk.login(mail,passwd,cert, callback=callback) 34 | elif resp == 3: 35 | self.Talk.TokenLogin(token) 36 | elif resp == 4: 37 | self.Talk.qrLogin(callback) 38 | else: 39 | raise Exception("invalid arguments") 40 | 41 | self.authToken = self.Talk.authToken 42 | self._headers = {'X-Line-Application': 'DESKTOPMAC 10.10.2-YOSEMITE-x64 MAC 4.5.0', 'X-Line-Access': self.authToken, 'User-Agent': 'Line/6.0.0 iPad4,1 9.0.2'} 43 | self.cert = self.Talk.cert 44 | self._headers = { 45 | 'X-Line-Application': 'DESKTOPMAC 10.10.2-YOSEMITE-x64 MAC 4.5.0', 46 | 'X-Line-Access': self.authToken, 47 | 'User-Agent': 'Line/6.0.0 iPad4,1 9.0.2' 48 | } 49 | self.Poll = Poll(self.authToken) 50 | self.channel = channel.Channel(self.authToken) 51 | self.channel.login() 52 | self.mid = self.channel.mid 53 | self.channel_access_token = self.channel.channel_access_token 54 | self.token = self.channel.token 55 | self.obs_token = self.channel.obs_token 56 | self.refresh_token = self.channel.refresh_token 57 | 58 | 59 | """User""" 60 | 61 | def getProfile(self): 62 | return self.Talk.client.getProfile() 63 | 64 | def getSettings(self): 65 | return self.Talk.client.getSettings() 66 | 67 | def getUserTicket(self): 68 | return self.Talk.client.getUserTicket() 69 | 70 | def updateProfile(self, profileObject): 71 | return self.Talk.client.updateProfile(0, profileObject) 72 | 73 | def updateSettings(self, settingObject): 74 | return self.Talk.client.updateSettings(0, settingObject) 75 | 76 | def updateSettings(self, settingObject): 77 | return self.Talk.client.updateSettings(0, settingObject) 78 | 79 | def CloneContactProfile(self, mid): 80 | contact = self.getContact(mid) 81 | profile = self.getProfile() 82 | profile.displayName = contact.displayName 83 | profile.statusMessage = contact.statusMessage 84 | profile.pictureStatus = contact.pictureStatus 85 | self.updateDisplayPicture(profile.pictureStatus) 86 | return self.updateProfile(profile) 87 | 88 | def updateDisplayPicture(self, hash_id): 89 | return self.Talk.client.updateProfileAttribute(0, 8, hash_id) 90 | 91 | """Operation""" 92 | 93 | def fetchOperation(self, revision, count): 94 | return self.Poll.client.fetchOperations(revision, count) 95 | 96 | def fetchOps(self, rev, count): 97 | return self.Poll.client.fetchOps(rev, count, 0, 0) 98 | 99 | def getLastOpRevision(self): 100 | return self.Talk.client.getLastOpRevision() 101 | 102 | def stream(self): 103 | return self.Poll.stream() 104 | 105 | """Message""" 106 | 107 | def sendMessage(self, messageObject): 108 | return self.Talk.client.sendMessage(0,messageObject) 109 | 110 | def sendText(self, Tomid, text): 111 | msg = Message() 112 | msg.to = Tomid 113 | msg.text = text 114 | 115 | return self.Talk.client.sendMessage(0, msg) 116 | def postContent(self, url, data=None, files=None): 117 | return self._session.post(url, headers=self._headers, data=data, files=files) 118 | 119 | def downloadFileURL(self, fileUrl): 120 | saveAs = '%s/linepy-%i.data' % (tempfile.gettempdir(), randint(0, 9)) 121 | r = self.server.getContent(fileUrl) 122 | if r.status_code == 200: 123 | with open(saveAs, 'wb') as f: 124 | shutil.copyfileobj(r.raw, f) 125 | return saveAs 126 | else: 127 | raise Exception('Download file failure.') 128 | 129 | def downloadObjectMsgId(self, messageId): 130 | saveAs = '%s/%s-%i.bin' % (tempfile.gettempdir(), messageId, randint(0, 9)) 131 | params = {'oid': messageId} 132 | url = self.server.urlEncode('https://obs.line-apps.com', '/talk/m/download.nhn', params) 133 | r = self.server.getContent(url) 134 | if r.status_code == 200: 135 | with open(saveAs, 'wb') as f: 136 | shutil.copyfileobj(r.raw, f) 137 | return saveAs 138 | else: 139 | raise Exception('Download file failure.') 140 | 141 | def sendImage(self, to_, path): 142 | M = Message(to=to_, text=None, contentType = 1) 143 | M.contentMetadata = None 144 | M.contentPreview = None 145 | M_id = self.Talk.client.sendMessage(0,M).id 146 | files = { 147 | 'file': open(path, 'rb'), 148 | } 149 | params = { 150 | 'name': 'media', 151 | 'oid': M_id, 152 | 'size': len(open(path, 'rb').read()), 153 | 'type': 'image', 154 | 'ver': '1.0', 155 | } 156 | data = { 157 | 'params': json.dumps(params) 158 | } 159 | 160 | r = self.postContent('https://os.line.naver.jp/talk/m/upload.nhn', data=data, files=files) 161 | print r 162 | if r.status_code != 201: 163 | raise Exception('Upload image failure.') 164 | return True 165 | 166 | def sendImageWithURL(self, to_, url): 167 | """Send a image with given image url 168 | 169 | :param url: image url to send 170 | """ 171 | path = 'tmp/pythonLine.data' 172 | 173 | r = requests.get(url, stream=True) 174 | if r.status_code == 200: 175 | with open(path, 'wb') as f: 176 | shutil.copyfileobj(r.raw, f) 177 | else: 178 | raise Exception('Download image failure.') 179 | 180 | try: 181 | self.sendImage(to_, path) 182 | except Exception as e: 183 | raise e 184 | 185 | def getCover(self,mid): 186 | h = self.getHome(mid) 187 | objId = h["result"]["homeInfo"]["objectId"] 188 | return "http://dl.profile.line-cdn.net/myhome/c/download.nhn?userid=" + mid + "&oid=" + objId 189 | 190 | def sendVideo(self, to, path): 191 | contentMetadata = { 192 | 'VIDLEN' : '60000', 193 | 'DURATION' : '60000' 194 | } 195 | objectId = self.sendMessage(to=to, text=None, contentMetadata=contentMetadata, contentType = 2).id 196 | files = { 197 | 'file': open(path, 'rb') 198 | } 199 | params = { 200 | 'name': 'media', 201 | 'oid': objectId, 202 | 'size': len(open(path, 'rb').read()), 203 | 'type': 'video', 204 | 'ver': '1.0', 205 | } 206 | data = { 207 | 'params': json.dumps(params) 208 | } 209 | r = self.postContent('https://os.line.naver.jp/talk/m/upload.nhn', data=data, files=files) 210 | if r.status_code != 201: 211 | raise Exception('Upload video failure.') 212 | return True 213 | 214 | def sendVideoWithURL(self, to, url): 215 | path = self.downloadFileURL(url) 216 | try: 217 | return self.sendVideo(to, path) 218 | except: 219 | raise Exception('Send video failure.') 220 | 221 | def sendAudio(self, to_, path): 222 | M = Message(to=to_,text=None,contentType=3) 223 | M.contentMetadata = { 224 | } 225 | M.contentPreview = None 226 | M_Id = self.Talk.client.sendMessage(0,M).id 227 | files = { 228 | 'file': open(path, 'rb'), 229 | } 230 | params = { 231 | 'name': 'media', 232 | 'oid': M_Id, 233 | 'size': len(open(path, 'rb').read()), 234 | 'type': 'audio', 235 | 'ver': '1.0', 236 | } 237 | data = { 238 | 'params': json.dumps(params) 239 | } 240 | r = self.postContent('https://os.line.naver.jp/talk/m/upload.nhn', data=data, files=files) 241 | if r.status_code != 201: 242 | raise Exception('Upload audio failure.') 243 | return True 244 | 245 | def sendAudioWithURL(self, to_, url, header=None): 246 | path = '%s/linepy-%i.data' % (tempfile.gettempdir(), randint(0, 9)) 247 | r = requests.get(url, stream=True,headers=header) 248 | if r.status_code == 200: 249 | with open(path, 'wb') as f: 250 | shutil.copyfileobj(r.raw, f) 251 | else: 252 | print r.status_code 253 | raise Exception('Download audio failure.') 254 | try: 255 | self.sendAudio(to_, path) 256 | except Exception as e: 257 | raise e 258 | 259 | def sendFile(self, to, path, file_name=''): 260 | if file_name == '': 261 | import ntpath 262 | file_name = ntpath.basename(path) 263 | file_size = len(open(path, 'rb').read()) 264 | contentMetadata = { 265 | 'FILE_NAME' : str(file_name), 266 | 'FILE_SIZE' : str(file_size) 267 | } 268 | objectId = self.sendMessage(to=to, text=None, contentMetadata=contentMetadata, contentType = 14).id 269 | files = { 270 | 'file': open(path, 'rb'), 271 | } 272 | params = { 273 | 'name': file_name, 274 | 'oid': objectId, 275 | 'size': file_size, 276 | 'type': 'file', 277 | 'ver': '1.0', 278 | } 279 | data = { 280 | 'params': json.dumps(params) 281 | } 282 | r = self.postContent('https://os.line.naver.jp/talk/m/upload.nhn', data=data, files=files) 283 | if r.status_code != 201: 284 | raise Exception('Upload file failure.') 285 | return True 286 | 287 | def sendFileWithURL(self, to, url, fileName=''): 288 | path = self.downloadFileURL(url) 289 | try: 290 | return self.sendFile(to, path, fileName) 291 | except: 292 | raise Exception('Send file failure.') 293 | 294 | def sendEvent(self, messageObject): 295 | return self._client.sendEvent(0, messageObject) 296 | 297 | def sendChatChecked(self, mid, lastMessageId): 298 | return self.Talk.client.sendChatChecked(0, mid, lastMessageId) 299 | 300 | def getMessageBoxCompactWrapUp(self, mid): 301 | return self.Talk.client.getMessageBoxCompactWrapUp(mid) 302 | 303 | def getMessageBoxCompactWrapUpList(self, start, messageBox): 304 | return self.Talk.client.getMessageBoxCompactWrapUpList(start, messageBox) 305 | 306 | def getRecentMessages(self, messageBox, count): 307 | return self.Talk.client.getRecentMessages(messageBox.id, count) 308 | 309 | def getMessageBox(self, channelId, messageboxId, lastMessagesCount): 310 | return self.Talk.client.getMessageBox(channelId, messageboxId, lastMessagesCount) 311 | 312 | def getMessageBoxList(self, channelId, lastMessagesCount): 313 | return self.Talk.client.getMessageBoxList(channelId, lastMessagesCount) 314 | 315 | def getMessageBoxListByStatus(self, channelId, lastMessagesCount, status): 316 | return self.Talk.client.getMessageBoxListByStatus(channelId, lastMessagesCount, status) 317 | 318 | def getMessageBoxWrapUp(self, mid): 319 | return self.Talk.client.getMessageBoxWrapUp(mid) 320 | 321 | def getMessageBoxWrapUpList(self, start, messageBoxCount): 322 | return self.Talk.client.getMessageBoxWrapUpList(start, messageBoxCount) 323 | 324 | """Contact""" 325 | 326 | 327 | def blockContact(self, mid): 328 | return self.Talk.client.blockContact(0, mid) 329 | 330 | 331 | def unblockContact(self, mid): 332 | return self.Talk.client.unblockContact(0, mid) 333 | 334 | 335 | def findAndAddContactsByMid(self, mid): 336 | return self.Talk.client.findAndAddContactsByMid(0, mid) 337 | 338 | 339 | def findAndAddContactsByMids(self, midlist): 340 | for i in midlist: 341 | self.Talk.client.findAndAddContactsByMid(0, i) 342 | 343 | def findAndAddContactsByUserid(self, userid): 344 | return self.Talk.client.findAndAddContactsByUserid(0, userid) 345 | 346 | def findContactsByUserid(self, userid): 347 | return self.Talk.client.findContactByUserid(userid) 348 | 349 | def findContactByTicket(self, ticketId): 350 | return self.Talk.client.findContactByUserTicket(ticketId) 351 | 352 | def getAllContactIds(self): 353 | return self.Talk.client.getAllContactIds() 354 | 355 | def getBlockedContactIds(self): 356 | return self.Talk.client.getBlockedContactIds() 357 | 358 | def getContact(self, mid): 359 | return self.Talk.client.getContact(mid) 360 | 361 | def getContacts(self, midlist): 362 | return self.Talk.client.getContacts(midlist) 363 | 364 | def getFavoriteMids(self): 365 | return self.Talk.client.getFavoriteMids() 366 | 367 | def getHiddenContactMids(self): 368 | return self.Talk.client.getHiddenContactMids() 369 | 370 | 371 | """Group""" 372 | 373 | def findGroupByTicket(self, ticketId): 374 | return self.Talk.client.findGroupByTicket(ticketId) 375 | 376 | def acceptGroupInvitation(self, groupId): 377 | return self.Talk.client.acceptGroupInvitation(0, groupId) 378 | 379 | def acceptGroupInvitationByTicket(self, groupId, ticketId): 380 | return self.Talk.client.acceptGroupInvitationByTicket(0, groupId, ticketId) 381 | 382 | def cancelGroupInvitation(self, groupId, contactIds): 383 | return self.Talk.client.cancelGroupInvitation(0, groupId, contactIds) 384 | 385 | def createGroup(self, name, midlist): 386 | return self.Talk.client.createGroup(0, name, midlist) 387 | 388 | def getGroup(self, groupId): 389 | return self.Talk.client.getGroup(groupId) 390 | 391 | def getGroups(self, groupIds): 392 | return self.Talk.client.getGroups(groupIds) 393 | 394 | def getGroupIdsInvited(self): 395 | return self.Talk.client.getGroupIdsInvited() 396 | 397 | def getGroupIdsJoined(self): 398 | return self.Talk.client.getGroupIdsJoined() 399 | 400 | def inviteIntoGroup(self, groupId, midlist): 401 | return self.Talk.client.inviteIntoGroup(0, groupId, midlist) 402 | 403 | def kickoutFromGroup(self, groupId, midlist): 404 | return self.Talk.client.kickoutFromGroup(0, groupId, midlist) 405 | 406 | def leaveGroup(self, groupId): 407 | return self.Talk.client.leaveGroup(0, groupId) 408 | 409 | def rejectGroupInvitation(self, groupId): 410 | return self.Talk.client.rejectGroupInvitation(0, groupId) 411 | 412 | def reissueGroupTicket(self, groupId): 413 | return self.Talk.client.reissueGroupTicket(groupId) 414 | 415 | def updateGroup(self, groupObject): 416 | return self.Talk.client.updateGroup(0, groupObject) 417 | def findGroupByTicket(self,ticketId): 418 | return self.Talk.client.findGroupByTicket(0,ticketId) 419 | 420 | """Room""" 421 | 422 | def createRoom(self, midlist): 423 | return self.Talk.client.createRoom(0, midlist) 424 | 425 | def getRoom(self, roomId): 426 | return self.Talk.client.getRoom(roomId) 427 | 428 | def inviteIntoRoom(self, roomId, midlist): 429 | return self.Talk.client.inviteIntoRoom(0, roomId, midlist) 430 | 431 | def leaveRoom(self, roomId): 432 | return self.Talk.client.leaveRoom(0, roomId) 433 | 434 | """TIMELINE""" 435 | 436 | def new_post(self, text): 437 | return self.channel.new_post(text) 438 | 439 | def like(self, mid, postid, likeType=1001): 440 | return self.channel.like(mid, postid, likeType) 441 | 442 | def comment(self, mid, postid, text): 443 | return self.channel.comment(mid, postid, text) 444 | 445 | def activity(self, limit=20): 446 | return self.channel.activity(limit) 447 | 448 | def getAlbum(self, gid): 449 | 450 | return self.channel.getAlbum(gid) 451 | def changeAlbumName(self, gid, name, albumId): 452 | return self.channel.changeAlbumName(gid, name, albumId) 453 | 454 | def deleteAlbum(self, gid, albumId): 455 | return self.channel.deleteAlbum(gid,albumId) 456 | 457 | def getNote(self,gid, commentLimit, likeLimit): 458 | return self.channel.getNote(gid, commentLimit, likeLimit) 459 | 460 | def getDetail(self,mid): 461 | return self.channel.getDetail(mid) 462 | 463 | def getHome(self,mid): 464 | return self.channel.getHome(mid) 465 | 466 | def createAlbum(self, gid, name): 467 | return self.channel.createAlbum(gid,name) 468 | 469 | def createAlbum2(self, gid, name, path): 470 | return self.channel.createAlbum(gid, name, path, oid) 471 | 472 | """Personalize""" 473 | 474 | def cloneContactProfile(self, mid): 475 | contact = self.getContact(mid) 476 | profile = self.getProfile() 477 | profile.displayName = contact.displayName 478 | profile.statusMessage = contact.statusMessage 479 | profile.pictureStatus = contact.pictureStatus 480 | self.updateDisplayPicture(profile.pictureStatus) 481 | return self.updateProfile(profile) 482 | 483 | def updateDisplayPicture(self, hash_id): 484 | return self.Talk.client.updateProfileAttribute(0, 8, hash_id) 485 | 486 | 487 | def __validate(self, mail, passwd, cert, token, qr): 488 | if mail is not None and passwd is not None and cert is None: 489 | return 1 490 | elif mail is not None and passwd is not None and cert is not None: 491 | return 2 492 | elif token is not None: 493 | return 3 494 | elif qr is True: 495 | return 4 496 | else: 497 | return 5 498 | 499 | def loginResult(self, callback=None): 500 | if callback is None: 501 | callback = def_callback 502 | 503 | prof = self.getProfile() 504 | 505 | print("Ard Bot") 506 | print("mid -> " + prof.mid) 507 | print("name -> " + prof.displayName) 508 | print("authToken -> " + self.authToken) 509 | print("cert -> " + self.cert if self.cert is not None else "") 510 | -------------------------------------------------------------------------------- /LINETCR/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from LineApi import LINE 3 | from lib.curve.ttypes import * 4 | -------------------------------------------------------------------------------- /LINETCR/lib/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /LINETCR/lib/curve/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['ttypes', 'constants', 'LineService'] 2 | -------------------------------------------------------------------------------- /LINETCR/lib/curve/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.9.3) 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, TException, TApplicationException 10 | from ttypes import * 11 | 12 | -------------------------------------------------------------------------------- /LINETCR/server.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import re, json, requests, urllib 3 | 4 | class LineServer(object): 5 | LINE_HOST_DOMAIN = 'https://gd2.line.naver.jp' 6 | LINE_OBS_DOMAIN = 'https://obs-sg.line-apps.com' 7 | LINE_TIMELINE_API = 'https://gd2.line.naver.jp/mh/api' 8 | 9 | LINE_AUTH_QUERY_PATH = '/api/v4/TalkService.do' 10 | 11 | LINE_API_QUERY_PATH_FIR = '/S4' 12 | LINE_POLL_QUERY_PATH_FIR = '/P4' 13 | LINE_CALL_QUERY_PATH = '/V4' 14 | LINE_CERTIFICATE_PATH = '/Q' 15 | LINE_CHAN_QUERY_PATH = '/CH4' 16 | 17 | USER_AGENT = 'Line/5.3.3' 18 | APP_NAME = 'DESKTOPMAC\t5.3.3-YOSEMITE-x64\tMAC\t10.12.0' 19 | PHONE_NAME = 'IOS\t7.13.1\tiPhone OS\t10.12.0' 20 | CARRIER = '1-0' 21 | SYSTEM_NAME = 'FDLRCN' 22 | IP_ADDR = '8.8.8.8' 23 | EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+") 24 | 25 | _session = requests.session() 26 | channelHeaders = {} 27 | Headers = {} 28 | 29 | def __init__(self): 30 | self.Headers = {} 31 | self.channelHeaders = {} 32 | 33 | def parseUrl(self, path): 34 | return self.LINE_HOST_DOMAIN + path 35 | 36 | def urlEncode(self, url, path, params=[]): 37 | try: # Works with python 2.x 38 | return url + path + '?' + urllib.urlencode(params) 39 | except: # Works with python 3.x 40 | return url + path + '?' + urllib.parse.urlencode(params) 41 | 42 | def getJson(self, url, allowHeader=False): 43 | if allowHeader is False: 44 | return json.loads(self._session.get(url).text) 45 | else: 46 | return json.loads(self._session.get(url, headers=self.Headers).text) 47 | 48 | def setHeaders(self, argument, value): 49 | self.Headers[argument] = value 50 | 51 | def setChannelHeaders(self, argument, value): 52 | self.channelHeaders[argument] = value 53 | 54 | def postContent(self, url, data=None, files=None, headers=None): 55 | if headers is None: 56 | headers=self.Headers 57 | return self._session.post(url, headers=headers, data=data, files=files) 58 | 59 | def getContent(self, url, headers=None): 60 | if headers is None: 61 | headers=self.Headers 62 | return self._session.get(url, headers=headers, stream=True) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Line-TCR 2 | Line Bot TCR fixed, 1 bot utama & 3 bot assists. 3 | 4 | Requirements: 5 | - 4 Line Clone untuk bot 6 | - 1 Line utama untuk admin/command 7 | 8 | Cara Run bot tanpa pc atau di Android : 9 | - (Download Termux & Install) 10 | - pkg install python2 11 | - pip2 install rsa 12 | - pip2 install requests 13 | - pip2 install thrift==0.9.3 14 | - pkg install git 15 | - pkg install nano 16 | - git clone https://github.com/fajrinard/Line-TCR 17 | - cd Line-TCR 18 | - nano line-tcr.py 19 | - (isi admin=["YOUR_MID"], ganti kata YOUR_MID dengan mid akun utama yang ingin dijadikan admin) (biarkan tanda kutipnya) 20 | - (lalu save; ctrl X + Y + enter) (gunakan Hacker's Keyboard, download di playstore) 21 | - python2 line-tcr.py 22 | - (login link/qr ke akun bot) 23 | - Selesai 24 | 25 | 26 | Thanks to : 27 | - Allah SWT 28 | - merkremont 29 | - AlfathDirk 30 | - team TCR 31 | - dan para mastah/programmer lainnya 32 | 33 | #ArdSquadBot 34 | -------------------------------------------------------------------------------- /line-tcr.py: -------------------------------------------------------------------------------- 1 | import LINETCR 2 | from LINETCR.lib.curve.ttypes import * 3 | from LINETCR import server 4 | from datetime import datetime 5 | import time,random,sys,json,codecs,threading,glob,requests,urllib 6 | import re,string,os,shutil,urllib2,urllib3,subprocess 7 | from urllib import urlopen 8 | import requests,tempfile 9 | 10 | cl = LINETCR.LINE() 11 | cl.login(qr=True) 12 | cl.loginResult() 13 | 14 | ki = LINETCR.LINE() 15 | ki.login(qr=True) 16 | ki.loginResult() 17 | 18 | kk = LINETCR.LINE() 19 | kk.login(qr=True) 20 | kk.loginResult() 21 | 22 | kc = LINETCR.LINE() 23 | kc.login(qr=True) 24 | kc.loginResult() 25 | 26 | print "login success" 27 | reload(sys) 28 | sys.setdefaultencoding('utf-8') 29 | 30 | helpMessage =""" - Ard Squad bot - 31 | 32 | General command : 33 | Me = Cek akun sendiri 34 | My mid = Cek akun Mid 35 | Mid @ = Cek mid via tag 36 | Bot? = Cek akun Bot 37 | Ginfo = Group info 38 | Id Group = Melihat id grup 39 | Group pict = Melihat pict grup 40 | Speedbot = Cek kecepatan bot 41 | Up = Fungsi spam chat 42 | Tagall = Mention semua user 43 | Cek = Membuat set point 44 | Sider = Melihat sider dibawah read point 45 | Apakah ... = Menanyakan jawaban ya atau tidak 46 | Creator = Melihat kontak pembuat bot 47 | 48 | private command : 49 | Set group = Melihat private menu""" 50 | 51 | Setgroup =""" Private Menu 􀔃􀄆red check mark􏿿 52 | 53 | [Protect Group] 54 | -- Gr on/off 55 | [Mid Via Contact] 56 | -- Contact on/off 57 | [Cancel All Invited] 58 | -- Cancl on/off 59 | [No Joinned] 60 | -- Joinn on/off 61 | 62 | 􀔃􀅕red arrow right􏿿 Command Private 63 | [Set View] = Melihat proteksi bot 64 | [Get ready] = Cek respon bot 65 | [Gn namagroup] = Ganti nama grup 66 | [Open url] = Membuka url grup 67 | [Gurl] = Membuka dan mengirim url grup 68 | [Close url] = Menutup url grup 69 | [Cancel] = Cancel user masuk grup 70 | [Staff add @] = Menambah user admin 71 | [Staff remove @] = Menghapus user dari admin 72 | [Stafflist] = Melihat daftar admin 73 | [Ban @] = Ban target with mention 74 | [Ban] = Ban target with send contact 75 | [Unban @] = Unban target with mention 76 | [Unban] = Unban target with send contact 77 | [Banlist] = Melihat daftar akun ter-banned 78 | [Kill @] = Kick target banned 79 | [Nk @] = Kick target user 80 | [List group] = Melihat daftar grup pada bot 81 | [Group id] = Melihat daftar id grup pada bot 82 | [Invite mid] = Invite via mid 83 | [inv: (gid)] = Invite admin ke group id yang dituju 84 | [Kick mid] = Kick via mid 85 | [Ard Squad join] = Invite semua bot 86 | [Bye bots] = Mengeluarkan semua bots assist 87 | [Bye Ard] = Mengeluarkan bot utama 88 | [Ard out] = Mengeluarkan bot utama dari semua grup 89 | [Bc ...] = Untuk broadcast ke semua grup 90 | [Kernel] = Melihat kernel bot""" 91 | KAC=[cl,ki,kk,kc] 92 | DEF=[ki,kk,kc] 93 | mid = cl.getProfile().mid 94 | Amid = ki.getProfile().mid 95 | Bmid = kk.getProfile().mid 96 | Cmid = kc.getProfile().mid 97 | 98 | Bots=[mid,Amid,Bmid,Cmid,"YOUR_MID"] 99 | admin=["YOUR_MID"] 100 | admsa=["YOUR_MID"] 101 | wait = { 102 | 'contact':False, 103 | 'autoJoin':True, 104 | 'autoCancel':{"on":True,"members":1}, 105 | 'leaveRoom':True, 106 | 'timeline':False, 107 | 'autoAdd':True, 108 | 'message':"Thanks for adding me\nFollow my instagram; instagram.com/fajrinard", 109 | "lang":"JP", 110 | "comment":"Thanks for add me", 111 | "commentOn":True, 112 | "commentBlack":{}, 113 | "wblack":False, 114 | "dblack":False, 115 | "clock":False, 116 | "cName":"Ard", 117 | "cName2":"Ard 1", 118 | "cName3":"Ard 2", 119 | "cName4":"Ard 3", 120 | "blacklist":{}, 121 | "wblacklist":False, 122 | "dblacklist":False, 123 | "Protectgr":True, 124 | "Protectjoin":False, 125 | "Protectcancl":False, 126 | "protectionOn":True, 127 | "atjointicket":True, 128 | } 129 | 130 | wait2 = { 131 | 'readPoint':{}, 132 | 'readMember':{}, 133 | 'setTime':{}, 134 | 'ROM':{} 135 | } 136 | 137 | setTime = {} 138 | setTime = wait2['setTime'] 139 | 140 | 141 | def sendMessage(to, text, contentMetadata={}, contentType=0): 142 | mes = Message() 143 | mes.to, mes.from_ = to, profile.mid 144 | mes.text = text 145 | mes.contentType, mes.contentMetadata = contentType, contentMetadata 146 | if to not in messageReq: 147 | messageReq[to] = -1 148 | messageReq[to] += 1 149 | 150 | def NOTIFIED_READ_MESSAGE(op): 151 | try: 152 | if op.param1 in wait2['readPoint']: 153 | Name = cl.getContact(op.param2).displayName 154 | if Name in wait2['readMember'][op.param1]: 155 | pass 156 | else: 157 | wait2['readMember'][op.param1] += "\n・" + Name 158 | wait2['ROM'][op.param1][op.param2] = "\n・" + Name 159 | else: 160 | pass 161 | except: 162 | pass 163 | 164 | def RECEIVE_MESSAGE(op): 165 | msg = op.message 166 | try: 167 | if msg.contentType == 0: 168 | try: 169 | if msg.to in wait['readPoint']: 170 | if msg.from_ in wait["ROM"][msg.to]: 171 | del wait["ROM"][msg.to][msg.from_] 172 | else: 173 | pass 174 | except: 175 | pass 176 | else: 177 | pass 178 | except KeyboardInterrupt: 179 | sys.exit(0) 180 | except Exception as error: 181 | print error 182 | print ("\n\nRECEIVE_MESSAGE\n\n") 183 | return 184 | 185 | def bot(op): 186 | try: 187 | if op.type == 0: 188 | return 189 | if op.type == 5: 190 | if wait["autoAdd"] == True: 191 | cl.findAndAddContactsByMid(op.param1) 192 | if (wait["message"] in [""," ","\n",None]): 193 | pass 194 | else: 195 | cl.sendText(op.param1,str(wait["message"])) 196 | 197 | if op.type == 32: 198 | if wait["Protectgr"] == True: 199 | if op.param2 not in Bots + admin: 200 | ki.findAndAddContactByMid(op.param3) 201 | ki.inviteIntoGroup(op.param1,[op.param3]) 202 | ki.kickoutFromGroup(op.param1,[op.param2]) 203 | else: 204 | pass 205 | 206 | #------Protect Group Kick start------# 207 | if op.type == 11: 208 | if wait["Protectgr"] == True: 209 | if ki.getGroup(op.param1).preventJoinByTicket == False: 210 | if op.param2 in Bots: 211 | pass 212 | if op.param2 in admin: 213 | pass 214 | else: 215 | ki.kickoutFromGroup(op.param1,[op.param2]) 216 | wait["blacklist"][op.param2] = True 217 | ki.reissueGroupTicket(op.param1) 218 | X = ki.getGroup(op.param1) 219 | X.preventJoinByTicket = True 220 | ki.updateGroup(X) 221 | print "Url Opened, Autokick on" 222 | else: 223 | print "random group update" 224 | else: 225 | pass 226 | #------Protect Group Kick finish-----# 227 | 228 | #------Cancel Invite User start------# 229 | #------Cancel Invite User Finish------# 230 | 231 | if op.type == 13: 232 | if wait["Protectcancl"] == True: 233 | try: 234 | X = ki.getGroup(op.param1) 235 | gInviMids = [contact.mid for contact in X.invitee] 236 | ki.cancelGroupInvitation(op.param1, gInviMids) 237 | print "invite canceled" 238 | except: 239 | try: 240 | print "Retry canceling invitation" 241 | X = kk.getGroup(op.param1) 242 | gInviMids = [contact.mid for contact in X.invitee] 243 | kk.cancelGroupInvitation(op.param1, gInviMids) 244 | print "invite canceled" 245 | except: 246 | print "Bot can't cancel the invitation" 247 | 248 | if op.type == 13: 249 | if mid in op.param3: 250 | if wait["autoJoin"] == True: 251 | cl.acceptGroupInvitation(op.param1) 252 | print "BOT 1 Joined" 253 | else: 254 | print "autoJoin is Off" 255 | else: 256 | pass 257 | 258 | if op.type == 13: 259 | if op.param3 in mid: 260 | if op.param2 in Amid: 261 | G = Amid.getGroup(op.param1) 262 | G.preventJoinByTicket = False 263 | Amid.updateGroup(G) 264 | Ticket = Amid.reissueGroupTicket(op.param1) 265 | cl.acceptGroupInvitationByTicket(op.param1,Ticket) 266 | G.preventJoinByTicket = True 267 | Amid.updateGroup(G) 268 | Ticket = Amid.reissueGroupTicket(op.param1) 269 | 270 | if op.param3 in Amid: 271 | if op.param2 in mid: 272 | X = cl.getGroup(op.param1) 273 | X.preventJoinByTicket = False 274 | cl.updateGroup(X) 275 | Ti = cl.reissueGroupTicket(op.param1) 276 | ki.acceptGroupInvitationByTicket(op.param1,Ti) 277 | X.preventJoinByTicket = True 278 | ki.updateGroup(X) 279 | Ti = ki.reissueGroupTicket(op.param1) 280 | 281 | if op.param3 in Bmid: 282 | if op.param2 in Amid: 283 | X = ki.getGroup(op.param1) 284 | X.preventJoinByTicket = False 285 | ki.updateGroup(X) 286 | Ti = ki.reissueGroupTicket(op.param1) 287 | kk.acceptGroupInvitationByTicket(op.param1,Ti) 288 | X.preventJoinByTicket = True 289 | kk.updateGroup(X) 290 | Ti = kk.reissueGroupTicket(op.param1) 291 | 292 | if op.param3 in Cmid: 293 | if op.param2 in Bmid: 294 | X = kk.getGroup(op.param1) 295 | X.preventJoinByTicket = False 296 | kk.updateGroup(X) 297 | Ti = kk.reissueGroupTicket(op.param1) 298 | kc.acceptGroupInvitationByTicket(op.param1,Ti) 299 | X.preventJoinByTicket = True 300 | kc.updateGroup(X) 301 | Ti = kc.reissueGroupTicket(op.param1) 302 | 303 | if op.param3 in Dmid: 304 | if op.param2 in Cmid: 305 | X = kc.getGroup(op.param1) 306 | X.preventJoinByTicket = False 307 | kc.updateGroup(X) 308 | Ti = kc.reissueGroupTicket(op.param1) 309 | ks.acceptGroupInvitationByTicket(op.param1,Ti) 310 | X.preventJoinByTicket = True 311 | ks.updateGroup(X) 312 | Ti = ks.reissueGroupTicket(op.param1) 313 | 314 | if op.param3 in Emid: 315 | if op.param2 in Dmid: 316 | X = ks.getGroup(op.param1) 317 | X.preventJoinByTicket = False 318 | ks.updateGroup(X) 319 | Ti = ks.reissueGroupTicket(op.param1) 320 | ka.acceptGroupInvitationByTicket(op.param1,Ti) 321 | X.preventJoinByTicket = True 322 | ka.updateGroup(X) 323 | Ti = ka.reissueGroupTicket(op.param1) 324 | 325 | if op.param3 in Fmid: 326 | if op.param2 in Emid: 327 | X = ka.getGroup(op.param1) 328 | X.preventJoinByTicket = False 329 | ka.updateGroup(X) 330 | Ti = ka.reissueGroupTicket(op.param1) 331 | kb.acceptGroupInvitationByTicket(op.param1,Ti) 332 | X.preventJoinByTicket = True 333 | kb.updateGroup(X) 334 | Ti = kb.reissueGroupTicket(op.param1) 335 | 336 | if op.param3 in Gmid: 337 | if op.param2 in Fmid: 338 | X = kb.getGroup(op.param1) 339 | X.preventJoinByTicket = False 340 | kb.updateGroup(X) 341 | Ti = kb.reissueGroupTicket(op.param1) 342 | ko.acceptGroupInvitationByTicket(op.param1,Ti) 343 | X.preventJoinByTicket = True 344 | ko.updateGroup(X) 345 | Ti = ko.reissueGroupTicket(op.param1) 346 | 347 | if op.param3 in Hmid: 348 | if op.param2 in Gmid: 349 | X = ko.getGroup(op.param1) 350 | X.preventJoinByTicket = False 351 | ko.updateGroup(X) 352 | Ti = ko.reissueGroupTicket(op.param1) 353 | ke.acceptGroupInvitationByTicket(op.param1,Ti) 354 | X.preventJoinByTicket = True 355 | ke.updateGroup(X) 356 | Ti = ke.reissueGroupTicket(op.param1) 357 | 358 | if op.param3 in Imid: 359 | if op.param2 in mid: 360 | X = cl.getGroup(op.param1) 361 | X.preventJoinByTicket = False 362 | cl.updateGroup(X) 363 | Ti = cl.reissueGroupTicket(op.param1) 364 | ku.acceptGroupInvitationByTicket(op.param1,Ti) 365 | X.preventJoinByTicket = True 366 | cl.updateGroup(X) 367 | Ti = cl.reissueGroupTicket(op.param1) 368 | 369 | if op.type == 15: 370 | group = cl.getGroup(op.param1) 371 | cb = Message() 372 | cb.to = op.param1 373 | cb.text = "Good bye " + cl.getContact(op.param2).displayName 374 | cl.sendMessage(cb) 375 | print op.param2 + "has left the group" 376 | 377 | #------Joined User Kick start------# 378 | if op.type == 17: 379 | if op.param2 in wait["blacklist"]: 380 | try: 381 | ki.kickoutFromGroup(op.param1, op.param2) 382 | except: 383 | random.choice(KAC).kickoutFromGroup(op.param1, op.param2) 384 | 385 | if op.type == 17: 386 | if wait["Protectjoin"] == True: 387 | if op.param2 not in Bots: 388 | random.choice(DEF).kickoutFromGroup(op.param1,[op.param2]) 389 | #------Joined User Kick start------# 390 | 391 | if op.type == 17: 392 | group = cl.getGroup(op.param1) 393 | cb = Message() 394 | cb.to = op.param1 395 | cb.text = "Hi " + cl.getContact(op.param2).displayName + ", welcome to " + group.name 396 | cl.sendMessage(cb) 397 | 398 | if op.type == 19: 399 | print "someone was kicked" 400 | if op.param3 in admin: 401 | print "Admin has been kicked" 402 | if op.param2 in Bots: 403 | pass 404 | if op.param2 in admsa: 405 | pass 406 | else: 407 | cl.kickoutFromGroup(op.param1,[op.param2]) 408 | wait["blacklist"][op.param2] = True 409 | print "kicker kicked" 410 | try: 411 | cl.inviteIntoGroup(op.param1,admin) 412 | except: 413 | cl.inviteIntoGroup(op.param1,admin) 414 | print "Admin invited back" 415 | 416 | if mid in op.param3: 417 | print "BOT1 has been kicked" 418 | if op.param2 in Bots: 419 | pass 420 | if op.param2 in admin: 421 | pass 422 | else: 423 | ki.kickoutFromGroup(op.param1,[op.param2]) 424 | wait["blacklist"][op.param2] = True 425 | print "kicker kicked" 426 | G = random.choice(KAC).getGroup(op.param1) 427 | G.preventJoinByTicket = False 428 | ki.updateGroup(G) 429 | Ti = ki.reissueGroupTicket(op.param1) 430 | cl.acceptGroupInvitationByTicket(op.param1,Ti) 431 | X = ki.getGroup(op.param1) 432 | X.preventJoinByTicket = True 433 | ki.updateGroup(X) 434 | Ti = ki.reissueGroupTicket(op.param1) 435 | print "BOT1 Joined" 436 | 437 | if Amid in op.param3: 438 | print "BOT2 has been kicked" 439 | if op.param2 in Bots: 440 | pass 441 | if op.param2 in admin: 442 | pass 443 | else: 444 | cl.kickoutFromGroup(op.param1,[op.param2]) 445 | wait["blacklist"][op.param2] = True 446 | print "kicker kicked" 447 | G = random.choice(KAC).getGroup(op.param1) 448 | G.preventJoinByTicket = False 449 | cl.updateGroup(G) 450 | Ti = cl.reissueGroupTicket(op.param1) 451 | ki.acceptGroupInvitationByTicket(op.param1,Ti) 452 | X = cl.getGroup(op.param1) 453 | X.preventJoinByTicket = True 454 | cl.updateGroup(X) 455 | Ti = cl.reissueGroupTicket(op.param1) 456 | print "BOT2 Joined" 457 | 458 | if Bmid in op.param3: 459 | print "BOT3 has been kicked" 460 | if op.param2 in Bots: 461 | pass 462 | if op.param2 in admin: 463 | pass 464 | else: 465 | cl.kickoutFromGroup(op.param1,[op.param2]) 466 | wait["blacklist"][op.param2] = True 467 | print "kicker kicked" 468 | G = random.choice(KAC).getGroup(op.param1) 469 | G.preventJoinByTicket = False 470 | cl.updateGroup(G) 471 | Ti = cl.reissueGroupTicket(op.param1) 472 | kk.acceptGroupInvitationByTicket(op.param1,Ti) 473 | X = cl.getGroup(op.param1) 474 | X.preventJoinByTicket = True 475 | cl.updateGroup(X) 476 | Ti = cl.reissueGroupTicket(op.param1) 477 | print "BOT3 Joined" 478 | 479 | if Cmid in op.param3: 480 | print "BOT4 has been kicked" 481 | if op.param2 in Bots: 482 | pass 483 | if op.param2 in admin: 484 | pass 485 | else: 486 | cl.kickoutFromGroup(op.param1,[op.param2]) 487 | wait["blacklist"][op.param2] = True 488 | print "kicker kicked" 489 | G = random.choice(KAC).getGroup(op.param1) 490 | G.preventJoinByTicket = False 491 | cl.updateGroup(G) 492 | Ti = cl.reissueGroupTicket(op.param1) 493 | kc.acceptGroupInvitationByTicket(op.param1,Ti) 494 | X = cl.getGroup(op.param1) 495 | X.preventJoinByTicket = True 496 | cl.updateGroup(X) 497 | Ti = cl.reissueGroupTicket(op.param1) 498 | print "BOT4 Joined" 499 | 500 | else: 501 | if wait["Protectgr"] == True: 502 | if op.param2 in Bots + admin: 503 | pass 504 | else: 505 | ki.kickoutFromGroup(op.param1,[op.param2]) 506 | kk.kickoutFromGroup(op.param1,[op.param2]) 507 | kc.kickoutFromGroup(op.param1,[op.param2]) 508 | wait["blacklist"][op.param2] = True 509 | print "autokick executed" 510 | 511 | if op.type == 22: 512 | if wait["leaveRoom"] == True: 513 | cl.leaveRoom(op.param1) 514 | if op.type == 24: 515 | if wait["leaveRoom"] == True: 516 | cl.leaveRoom(op.param1) 517 | if op.type == 26: 518 | msg = op.message 519 | if msg.toType == 0: 520 | msg.to = msg.from_ 521 | if msg.from_ == "ue11fc7860247c63bd3da149613a793f6": 522 | if "join:" in msg.text: 523 | list_ = msg.text.split(":") 524 | try: 525 | cl.acceptGroupInvitationByTicket(list_[1],list_[2]) 526 | G = cl.getGroup(list_[1]) 527 | G.preventJoinByTicket = True 528 | cl.updateGroup(G) 529 | except: 530 | cl.sendText(msg.to,"error") 531 | if op.type == 26: 532 | msg = op.message 533 | if msg.toType == 1: 534 | if wait["leaveRoom"] == True: 535 | cl.leaveRoom(msg.to) 536 | if msg.contentType == 16: 537 | url = msg.contentMetadata("line://home/post?userMid="+mid+"&postId="+"new_post") 538 | cl.like(url[25:58], url[66:], likeType=1001) 539 | if op.type == 26: 540 | msg = op.message 541 | if msg.contentType == 13: 542 | if wait["wblack"] == True: 543 | if msg.contentMetadata["mid"] in wait["commentBlack"]: 544 | cl.sendText(msg.to,"Already in blacklist") 545 | wait["wblack"] = False 546 | else: 547 | wait["commentBlack"][msg.contentMetadata["mid"]] = True 548 | wait["wblack"] = False 549 | cl.sendText(msg.to,"Decided not to comment.") 550 | 551 | elif wait["dblack"] == True: 552 | if msg.contentMetadata["mid"] in wait["commentBlack"]: 553 | del wait["commentBlack"][msg.contentMetadata["mid"]] 554 | cl.sendText(msg.to,"Removed from blacklist.") 555 | wait["dblack"] = False 556 | 557 | else: 558 | wait["dblack"] = False 559 | cl.sendText(msg.to,"There's no target in blacklist.") 560 | elif wait["wblacklist"] == True: 561 | if msg.contentMetadata["mid"] in wait["blacklist"]: 562 | cl.sendText(msg.to,"Already in blacklist") 563 | wait["wblacklist"] = False 564 | else: 565 | wait["blacklist"][msg.contentMetadata["mid"]] = True 566 | wait["wblacklist"] = False 567 | cl.sendText(msg.to,"Added to blacklist.") 568 | 569 | elif wait["dblacklist"] == True: 570 | if msg.contentMetadata["mid"] in wait["blacklist"]: 571 | del wait["blacklist"][msg.contentMetadata["mid"]] 572 | cl.sendText(msg.to,"Removed from blacklist.") 573 | wait["dblacklist"] = False 574 | 575 | else: 576 | wait["dblacklist"] = False 577 | cl.sendText(msg.to,"There's no target in blacklist.") 578 | elif wait["contact"] == True: 579 | msg.contentType = 0 580 | cl.sendText(msg.to,msg.contentMetadata["mid"]) 581 | if 'displayName' in msg.contentMetadata: 582 | contact = cl.getContact(msg.contentMetadata["mid"]) 583 | try: 584 | cu = cl.channel.getCover(msg.contentMetadata["mid"]) 585 | except: 586 | cu = "" 587 | cl.sendText(msg.to,"display name : " + msg.contentMetadata["displayName"] + "\n\nmid : " + msg.contentMetadata["mid"] + "\n\nstatus message : " + contact.statusMessage + "\n\ndisplay picture : http://dl.profile.line-cdn.net/" + contact.pictureStatus + "\n\ncover URL : " + str(cu)) 588 | else: 589 | contact = cl.getContact(msg.contentMetadata["mid"]) 590 | try: 591 | cu = cl.channel.getCover(msg.contentMetadata["mid"]) 592 | except: 593 | cu = "" 594 | cl.sendText(msg.to,"display name : " + msg.contentMetadata["displayName"] + "\n\nmid : " + msg.contentMetadata["mid"] + "\n\nstatus message : " + contact.statusMessage + "\n\ndisplay picture : http://dl.profile.line-cdn.net/" + contact.pictureStatus + "\n\ncover URL : " + str(cu)) 595 | elif msg.contentType == 16: 596 | if wait["timeline"] == True: 597 | msg.contentType = 0 598 | msg.text = "post URL\n" + msg.contentMetadata["postEndUrl"] 599 | cl.sendMessage(msg) 600 | elif msg.text is None: 601 | return 602 | elif msg.text.lower() == 'help': 603 | if wait["lang"] == "JP": 604 | cl.sendText(msg.to,helpMessage) 605 | else: 606 | cl.sendText(msg.to,helpt) 607 | elif msg.text.lower() == 'set group': 608 | if msg.from_ in admin: 609 | if wait["lang"] == "JP": 610 | cl.sendText(msg.to,Setgroup) 611 | else: 612 | cl.sendText(msg.to,Sett) 613 | else: 614 | cl.sendText(msg.to,"Command denied.") 615 | cl.sendText(msg.to,"Admin permission required.") 616 | elif ("Gn " in msg.text): 617 | if msg.from_ in admin: 618 | if msg.toType == 2: 619 | X = cl.getGroup(msg.to) 620 | X.name = msg.text.replace("Gn ","") 621 | cl.updateGroup(X) 622 | else: 623 | cl.sendText(msg.to,"It can't be used besides the group.") 624 | elif "Kick " in msg.text: 625 | if msg.from_ in admin: 626 | midd = msg.text.replace("Kick ","") 627 | cl.kickoutFromGroup(msg.to,[midd]) 628 | elif "Invite " in msg.text: 629 | if msg.from_ in admin: 630 | midd = msg.text.replace("Invite ","") 631 | cl.findAndAddContactsByMid(midd) 632 | cl.inviteIntoGroup(msg.to,[midd]) 633 | elif "inv: " in msg.text: 634 | if msg.from_ in admin: 635 | gid = msg.text.replace("inv: ","") 636 | if gid == "": 637 | cl.sendText(msg.to,"invalid group id.") 638 | else: 639 | try: 640 | cl.findAndAddContactsByMid(msg.from_) 641 | cl.inviteIntoGroup(gid,[msg.from_]) 642 | cl.sendText(msg.to,"invited.") 643 | except: 644 | cl.sendText(msg.to,"you are has been invited.") 645 | elif "leave: " in msg.text: 646 | if msg.from_ in admin: 647 | gid = msg.text.replace("leave: ","") 648 | if gid == "": 649 | cl.sendText(msg.to,"invalid group id.") 650 | else: 651 | try: 652 | cl.leaveGroup(gid) 653 | cl.sendText(msg.to,"Bot leaving the group.") 654 | except: 655 | cl.sendText(msg.to,"Bot has left the group.") 656 | elif msg.text in ["Bot?"]: 657 | msg.contentType = 13 658 | msg.contentMetadata = {'mid': mid} 659 | cl.sendMessage(msg) 660 | 661 | msg.contentType = 13 662 | msg.contentMetadata = {'mid': Amid} 663 | ki.sendMessage(msg) 664 | 665 | msg.contentType = 13 666 | msg.contentMetadata = {'mid': Bmid} 667 | kk.sendMessage(msg) 668 | 669 | msg.contentType = 13 670 | msg.contentMetadata = {'mid': Cmid} 671 | kc.sendMessage(msg) 672 | elif msg.text in ["Creator","creator"]: 673 | msg.contentType = 13 674 | cl.sendText(msg.to, "Created By: FajrinArd") 675 | msg.contentMetadata = {'mid': 'ue11fc7860247c63bd3da149613a793f6'} 676 | cl.sendMessage(msg) 677 | elif msg.text in ["Me"]: 678 | msg.contentType = 13 679 | msg.contentMetadata = {'mid': msg.from_} 680 | cl.sendMessage(msg) 681 | elif msg.text in ["æ„›ã�®ãƒ—レゼント","Gift"]: 682 | msg.contentType = 9 683 | msg.contentMetadata={'PRDID': 'a0768339-c2d3-4189-9653-2909e9bb6f58', 684 | 'PRDTYPE': 'THEME', 685 | 'MSGTPL': '5'} 686 | msg.text = None 687 | cl.sendMessage(msg) 688 | elif msg.text in ["Cancel","cancel"]: 689 | if msg.from_ in admin: 690 | if msg.toType == 2: 691 | X = cl.getGroup(msg.to) 692 | if X.invitee is not None: 693 | gInviMids = [contact.mid for contact in X.invitee] 694 | cl.cancelGroupInvitation(msg.to, gInviMids) 695 | else: 696 | if wait["lang"] == "JP": 697 | cl.sendText(msg.to,"No one is inviting") 698 | else: 699 | cl.sendText(msg.to,"Sorry, nobody absent") 700 | else: 701 | if wait["lang"] == "JP": 702 | cl.sendText(msg.to,"Can not be used outside the group") 703 | else: 704 | cl.sendText(msg.to,"Not for use less than group") 705 | #elif "gurl" == msg.text: 706 | #print cl.getGroup(msg.to) 707 | ##cl.sendMessage(msg) 708 | elif msg.text in ["Open url","open url"]: 709 | if msg.from_ in admin: 710 | if msg.toType == 2: 711 | X = cl.getGroup(msg.to) 712 | X.preventJoinByTicket = False 713 | cl.updateGroup(X) 714 | if wait["lang"] == "JP": 715 | cl.sendText(msg.to,"Invite by link open") 716 | else: 717 | cl.sendText(msg.to,"Already open") 718 | else: 719 | if wait["lang"] == "JP": 720 | cl.sendText(msg.to,"Can not be used outside the group") 721 | else: 722 | cl.sendText(msg.to,"Not for use less than group") 723 | elif msg.text in ["Close url","close url"]: 724 | if msg.from_ in admin: 725 | if msg.toType == 2: 726 | X = cl.getGroup(msg.to) 727 | X.preventJoinByTicket = True 728 | cl.updateGroup(X) 729 | if wait["lang"] == "JP": 730 | cl.sendText(msg.to,"Invite by link Close") 731 | else: 732 | cl.sendText(msg.to,"Already close") 733 | else: 734 | if wait["lang"] == "JP": 735 | cl.sendText(msg.to,"Can not be used outside the group") 736 | else: 737 | cl.sendText(msg.to,"Not for use less than group") 738 | elif msg.text == "Ginfo": 739 | if msg.toType == 2: 740 | ginfo = cl.getGroup(msg.to) 741 | try: 742 | gCreator = ginfo.creator.displayName 743 | except: 744 | gCreator = "Error" 745 | if wait["lang"] == "JP": 746 | if ginfo.invitee is None: 747 | sinvitee = "0" 748 | else: 749 | sinvitee = str(len(ginfo.invitee)) 750 | if ginfo.preventJoinByTicket == True: 751 | u = "close" 752 | else: 753 | u = "open" 754 | cl.sendText(msg.to,"group name :\n" + str(ginfo.name) + "\n\ngid :\n" + msg.to + "\n\ngroup creator :\n" + gCreator + "\n\nprofile status :\nhttp://dl.profile.line.naver.jp/" + ginfo.pictureStatus + "\n\nmembers : " + str(len(ginfo.members)) + " members\npending : " + sinvitee + " people\nQR/Link : " + u + " it is inside") 755 | else: 756 | cl.sendText(msg.to,"group name :\n" + str(ginfo.name) + "\n\ngid :\n" + msg.to + "\n\ngroup creator :\n" + gCreator + "\n\nprofile status :\nhttp://dl.profile.line.naver.jp/" + ginfo.pictureStatus + "\n\nmembers : " + str(len(ginfo.members)) + " members\npending : " + sinvitee + " people\nQR/Link : " + u + " it is inside") 757 | else: 758 | if wait["lang"] == "JP": 759 | cl.sendText(msg.to,"Can not be used outside the group") 760 | else: 761 | cl.sendText(msg.to,"Not for use less than group") 762 | elif msg.text.lower() == "id group": 763 | cl.sendText(msg.to,msg.to) 764 | elif msg.text.lower() == "my mid": 765 | cl.sendText(msg.to, msg.from_) 766 | elif msg.text.lower() == "Mid all": 767 | if msg.from_ in admin: 768 | cl.sendText(msg.to,mid) 769 | ki.sendText(msg.to,Amid) 770 | kk.sendText(msg.to,Bmid) 771 | kc.sendText(msg.to,Cmid) 772 | elif msg.text in ["Wkwkwk","Wkwk","Wk","wkwkwk","wkwk","wk"]: 773 | msg.contentType = 7 774 | msg.text = None 775 | msg.contentMetadata = { 776 | "STKID": "100", 777 | "STKPKGID": "1", 778 | "STKVER": "100" } 779 | ki.sendMessage(msg) 780 | elif msg.text in ["Hehehe","Hehe","He","hehehe","hehe","he"]: 781 | msg.contentType = 7 782 | msg.text = None 783 | msg.contentMetadata = { 784 | "STKID": "10", 785 | "STKPKGID": "1", 786 | "STKVER": "100" } 787 | ki.sendMessage(msg) 788 | elif msg.text in ["Galau"]: 789 | msg.contentType = 7 790 | msg.text = None 791 | msg.contentMetadata = { 792 | "STKID": "9", 793 | "STKPKGID": "1", 794 | "STKVER": "100" } 795 | ki.sendMessage(msg) 796 | kk.sendMessage(msg) 797 | elif msg.text in ["You"]: 798 | msg.contentType = 7 799 | msg.text = None 800 | msg.contentMetadata = { 801 | "STKID": "7", 802 | "STKPKGID": "1", 803 | "STKVER": "100" } 804 | ki.sendMessage(msg) 805 | kk.sendMessage(msg) 806 | elif msg.text in ["Hadeuh"]: 807 | msg.contentType = 7 808 | msg.text = None 809 | msg.contentMetadata = { 810 | "STKID": "6", 811 | "STKPKGID": "1", 812 | "STKVER": "100" } 813 | ki.sendMessage(msg) 814 | kk.sendMessage(msg) 815 | elif msg.text in ["Please"]: 816 | msg.contentType = 7 817 | msg.text = None 818 | msg.contentMetadata = { 819 | "STKID": "4", 820 | "STKPKGID": "1", 821 | "STKVER": "100" } 822 | ki.sendMessage(msg) 823 | kk.sendMessage(msg) 824 | elif msg.text in ["Haaa"]: 825 | msg.contentType = 7 826 | msg.text = None 827 | msg.contentMetadata = { 828 | "STKID": "3", 829 | "STKPKGID": "1", 830 | "STKVER": "100" } 831 | ki.sendMessage(msg) 832 | kk.sendMessage(msg) 833 | elif msg.text in ["Lol"]: 834 | msg.contentType = 7 835 | msg.text = None 836 | msg.contentMetadata = { 837 | "STKID": "110", 838 | "STKPKGID": "1", 839 | "STKVER": "100" } 840 | ki.sendMessage(msg) 841 | kk.sendMessage(msg) 842 | elif msg.text in ["Hmmm","Hmm","Hm","hmmm","hmm","hm"]: 843 | msg.contentType = 7 844 | msg.text = None 845 | msg.contentMetadata = { 846 | "STKID": "101", 847 | "STKPKGID": "1", 848 | "STKVER": "100" } 849 | ki.sendMessage(msg) 850 | elif msg.text in ["Welcome"]: 851 | msg.contentType = 7 852 | msg.text = None 853 | msg.contentMetadata = { 854 | "STKID": "247", 855 | "STKPKGID": "3", 856 | "STKVER": "100" } 857 | ki.sendMessage(msg) 858 | elif msg.text in ["TL: "]: 859 | if msg.from_ in admin: 860 | tl_text = msg.text.replace("TL: ","") 861 | cl.sendText(msg.to,"line://home/post?userMid="+mid+"&postId="+cl.new_post(tl_text)["result"]["post"]["postInfo"]["postId"]) 862 | elif msg.text in ["Mc "]: 863 | mmid = msg.text.replace("Mc ","") 864 | msg.contentType = 13 865 | msg.contentMetadata = {"mid":mmid} 866 | cl.sendMessage(msg) 867 | elif msg.text in ["Joinn on","joinn on"]: 868 | if msg.from_ in admin: 869 | if wait["Protectjoin"] == True: 870 | if wait["lang"] == "JP": 871 | cl.sendText(msg.to,"kick Joined Group On") 872 | else: 873 | cl.sendText(msg.to,"done") 874 | else: 875 | wait["Protectjoin"] = True 876 | if wait["lang"] == "JP": 877 | cl.sendText(msg.to,"kick Joined Group On") 878 | else: 879 | cl.sendText(msg.to,"done") 880 | elif msg.text in ["Joinn off","joinn off"]: 881 | if msg.from_ in admin: 882 | if wait["Protectjoin"] == False: 883 | if wait["lang"] == "JP": 884 | cl.sendText(msg.to,"kick Joined Group Off") 885 | else: 886 | cl.sendText(msg.to,"done") 887 | else: 888 | wait["Protectjoin"] = False 889 | if wait["lang"] == "JP": 890 | cl.sendText(msg.to,"kick Joined Group Off") 891 | else: 892 | cl.sendText(msg.to,"done") 893 | elif msg.text in ["Cancl on","cancl on"]: 894 | if msg.from_ in admin: 895 | if wait["Protectcancl"] == True: 896 | if wait["lang"] == "JP": 897 | cl.sendText(msg.to,"Cancel All Invited On") 898 | else: 899 | cl.sendText(msg.to,"done") 900 | else: 901 | wait["Protectcancl"] = True 902 | if wait["lang"] == "JP": 903 | cl.sendText(msg.to,"Cancel All Invited On") 904 | else: 905 | cl.sendText(msg.to,"done") 906 | elif msg.text in ["Cancl off","cancl off"]: 907 | if msg.from_ in admin: 908 | if wait["Protectcancl"] == False: 909 | if wait["lang"] == "JP": 910 | cl.sendText(msg.to,"Cancel All Invited Off") 911 | else: 912 | cl.sendText(msg.to,"done") 913 | else: 914 | wait["Protectcancl"] = False 915 | if wait["lang"] == "JP": 916 | cl.sendText(msg.to,"Cancel All Invited Off") 917 | else: 918 | cl.sendText(msg.to,"done") 919 | elif msg.text in ["Gr on","gr on"]: 920 | if msg.from_ in admin: 921 | if wait["Protectgr"] == True: 922 | if wait["lang"] == "JP": 923 | cl.sendText(msg.to,"Protect Group On") 924 | else: 925 | cl.sendText(msg.to,"done") 926 | else: 927 | wait["Protectgr"] = True 928 | if wait["lang"] == "JP": 929 | cl.sendText(msg.to,"Protect Group On") 930 | else: 931 | cl.sendText(msg.to,"done") 932 | elif msg.text in ["Gr off","gr off"]: 933 | if msg.from_ in admin: 934 | if wait["Protectgr"] == False: 935 | if wait["lang"] == "JP": 936 | cl.sendText(msg.to,"Protect Group Off") 937 | else: 938 | cl.sendText(msg.to,"done") 939 | else: 940 | wait["Protectgr"] = False 941 | if wait["lang"] == "JP": 942 | cl.sendText(msg.to,"Protect Group Off") 943 | else: 944 | cl.sendText(msg.to,"done") 945 | elif msg.text in ["Contact On","Contact on","contact on"]: 946 | if msg.from_ in admin: 947 | if wait["contact"] == True: 948 | if wait["lang"] == "JP": 949 | cl.sendText(msg.to,"Cek Mid Send Contact On") 950 | else: 951 | cl.sendText(msg.to,"done") 952 | else: 953 | wait["contact"] = True 954 | if wait["lang"] == "JP": 955 | cl.sendText(msg.to,"Cek Mid Send Contact On") 956 | else: 957 | cl.sendText(msg.to,"done") 958 | elif msg.text in ["Contact Off","Contact off","contact off"]: 959 | if msg.from_ in admin: 960 | if wait["contact"] == False: 961 | if wait["lang"] == "JP": 962 | cl.sendText(msg.to,"Cek Mid Send Contact Off") 963 | else: 964 | cl.sendText(msg.to,"done") 965 | else: 966 | wait["contact"] = False 967 | if wait["lang"] == "JP": 968 | cl.sendText(msg.to,"Cek Mid Send Contact Off") 969 | else: 970 | cl.sendText(msg.to,"done") 971 | elif msg.text in ["自動å�‚åŠ :オン","Join on","Auto join:on","自動å�ƒåŠ ï¼šé–‹"]: 972 | if msg.from_ in admin: 973 | if wait["autoJoin"] == True: 974 | if wait["lang"] == "JP": 975 | cl.sendText(msg.to,"already on") 976 | else: 977 | cl.sendText(msg.to,"done") 978 | else: 979 | wait["autoJoin"] = True 980 | if wait["lang"] == "JP": 981 | cl.sendText(msg.to,"already on") 982 | else: 983 | cl.sendText(msg.to,"done") 984 | elif msg.text in ["自動å�‚åŠ :オフ","Join off","Auto join:off","自動å�ƒåŠ ï¼šé—œ"]: 985 | if msg.from_ in admin: 986 | if wait["autoJoin"] == False: 987 | if wait["lang"] == "JP": 988 | cl.sendText(msg.to,"already off") 989 | else: 990 | cl.sendText(msg.to,"done") 991 | else: 992 | wait["autoJoin"] = False 993 | if wait["lang"] == "JP": 994 | cl.sendText(msg.to,"already off") 995 | else: 996 | cl.sendText(msg.to,"done") 997 | elif msg.text in ["共有:オン","Share on","Share on"]: 998 | if msg.from_ in admin: 999 | if wait["timeline"] == True: 1000 | if wait["lang"] == "JP": 1001 | cl.sendText(msg.to,"already on") 1002 | else: 1003 | cl.sendText(msg.to,"done") 1004 | else: 1005 | wait["timeline"] = True 1006 | if wait["lang"] == "JP": 1007 | cl.sendText(msg.to,"done") 1008 | else: 1009 | cl.sendText(msg.to,"è¦�了开。") 1010 | elif msg.text in ["共有:オフ","Share off","Share off"]: 1011 | if msg.from_ in admin: 1012 | if wait["timeline"] == False: 1013 | if wait["lang"] == "JP": 1014 | cl.sendText(msg.to,"already off") 1015 | else: 1016 | cl.sendText(msg.to,"done") 1017 | else: 1018 | wait["timeline"] = False 1019 | if wait["lang"] == "JP": 1020 | cl.sendText(msg.to,"done") 1021 | else: 1022 | cl.sendText(msg.to,"è¦�了关断。") 1023 | elif msg.text in ["Set View"]: 1024 | if msg.from_ in admin: 1025 | md = "" 1026 | if wait["Protectjoin"] == True: md+="􀔃􀆑lock􏿿 Block Join\n" 1027 | else: md+=" Block Join Off\n" 1028 | if wait["Protectgr"] == True: md+="􀔃􀆑lock􏿿 Block Group\n" 1029 | else: md+=" Block Group Off\n" 1030 | if wait["Protectcancl"] == True: md+="􀔃􀆑lock􏿿 Cancel All Invited\n" 1031 | else: md+=" Cancel All Invited Off\n" 1032 | if wait["contact"] == True: md+=" Contact : on\n" 1033 | else: md+=" Contact : off\n" 1034 | if wait["autoJoin"] == True: md+=" Auto join : on\n" 1035 | else: md +=" Auto join : off\n" 1036 | if wait["autoCancel"]["on"] == True:md+=" Group cancel :" + str(wait["autoCancel"]["members"]) + "\n" 1037 | else: md+= " Group cancel : off\n" 1038 | if wait["leaveRoom"] == True: md+=" Auto leave : on\n" 1039 | else: md+=" Auto leave : off\n" 1040 | if wait["timeline"] == True: md+=" Share : on\n" 1041 | else:md+=" Share : off\n" 1042 | if wait["autoAdd"] == True: md+=" Auto add : on\n" 1043 | else:md+=" Auto add : off\n" 1044 | if wait["commentOn"] == True: md+=" Comment : on\n" 1045 | else:md+=" Comment : off\n" 1046 | cl.sendText(msg.to,md) 1047 | elif msg.text.lower() in ["Group id"]: 1048 | if msg.from_ in admin: 1049 | gid = cl.getGroupIdsJoined() 1050 | h = "" 1051 | for i in gid: 1052 | h += "[ %s ] :\n%s\n\n" % (cl.getGroup(i).name,i) 1053 | cl.sendText(msg.to,h) 1054 | elif msg.text in ["Cancelall"]: 1055 | if msg.from_ in admin: 1056 | gid = cl.getGroupIdsInvited() 1057 | for i in gid: 1058 | cl.rejectGroupInvitation(i) 1059 | if wait["lang"] == "JP": 1060 | cl.sendText(msg.to,"All invitations have been refused") 1061 | else: 1062 | cl.sendText(msg.to,"æ‹’ç»�了全部的邀请。") 1063 | elif msg.text in ["Gurl"]: 1064 | if msg.from_ in admin: 1065 | if msg.toType == 2: 1066 | x = cl.getGroup(msg.to) 1067 | if x.preventJoinByTicket == True: 1068 | x.preventJoinByTicket = False 1069 | cl.updateGroup(x) 1070 | gurl = cl.reissueGroupTicket(msg.to) 1071 | cl.sendText(msg.to,"line://ti/g/" + gurl) 1072 | else: 1073 | if wait["lang"] == "JP": 1074 | cl.sendText(msg.to,"Can't be used outside the group") 1075 | else: 1076 | cl.sendText(msg.to,"Not for use less than group") 1077 | elif msg.text.lower() == 'cek': 1078 | cl.sendText(msg.to, "Set point.") 1079 | try: 1080 | del wait2['readPoint'][msg.to] 1081 | del wait2['readMember'][msg.to] 1082 | except: 1083 | pass 1084 | now2 = datetime.now() 1085 | wait2['readPoint'][msg.to] = msg.id 1086 | wait2['readMember'][msg.to] = "" 1087 | wait2['setTime'][msg.to] = datetime.now().strftime('%Y-%m-%d %H:%M') 1088 | wait2['ROM'][msg.to] = {} 1089 | print wait2 1090 | elif msg.text.lower() == 'sider': 1091 | if msg.to in wait2['readPoint']: 1092 | if wait2["ROM"][msg.to].items() == []: 1093 | chiya = "" 1094 | else: 1095 | chiya = "" 1096 | for rom in wait2["ROM"][msg.to].items(): 1097 | print rom 1098 | chiya += rom[1] + "\n" 1099 | 1100 | cl.sendText(msg.to, "Readers:\n%s\nDate and time:\n[%s]" % (chiya,setTime[msg.to])) 1101 | else: 1102 | cl.sendText(msg.to, "Type 'cek' to set point.") 1103 | #----------------------------------------------- 1104 | 1105 | #----------------------------------------------- 1106 | #----------------Fungsi Join Group Start-----------------------# 1107 | elif msg.text in ["Ard Squad join"]: 1108 | if msg.from_ in admin: 1109 | G = cl.getGroup(msg.to) 1110 | ginfo = cl.getGroup(msg.to) 1111 | G.preventJoinByTicket = False 1112 | cl.updateGroup(G) 1113 | invsend = 0 1114 | Ticket = cl.reissueGroupTicket(msg.to) 1115 | ki.acceptGroupInvitationByTicket(msg.to,Ticket) 1116 | time.sleep(0.1) 1117 | kk.acceptGroupInvitationByTicket(msg.to,Ticket) 1118 | time.sleep(0.1) 1119 | kc.acceptGroupInvitationByTicket(msg.to,Ticket) 1120 | time.sleep(0.1) 1121 | G = cl.getGroup(msg.to) 1122 | G.preventJoinByTicket = True 1123 | cl.updateGroup(G) 1124 | print "Bot Complete" 1125 | G.preventJoinByTicket(G) 1126 | cl.updateGroup(G) 1127 | 1128 | elif msg.text in ["Ard join"]: 1129 | if msg.form_ in admin: 1130 | x = ki.getGroup(msg.to) 1131 | x.preventJoinByTicket = False 1132 | ki.updateGroup(x) 1133 | invsend = 0 1134 | Ti = ki.reissueGroupTicket(msg.to) 1135 | cl.acceptGroupInvitationByTicket(msg.to,Ti) 1136 | G = ki.getGroup(msg.to) 1137 | G.preventJoinByTicket = True 1138 | ki.updateGroup(G) 1139 | Ticket = ki.reissueGroupTicket(msg.to) 1140 | 1141 | elif msg.text in ["Ard1 join"]: 1142 | if msg.from_ in admin: 1143 | x = cl.getGroup(msg.to) 1144 | x.preventJoinByTicket = False 1145 | cl.updateGroup(x) 1146 | invsend = 0 1147 | Ti = cl.reissueGroupTicket(msg.to) 1148 | ki.acceptGroupInvitationByTicket(msg.to,Ti) 1149 | G = cl.getGroup(msg.to) 1150 | G.preventJoinByTicket = True 1151 | cl.updateGroup(G) 1152 | Ticket = cl.reissueGroupTicket(msg.to) 1153 | 1154 | elif msg.text in ["Ard2 join"]: 1155 | if msg.from_ in admin: 1156 | x = cl.getGroup(msg.to) 1157 | x.preventJoinByTicket = False 1158 | cl.updateGroup(x) 1159 | invsend = 0 1160 | Ti = cl.reissueGroupTicket(msg.to) 1161 | kk.acceptGroupInvitationByTicket(msg.to,Ti) 1162 | G = cl.getGroup(msg.to) 1163 | G.preventJoinByTicket = True 1164 | cl.updateGroup(G) 1165 | Ticket = cl.reissueGroupTicket(msg.to) 1166 | 1167 | elif msg.text in ["Ard3 join"]: 1168 | if msg.from_ in admin: 1169 | X = cl.getGroup(msg.to) 1170 | X.preventJoinByTicket = False 1171 | cl.updateGroup(X) 1172 | invsend = 0 1173 | Ti = cl.reissueGroupTicket(msg.to) 1174 | kc.acceptGroupInvitationByTicket(msg.to,Ti) 1175 | G = cl.getGroup(msg.to) 1176 | G.preventJoinByTicket = True 1177 | cl.updateGroup(G) 1178 | Ticket = cl.reissueGroupTicket(msg.to) 1179 | #----------------------Fungsi Join Group Finish---------------# 1180 | 1181 | #-------------Fungsi Leave Group Start---------------# 1182 | elif msg.text in ["Bye bots"]: 1183 | if msg.from_ in admin: 1184 | if msg.toType == 2: 1185 | ginfo = ki.getGroup(msg.to) 1186 | try: 1187 | ki.leaveGroup(msg.to) 1188 | kk.leaveGroup(msg.to) 1189 | kc.leaveGroup(msg.to) 1190 | except: 1191 | pass 1192 | elif msg.text in ["Bye Ard"]: 1193 | if msg.from_ in admin: 1194 | if msg.toType == 2: 1195 | ginfo = cl.getGroup(msg.to) 1196 | try: 1197 | cl.leaveGroup(msg.to) 1198 | except: 1199 | pass 1200 | #-------------Fungsi Leave Group Finish---------------# 1201 | 1202 | #-------------Fungsi Tag All Start---------------# 1203 | elif msg.text in ["kiwkiw","Tagall"]: 1204 | group = cl.getGroup(msg.to) 1205 | nama = [contact.mid for contact in group.members] 1206 | 1207 | cb = "" 1208 | cb2 = "" 1209 | strt = int(0) 1210 | akh = int(0) 1211 | for md in nama: 1212 | akh = akh + int(6) 1213 | 1214 | cb += """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(md)+"},""" 1215 | 1216 | strt = strt + int(7) 1217 | akh = akh + 1 1218 | cb2 += "@nrik \n" 1219 | 1220 | cb = (cb[:int(len(cb)-1)]) 1221 | msg.contentType = 0 1222 | msg.text = cb2 1223 | msg.contentMetadata ={'MENTION':'{"MENTIONEES":['+cb+']}','EMTVER':'4'} 1224 | 1225 | try: 1226 | cl.sendMessage(msg) 1227 | except Exception as error: 1228 | print error 1229 | #-------------Fungsi Tag All Finish---------------# 1230 | 1231 | #----------------Fungsi Banned Kick Target Start-----------------------# 1232 | elif msg.text in ["Kill "]: 1233 | if msg.from_ in admin: 1234 | if msg.toType == 2: 1235 | group = ki.getGroup(msg.to) 1236 | gMembMids = [contact.mid for contact in group.members] 1237 | matched_list = [] 1238 | for tag in wait["blacklist"]: 1239 | matched_list+=filter(lambda str: str == tag, gMembMids) 1240 | if matched_list == []: 1241 | kk.sendText(msg.to,"Good Bye") 1242 | return 1243 | for jj in matched_list: 1244 | try: 1245 | klist=[ki,kk,kc] 1246 | kicker=random.choice(klist) 1247 | kicker.kickoutFromGroup(msg.to,[jj]) 1248 | print (msg.to,[jj]) 1249 | except: 1250 | pass 1251 | #----------------Fungsi Banned Kick Target Finish----------------------# 1252 | 1253 | elif "Sweep this group" in msg.text.lower(): 1254 | if msg.from_ in admsa: 1255 | if msg.toType == 2: 1256 | print "sweeping" 1257 | _name = msg.text.replace("Sweep this group","") 1258 | gs = ki.getGroup(msg.to) 1259 | gs = kk.getGroup(msg.to) 1260 | gs = kc.getGroup(msg.to) 1261 | ki.sendText(msg.to,"maaf kalo gak sopan") 1262 | kk.sendText(msg.to,"makasih semuanya..") 1263 | kc.sendText(msg.to,"hehehhehe") 1264 | msg.contentType = 13 1265 | msg.contentMetadata = {'mid': 'ue11fc7860247c63bd3da149613a793f6'} 1266 | cl.sendMessage(msg) 1267 | targets = [] 1268 | for s in gs.members: 1269 | if _name in s.displayName: 1270 | targets.append(s.mid) 1271 | if targets == []: 1272 | ki.sendText(msg.to,"Not found") 1273 | else: 1274 | for target in targets: 1275 | if target not in Bots: 1276 | if target not in admin: 1277 | try: 1278 | klist=[cl,ki,kk,kc] 1279 | kicker=random.choice(klist) 1280 | kicker.kickoutFromGroup(msg.to,[target]) 1281 | print (msg.to,[g.mid]) 1282 | except: 1283 | pass 1284 | 1285 | #----------------Fungsi Kick User Target Start----------------------# 1286 | elif "Nk " in msg.text: 1287 | if msg.from_ in admin: 1288 | nk0 = msg.text.replace("Nk ","") 1289 | nk1 = nk0.lstrip() 1290 | nk2 = nk1.replace("@","") 1291 | nk3 = nk2.rstrip() 1292 | _name = nk3 1293 | gs = cl.getGroup(msg.to) 1294 | targets = [] 1295 | for s in gs.members: 1296 | if _name in s.displayName: 1297 | targets.append(s.mid) 1298 | if targets == []: 1299 | cl.sendMessage(msg.to,"user does not exist") 1300 | pass 1301 | else: 1302 | for target in targets: 1303 | if targets not in Bots: 1304 | if targets not in admin: 1305 | try: 1306 | klist=[cl,ki,kk,kc] 1307 | kicker=random.choice(klist) 1308 | ki.sendText(msg.to, "Good bye.") 1309 | kicker.kickoutFromGroup(msg.to,[target]) 1310 | print (msg.to,[g.mid]) 1311 | except: 1312 | pass 1313 | #----------------Fungsi Kick User Target Finish----------------------# 1314 | #elif "Blacklist @" in msg.text: 1315 | #_name = msg.text.replace("Blacklist @","") 1316 | #_kicktarget = _name.rstrip(' ') 1317 | #gs = ki2.getGroup(msg.to) 1318 | #targets = [] 1319 | #for g in gs.members: 1320 | #if _kicktarget == g.displayName: 1321 | #targets.append(g.mid) 1322 | #if targets == []: 1323 | #cl.sendText(msg.to,"Not found") 1324 | #else: 1325 | #for target in targets: 1326 | #try: 1327 | #wait["blacklist"][target] = True 1328 | #f=codecs.open('st2__b.json','w','utf-8') 1329 | #json.dump(wait["blacklist"], f, sort_keys=True, indent=4,ensure_ascii=False) 1330 | #k3.sendText(msg.to,"Target locked.") 1331 | #except: 1332 | #ki.sendText(msg.to,"error") 1333 | 1334 | #----------------Fungsi Banned User Target Start-----------------------# 1335 | elif "Ban @" in msg.text: 1336 | if msg.from_ in admin: 1337 | if msg.toType == 2: 1338 | print "[Banned] executed" 1339 | _name = msg.text.replace("Ban @","") 1340 | _nametarget = _name.rstrip(' ') 1341 | gs = cl.getGroup(msg.to) 1342 | gs = ki.getGroup(msg.to) 1343 | gs = kk.getGroup(msg.to) 1344 | gs = kc.getGroup(msg.to) 1345 | targets = [] 1346 | for g in gs.members: 1347 | if _nametarget == g.displayName: 1348 | targets.append(g.mid) 1349 | if targets in Bots: 1350 | cl.sendText(msg.to,"Can't ban bot") 1351 | else: 1352 | for target in targets: 1353 | try: 1354 | wait["blacklist"][target] = True 1355 | f=codecs.open('st2__b.json','w','utf-8') 1356 | json.dump(wait["blacklist"], f, sort_keys=True, indent=4,ensure_ascii=False) 1357 | cl.sendText(msg.to,"Target locked.") 1358 | print "[Banned] success" 1359 | except: 1360 | ki.sendText(msg.to,"Target already in blacklist.") 1361 | #----------------Fungsi Banned User Target Finish-----------------------# 1362 | 1363 | #----------------Fungsi Unbanned User Target Start-----------------------# 1364 | elif "Unban @" in msg.text: 1365 | if msg.from_ in admin: 1366 | if msg.toType == 2: 1367 | print "[Unban] executed" 1368 | _name = msg.text.replace("Unban @","") 1369 | _nametarget = _name.rstrip(' ') 1370 | gs = cl.getGroup(msg.to) 1371 | gs = ki.getGroup(msg.to) 1372 | gs = kk.getGroup(msg.to) 1373 | gs = kc.getGroup(msg.to) 1374 | targets = [] 1375 | for g in gs.members: 1376 | if _nametarget == g.displayName: 1377 | targets.append(g.mid) 1378 | if targets == []: 1379 | cl.sendText(msg.to,"Target not found") 1380 | else: 1381 | for target in targets: 1382 | try: 1383 | del wait["blacklist"][target] 1384 | f=codecs.open('st2__b.json','w','utf-8') 1385 | json.dump(wait["blacklist"], f, sort_keys=True, indent=4,ensure_ascii=False) 1386 | cl.sendText(msg.to,"Target cleaned.") 1387 | print "[Unban] success" 1388 | except: 1389 | ki.sendText(msg.to,"There's no target in blacklist.") 1390 | #----------------Fungsi Unbanned User Target Finish-----------------------# 1391 | 1392 | #-------------Fungsi Spam Start---------------------# 1393 | elif msg.text in ["Up","up","Up Chat","Up chat","up chat","Upchat","upchat"]: 1394 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1395 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1396 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1397 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1398 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1399 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1400 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1401 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1402 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1403 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1404 | cl.sendText(msg.to,"􀔃􀆶squared up!􏿿") 1405 | #-------------Fungsi Spam Finish---------------------# 1406 | 1407 | #-------------Fungsi Broadcast Start------------# 1408 | elif "Bc " in msg.text: 1409 | if msg.from_ in admin: 1410 | bctxt = msg.text.replace("Bc ","") 1411 | n = cl.getGroupIdsJoined() 1412 | for manusia in n: 1413 | cl.sendText(manusia, (bctxt)) 1414 | #--------------Fungsi Broadcast Finish-----------# 1415 | 1416 | elif msg.text in ["Cv say hi"]: 1417 | ki.sendText(msg.to,"Hi buddy 􀜁􀅔Har Har􏿿") 1418 | kk.sendText(msg.to,"Hi buddy 􀜁􀅔Har Har􏿿") 1419 | kc.sendText(msg.to,"Hi buddy 􀜁􀅔Har Har􏿿") 1420 | 1421 | #----------------------------------------------- 1422 | 1423 | elif msg.text in ["Ard","ard"]: 1424 | cl.sendText(msg.to,"Ya? Type 'help' for help message.") 1425 | #----------------------------------------------- 1426 | 1427 | #-------------Fungsi Respon Start---------------------# 1428 | elif msg.text in ["Get ready"]: 1429 | if msg.from_ in admin: 1430 | cl.sendText(msg.to,"I'm ready") 1431 | ki.sendText(msg.to,"I'm ready") 1432 | kk.sendText(msg.to,"I'm ready") 1433 | kc.sendText(msg.to,"I'm ready") 1434 | #-------------Fungsi Respon Finish---------------------# 1435 | 1436 | #-------------Fungsi Balesan Respon Finish---------------------# 1437 | 1438 | #-------------Fungsi Speedbot Start---------------------# 1439 | elif msg.text in ["Speedbot","speedbot"]: 1440 | start = time.time() 1441 | cl.sendText(msg.to, "please wait...") 1442 | elapsed_time = time.time() - start 1443 | cl.sendText(msg.to, "%ss" % (elapsed_time)) 1444 | #-------------Fungsi Speedbot Finish---------------------# 1445 | 1446 | #-------------Fungsi Banned Send Contact Start------------------# 1447 | elif msg.text in ["Ban"]: 1448 | if msg.from_ in admin: 1449 | wait["wblacklist"] = True 1450 | cl.sendText(msg.to,"send contact") 1451 | elif msg.text in ["Unban"]: 1452 | if msg.from_ in admin: 1453 | wait["dblacklist"] = True 1454 | cl.sendText(msg.to,"send contact") 1455 | #-------------Fungsi Banned Send Contact Finish------------------# 1456 | 1457 | #-------------Fungsi Bannlist Start------------------# 1458 | elif msg.text in ["Banlist"]: 1459 | if msg.from_ in admin: 1460 | if wait["blacklist"] == {}: 1461 | cl.sendText(msg.to,"There's no banned user") 1462 | else: 1463 | ki.sendText(msg.to,"Blacklist user") 1464 | mc = "" 1465 | for mi_d in wait["blacklist"]: 1466 | mc += "->" +cl.getContact(mi_d).displayName + "\n" 1467 | cl.sendText(msg.to,mc) 1468 | #-------------Fungsi Bannlist Finish------------------# 1469 | 1470 | elif msg.text in ["Cek ban"]: 1471 | if msg.toType == 2: 1472 | group = cl.getGroup(msg.to) 1473 | gMembMids = [contact.mid for contact in group.members] 1474 | matched_list = [] 1475 | for tag in wait["blacklist"]: 1476 | matched_list+=filter(lambda str: str == tag, gMembMids) 1477 | cocoa = "" 1478 | for mm in matched_list: 1479 | cocoa += mm + "\n" 1480 | cl.sendText(msg.to,cocoa + "") 1481 | elif msg.text in ["Kill ban"]: 1482 | if msg.from_ in admin: 1483 | if msg.toType == 2: 1484 | group = cl.getGroup(msg.to) 1485 | gMembMids = [contact.mid for contact in group.members] 1486 | matched_list = [] 1487 | for tag in wait["blacklist"]: 1488 | matched_list+=filter(lambda str: str == tag, gMembMids) 1489 | if matched_list == []: 1490 | cl.sendText(msg.to,"There was no blacklist user") 1491 | return 1492 | for jj in matched_list: 1493 | cl.sendText(msg.to,"Good bye.") 1494 | cl.kickoutFromGroup(msg.to,[jj]) 1495 | ki.kickoutFromGroup(msg.to,[jj]) 1496 | kk.kickoutFromGroup(msg.to,[jj]) 1497 | kc.kickoutFromGroup(msg.to,[jj]) 1498 | elif msg.text in ["Clear"]: 1499 | if msg.from_ in admin: 1500 | if msg.toType == 2: 1501 | group = cl.getGroup(msg.to) 1502 | gMembMids = [contact.mid for contact in group.invitee] 1503 | for _mid in gMembMids: 1504 | cl.cancelGroupInvitation(msg.to,[_mid]) 1505 | cl.sendText(msg.to,"I pretended to cancel and canceled.") 1506 | 1507 | elif msg.text in ["Bot Like", "Bot like"]: 1508 | if msg.from_ in admin: 1509 | print "[Command]Like executed" 1510 | cl.sendText(msg.to,"Trying to Like post(s)") 1511 | try: 1512 | likePost() 1513 | except: 1514 | pass 1515 | 1516 | elif msg.text.lower() == 'ard out all': 1517 | if msg.from_ in admsa: 1518 | gid = cl.getGroupIdsJoined() 1519 | gid = ki.getGroupIdsJoined() 1520 | gid = kk.getGroupIdsJoined() 1521 | gid = kc.getGroupIdsJoined() 1522 | for i in gid: 1523 | cl.leaveGroup(i) 1524 | ki.leaveGroup(i) 1525 | kk.leaveGroup(i) 1526 | kc.leaveGroup(i) 1527 | if wait["lang"] == "JP": 1528 | cl.sendText(msg.to,"Ard Squad bot leaving all groups.") 1529 | else: 1530 | cl.sendText(msg.to,"He declined all invitations") 1531 | elif msg.text.lower() == 'ard out': 1532 | if msg.from_ in admsa: 1533 | gid = cl.getGroupIdsJoined() 1534 | for i in gid: 1535 | cl.leaveGroup(i) 1536 | if wait["lang"] == "JP": 1537 | cl.sendText(msg.to,"Ard bot leaving all groups.") 1538 | else: 1539 | cl.sendText(msg.to,"He declined all invitations") 1540 | 1541 | elif "Group pict" in msg.text.lower(): 1542 | print "[command]steal executing" 1543 | group = cl.getGroup(msg.to) 1544 | path = "http://dl.profile.line-cdn.net/" + group.pictureStatus 1545 | cl.sendImageWithURL(msg.to,path) 1546 | print "[command]steal executed" 1547 | 1548 | elif "Mid @" in msg.text: 1549 | _name = msg.text.replace("Mid @","") 1550 | _nametarget = _name.rstrip(' ') 1551 | gs = cl.getGroup(msg.to) 1552 | for g in gs.members: 1553 | if _nametarget == g.displayName: 1554 | cl.sendText(msg.to, g.mid) 1555 | else: 1556 | pass 1557 | 1558 | elif msg.text.lower() in ["List group"]: 1559 | if msg.from_ in admin: 1560 | gid = cl.getGroupIdsJoined() 1561 | h = "" 1562 | for i in gid: 1563 | h += "%s\n" % (cl.getGroup(i).name +" → ["+str(len(cl.getGroup(i).members))+"]") 1564 | cl.sendText(msg.to,"-- List Groups --\n\n"+ h +"\nTotal groups =" +" ["+str(len(gid))+"]") 1565 | 1566 | elif "Staff add @" in msg.text: 1567 | if msg.from_ in admsa: 1568 | print "[Command]Staff add executing" 1569 | _name = msg.text.replace("Staff add @","") 1570 | _nametarget = _name.rstrip(' ') 1571 | gs = cl.getGroup(msg.to) 1572 | gs = ki.getGroup(msg.to) 1573 | gs = kk.getGroup(msg.to) 1574 | gs = kc.getGroup(msg.to) 1575 | targets = [] 1576 | for g in gs.members: 1577 | if _nametarget == g.displayName: 1578 | targets.append(g.mid) 1579 | if targets == []: 1580 | ki.sendText(msg.to,"Contact not found") 1581 | else: 1582 | for target in targets: 1583 | try: 1584 | admin.append(target) 1585 | cl.sendText(msg.to,"Staff added") 1586 | except: 1587 | pass 1588 | print "[Command]Staff add executed" 1589 | else: 1590 | cl.sendText(msg.to,"Command denied.") 1591 | cl.sendText(msg.to,"Admin permission required.") 1592 | 1593 | elif "Staff remove @" in msg.text: 1594 | if msg.from_ in admsa: 1595 | print "[Command]Staff remove executing" 1596 | _name = msg.text.replace("Staff remove @","") 1597 | _nametarget = _name.rstrip(' ') 1598 | gs = cl.getGroup(msg.to) 1599 | gs = ki.getGroup(msg.to) 1600 | gs = kk.getGroup(msg.to) 1601 | gs = kc.getGroup(msg.to) 1602 | targets = [] 1603 | for g in gs.members: 1604 | if _nametarget == g.displayName: 1605 | targets.append(g.mid) 1606 | if targets == []: 1607 | ki.sendText(msg.to,"Contact not found") 1608 | else: 1609 | for target in targets: 1610 | try: 1611 | admin.remove(target) 1612 | cl.sendText(msg.to,"Staff deleted") 1613 | except: 1614 | pass 1615 | print "[Command]Staff remove executed" 1616 | else: 1617 | cl.sendText(msg.to,"Command denied.") 1618 | cl.sendText(msg.to,"Admin permission required.") 1619 | 1620 | elif msg.text in ["Stafflist","stafflist"]: 1621 | if admin == []: 1622 | cl.sendText(msg.to,"The stafflist is empty") 1623 | else: 1624 | cl.sendText(msg.to,"please wait...") 1625 | mc = "" 1626 | for mi_d in admin: 1627 | mc += "\n- " + cl.getContact(mi_d).displayName 1628 | cl.sendText(msg.to, "Staff :\n" + mc) 1629 | print "[Command]Stafflist executed" 1630 | 1631 | elif msg.text in ["Kernel","kernel"]: 1632 | if msg.from_ in admin: 1633 | botKernel = subprocess.Popen(["uname","-svmo"], stdout=subprocess.PIPE).communicate()[0] 1634 | cl.sendText(msg.to, botKernel) 1635 | print "[Command]Kernel executed" 1636 | 1637 | elif "Apakah " in msg.text: 1638 | tanya = msg.text.replace("Apakah ","") 1639 | jawab = ("Ya","Tidak") 1640 | jawaban = random.choice(jawab) 1641 | cl.sendText(msg.to,jawaban) 1642 | 1643 | if op.type == 55: 1644 | try: 1645 | if op.param1 in wait2['readPoint']: 1646 | Name = cl.getContact(op.param2).displayName 1647 | if Name in wait2['readMember'][op.param1]: 1648 | pass 1649 | else: 1650 | wait2['readMember'][op.param1] += "\n- " + Name 1651 | wait2['ROM'][op.param1][op.param2] = "- " + Name 1652 | else: 1653 | cl.sendText 1654 | except: 1655 | pass 1656 | 1657 | if op.type == 59: 1658 | print op 1659 | 1660 | 1661 | except Exception as error: 1662 | print error 1663 | 1664 | 1665 | def a2(): 1666 | now2 = datetime.now() 1667 | nowT = datetime.strftime(now2,"%M") 1668 | if nowT[14:] in ["10","20","30","40","50","00"]: 1669 | return False 1670 | else: 1671 | return True 1672 | 1673 | def nameUpdate(): 1674 | while True: 1675 | try: 1676 | #while a2(): 1677 | #pass 1678 | if wait["clock"] == True: 1679 | now2 = datetime.now() 1680 | nowT = datetime.strftime(now2,"(%H:%M)") 1681 | profile = cl.getProfile() 1682 | profile.displayName = wait["cName"] 1683 | cl.updateProfile(profile) 1684 | 1685 | profile2 = ki.getProfile() 1686 | profile2.displayName = wait["cName2"] 1687 | ki.updateProfile(profile2) 1688 | 1689 | profile3 = kk.getProfile() 1690 | profile3.displayName = wait["cName3"] 1691 | kk.updateProfile(profile3) 1692 | 1693 | profile4 = kc.getProfile() 1694 | profile4.displayName = wait["cName4"] 1695 | kc.updateProfile(profile4) 1696 | 1697 | profile5 = ks.getProfile() 1698 | profile5.displayName = wait["cName5"] 1699 | ks.updateProfile(profile5a) 1700 | 1701 | profile6 = ka.getProfile() 1702 | profile6.displayName = wait["cName6"] 1703 | ka.updateProfile(profile6) 1704 | 1705 | profile7 = kb.getProfile() 1706 | profile7.displayName = wait["cName7"] 1707 | kb.updateProfile(profile7) 1708 | 1709 | profile8 = ko.getProfile() 1710 | profile8.displayName = wait["cName8"] 1711 | ko.updateProfile(profile8) 1712 | 1713 | profile9 = ke.getProfile() 1714 | profile9.displayName = wait["cName9"] 1715 | ke.updateProfile(profile9) 1716 | 1717 | profile10 = ku.getProfile() 1718 | profile10.displayName = wait["cName10"] 1719 | ku.updateProfile(profile10) 1720 | time.sleep(600) 1721 | except: 1722 | pass 1723 | thread2 = threading.Thread(target=nameUpdate) 1724 | thread2.daemon = True 1725 | thread2.start() 1726 | 1727 | def autolike(): 1728 | for zx in range(0,20): 1729 | hasil = cl.activity(limit=200) 1730 | if hasil['result']['posts'][zx]['postInfo']['liked'] == False: 1731 | try: 1732 | cl.like(hasil['result']['posts'][zx]['userInfo']['mid'],hasil['result']['posts'][zx]['postInfo']['postId'],likeType=1003) 1733 | cl.comment(hasil['result']['posts'][zx]['userInfo']['mid'],hasil['result']['posts'][zx]['postInfo']['postId'],"Auto Like by\nline.me/ti/p/~ardfajrin") 1734 | ki.like(hasil['result']['posts'][zx]['userInfo']['mid'],hasil['result']['posts'][zx]['postInfo']['postId'],likeType=1003) 1735 | kk.like(hasil['result']['posts'][zx]['userInfo']['mid'],hasil['result']['posts'][zx]['postInfo']['postId'],likeType=1003) 1736 | kc.like(hasil['result']['posts'][zx]['userInfo']['mid'],hasil['result']['posts'][zx]['postInfo']['postId'],likeType=1003) 1737 | print "Like" 1738 | except: 1739 | pass 1740 | else: 1741 | print "Already Liked" 1742 | time.sleep(200) 1743 | thread2 = threading.Thread(target=autolike) 1744 | thread2.daemon = True 1745 | thread2.start() 1746 | 1747 | while True: 1748 | try: 1749 | Ops = cl.fetchOps(cl.Poll.rev, 5) 1750 | except EOFError: 1751 | raise Exception("It might be wrong revision\n" + str(cl.Poll.rev)) 1752 | 1753 | for Op in Ops: 1754 | if (Op.type != OpType.END_OF_OPERATION): 1755 | cl.Poll.rev = max(cl.Poll.rev, Op.revision) 1756 | bot(Op) 1757 | --------------------------------------------------------------------------------