def get(self): parser.add_argument('id', type=str, location='args') parser.add_argument('name', type=str, location='args') args = parser.parse_args() token = args['token'] try: id = args['id'] except IndexError : id = False try: name = args['name'] except IndexError : name = False client = LineClient(authToken=token) lineTokenChecker = LineTokenChecker() if (lineTokenChecker.check(client)) : if (id) : profile = str(client.getContactById(id)) elif (name) : profile = str(client.getContactByName(name)) else: lineContactParse = LineContactParse() profile = lineContactParse.parse(client.contacts) return json.loads(profile), 200, {'Access-Control-Allow-Origin': '*'} else : return json.loads(lineTokenChecker.msg),505,{'Access-Control-Allow-Origin': '*'}
def on_login_clicked(self, button): self.status.set_text(('info', "Login...")) self.context.loop.draw_screen() authToken = get_authToken() try: with self.context.lock: client = LineClient(authToken=authToken) context = Context(client=client) context.loop = urwid.MainLoop( MainPage(None, context).page, palette) context.loop.run() except: try: with self.context.lock: self.context.client = LineClient( self.uid.get_edit_text(), self.password.get_edit_text(), com_name=socket.gethostname(), delay=True) except TalkException as e: self.status.set_text(('error', e.reason)) self.context.loop.draw_screen() except Exception as e: self.status.set_text(('error', e.message)) self.context.loop.draw_screen() else: self.go_to_page(PinPage) self.child.verify()
def get(self): parser.add_argument('id', type=str, location='args') parser.add_argument('name', type=str, location='args') args = parser.parse_args() token = args['token'] try: id = args['id'] except IndexError : id = False try: name = args['name'] except IndexError : name = False args = parser.parse_args() token = args['token'] client = LineClient(authToken=token) lineTokenChecker = LineTokenChecker() if (lineTokenChecker.check(client)) : if (id) : groups = client.getGroupById(id) groups = json.dumps(json.loads(str(groups))) elif (name) : groups = client.getGroupByName(name) groups = json.dumps(json.loads(str(groups))) else: groups = client.groups lineGroupParse = LineGroupParse() groups = lineGroupParse.parse(groups) return json.loads(groups), 200, {'Access-Control-Allow-Origin': '*'} else : return json.loads(lineTokenChecker.msg),505,{'Access-Control-Allow-Origin': '*'}
class Line(object): def __init__(self): config = ConfigParser.ConfigParser() config.read(os.path.join(os.path.dirname(__file__), 'config.ini')) email = config.get('LINE', 'email') password = config.get('LINE', 'password') try: self.client = LineClient(email, password) except: print("Line login failed") def updateAuthToken(self): self.client.updateAuthToken() def send(self, target_id, message): try: target = self.client._client.findContactByUserid(target_id) c = LineContact(self.client, target) c.sendMessage(message) except: print("line id not found") def exist_id(self, target_id): try: target = self.client._client.findContactByUserid(target_id) result = True if target else False except: result = False return result
def main(): client = LineClient(authToken=token) for op in client.longPoll(): print op print op[0] print op[1] print op[2] print op[3]
def Login(self): try: self.onInit() self._inst = LineClient(authToken=self.token, com_name=self.cname) self.timeStarted = float(time.time()) self.onLoginSuccessfull() except: self.onLoginFailure()
def get(self): args = parser.parse_args() token = args['token'] client = LineClient(authToken=token) lineTokenChecker = LineTokenChecker() if (lineTokenChecker.check(client)) : profile = str(client.getProfile()) return json.loads(profile), 200, {'Access-Control-Allow-Origin': '*'} else : return json.loads(lineTokenChecker.msg),505,{'Access-Control-Allow-Origin': '*'}
def get(self): parser.add_argument('id', type=str, location='args') args = parser.parse_args() token = args['token'] try: id = args['id'] except IndexError : return {} , 506, {'Access-Control-Allow-Origin': '*'} client = LineClient(authToken=token) lineTokenChecker = LineTokenChecker() if (lineTokenChecker.check(client)) : try : if (id[0] =='u'): contact = client.getContactById(id) if contact : message = client.getMessageBox(id) msg ={} msg["status"] = message.status msg["unreadCount"] = message.unreadCount msg["lastSeq"] = message.lastSeq lastMessages = {} msg["lastMessages"]= (message.lastMessages[0].__dict__) msg["midType"] = message.midType msg["channelId"] = message.channelId, msg["lastModifiedTime"] = message.lastModifiedTime msg["id"] = message.id return msg, 200, {'Access-Control-Allow-Origin': '*'} else : return {'status':'failure','msg':'找不到使用者'}, 500, {'Access-Control-Allow-Origin': '*'} elif (id[0] =='c'): group = client.getGroupById(id) if group : message = client.getMessageBox(id) msg ={} msg["status"] = message.status msg["unreadCount"] = message.unreadCount msg["lastSeq"] = message.lastSeq lastMessages = {} msg["lastMessages"]= (message.lastMessages[0].__dict__) msg["midType"] = message.midType msg["channelId"] = message.channelId, msg["lastModifiedTime"] = message.lastModifiedTime msg["id"] = message.id return msg, 200, {'Access-Control-Allow-Origin': '*'} else : return {'status':'failure','msg':'找不到使用者'}, 500, {'Access-Control-Allow-Origin': '*'} else : return {'status':'failure','msg':'錯誤的id'}, 500, {'Access-Control-Allow-Origin': '*'} except Exception : print Exception return {'status':'failure'}, 500, {'Access-Control-Allow-Origin': '*'} else : return json.loads(lineTokenChecker.msg),505,{'Access-Control-Allow-Origin': '*'}
def send_to_line(message, image): """Send message and image to Line Messanger.""" try: client = LineClient(conf.LINE_USERNAME, conf.LINE_PASSWORD) myline = client.getProfile() myline.sendMessage(message) myline.sendImage(image) return True except: pass return False
def auth(_id, _password, _token=None): try: if _token == None: print "ID:" + _id print "password:"******"auth Failed" raise
def execute(self, deviceData, mqttClient=None): print 'Run LineControl.......' d_Data = deviceData['DeviceData'] temp_c = float(d_Data['Temperature_C']) msgPlainTxt = "Warning message from IOT platform: current temperature is over threshold:" + str( temp_c) # Initial Line client client = LineClient( authToken= 'DOFM6cNhM8VIuKmyOXK2.azad0AlpxQy6iJzh2pQLqG.By8oDIYL8bQ8KNscNnygUVN7HngF0vweWFwHG1lGyII=' ) friend = client.getContactFromName('Wester') friend.sendMessage(msgPlainTxt) return None
def __init__(self, id=None, password=None, authToken=None): if not (id and password or authToken): msg = "`id` and `password` or `authToken` is needed" raise Exception(msg) self._session = requests.Session() self.talk = Talk(self.name, self.creator, self._session) self.id = id self.password = password if authToken: self.line = LineClient(authToken=authToken) else: self.line = LineClient(self.id, self.password)
def __init__(self): config = ConfigParser.ConfigParser() config.read(os.path.join(os.path.dirname(__file__), 'config.ini')) email = config.get('LINE', 'email') password = config.get('LINE', 'password') try: self.client = LineClient(email, password) except: print("Line login failed")
def post(self): parser.add_argument('id', type=str, location='form') parser.add_argument('message', type=str, location='form') args = parser.parse_args() token = args['token'] try: id = args['id'] except IndexError : return {"message": "沒有傳入Id"} , 506, {'Access-Control-Allow-Origin': '*'} try: message = args['message'] except IndexError : return {"message": "message"} , 506, {'Access-Control-Allow-Origin': '*'} client = LineClient(authToken=token) lineTokenChecker = LineTokenChecker() if (lineTokenChecker.check(client)) : try : if (id[0] =='u'): contact = client.getContactById(id) if contact : res = contact.sendMessage(message) return {'status':'success'}, 200, {'Access-Control-Allow-Origin': '*'} else : return {'status':'failure','msg':'找不到使用者'}, 500, {'Access-Control-Allow-Origin': '*'} elif (id[0] =='c'): group = client.getGroupById(id) if group : res = group.sendMessage(message) return {'status':'success'}, 200, {'Access-Control-Allow-Origin': '*'} else : return {'status':'failure','msg':'找不到群組'}, 500, {'Access-Control-Allow-Origin': '*'} else: return {'status':'failure','msg':'錯誤的Id'}, 500, {'Access-Control-Allow-Origin': '*'} except Exception : print Exception return {'status':'failure'}, 500, {'Access-Control-Allow-Origin': '*'} else : return json.loads(lineTokenChecker.msg),505,{'Access-Control-Allow-Origin': '*'}
def run_bot(): try: client = LineClient(EMAIL, PASSWORD) # client = LineClient(authToken=token) except: print "Login Failed" print "===START SERVER===" while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0] receiver = op[1] message = op[2] cr = CekResi(message.text) print "RESI %s" % message.text response = cr.post() msg = response sender.sendMessage("[%s] %s" % (sender.name, msg))
def linelogin(): try: print "[%s] [Login] [%s] - Start login line client" % (str( datetime.now()), botname) client = LineClient(botuser, botpass, authToken=None, is_mac=False, com_name=botlog, bypass=True) print "[%s] [Login] [%s] - Login Success" % (str( datetime.now()), botname) authToken = client.authToken print "[%s] [Login] [%s] - AuthToken=%s" % (str( datetime.now()), botname, authToken) except: print "[%s] [Login] [%s] - Login Fail" % (str(datetime.now()), botname) return
class Black(object): prefix = "!" name = "검정봇" creator = "carpedm20" def __init__(self, id=None, password=None, authToken=None): if not (id and password or authToken): msg = "`id` and `password` or `authToken` is needed" raise Exception(msg) self._session = requests.Session() self.talk = Talk(self.name, self.creator, self._session) self.id = id self.password = password if authToken: self.line = LineClient(authToken=authToken) else: self.line = LineClient(self.id, self.password) def run(self): ops = [] for op in self.line.longPoll(): ops.append(op) for op in ops: sender = op[0] receiver = op[1] message = op[2] try: if message.text[0] == self.prefix: response = self.talk.get_message(sender, receiver, message.text[1:]) receiver.sendMessage(response) else: pass except Exception as e: print e
from line import LineClient, LineGroup, LineContact try: client = LineClient("*****@*****.**", "bot1line1") #client = LineClient(authToken="AUTHTOKEN") except: print "Login Failed" while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0] receiver = op[1] message = op[2] msg = message.text receiver.sendMessage("[%s] %s" % (sender.name, msg)) if msg = "hoiii" receiver.sendMessage('contoh cari : lirik once-dealova')
def GetLineAuthToken(username, password): return LineClient(username, password).authToken;
# -*- coding: utf-8 -*- from line import LineClient from os import environ import re import time try: LINE_USERNAME = environ.get("LINE_USERNAME", "") LINE_PASSWORD = environ.get("LINE_PASSWORD", "") LINE_COMPUTER_NAME = environ.get("LINE_COMPUTER_NAME", "LineBotWorker") client = LineClient(id=LINE_USERNAME, password=LINE_PASSWORD, com_name=LINE_COMPUTER_NAME) print "Connected" if client.verifier: print client.verifier, client.pinCode except Exception as e: print "Login Failed\n", e.message exit() while True: group = client.getGroupByName("LineBotWorker") chat = client.getMessageBox(group.id) if not chat or not chat.unreadCount: continue messages = client.getRecentMessages(chat, chat.unreadCount) messages.reverse() for message in messages: if re.match(r'(เล้ง|เลิ้ง|เลี้ยง)', message.text): group.sendMessage("ว่าไงครัซซ") break time.sleep(5)
from line import sys, LineClient, LineGroup, LineContact try: client = LineClient( authToken= "DPg6LCpab578tZrNzCvf.GecCs48wBQyh1HX4GyKvRW.9wWXZUysh3o02y0J6H2N8tge/0AhOBf6C5vIugtL6YQ=" ) except: print "Login Failed" while True: #print client.contacts client.contacts[4].sendMessage(sys.argv[1]) #print "Message sent." break
from line import LineClient, LineGroup, LineContact import re import regexp import WebCrawler import weather KeyFile = open("token", "r") AuthToken = KeyFile.read().strip() try: client = LineClient(authToken=AuthToken) except: print "Hey Login Failed" while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0] receiver = op[1] message = op[2] msg = message.text print str(receiver) + "\t" + str(sender) + "\t" + str(message) m = regexp.REMatcher(msg) if str(msg).strip() == "None": print("It's a Sticker")
#search('Pachara') USERNAME = '' PASSWORD = '' GROUPNAME = 'Evolution CS #13' GROUPNAME1 = 'Test' MSG = '' #optional COMPUTERNEME = 'bot yo' #TOKEN = 'DV0yPSYwYQe1dLNZhJn1.oxhXCYbL5mot1nyKC+t0eq.w/+1EMvF/1L8/7Ht+UY852MvgUyv/xoZ0MvGLeg7+nI=' TOKEN = '' try: client = LineClient(id=USERNAME, password=PASSWORD, authToken=TOKEN, com_name=COMPUTERNEME) group = client.getGroupByName(GROUPNAME1) print client.groups print TOKEN #client = LineClient(authToken='DV7I8leLWjKGX086Wtz1.oxhXCYbL5mot1nyKC+t0eq.ZMI9FeewbGOhkGJrj/8Adr4o0e+25v4bwf3opBJuhZU=') except: print "Login Failed" print 'Bot Ready !!!' while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list:
botpass = arg elif opt in ("-l", "--listen"): port = int(arg) else: usage() except: usage() # Verify User & Password input if (botuser == None) or (botpass == None): usage() # Login line account try: print "[%s] [%s] [Initial] Start login line client" % (str(datetime.now()), botuser) client = LineClient(botuser, botpass) print "[%s] [%s] [Initial] Login Success" % (str(datetime.now()), botuser) except: print "[%s] [%s] [Initial] Login Fail" % (str(datetime.now()), botuser) raise #------------------------------------------------------------------------------- # M A I N P R O G R A M #------------------------------------------------------------------------------- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((host,port)) s.listen(backlog) print "[%s] [%s] [Initial] Establish socket listener on port %i" % (str(datetime.now()), botuser, port)
from selenium import webdriver from selenium.webdriver.common.keys import Keys import time import sys USERNAME = '******' PASSWORD = '' GROUPNAME = 'Bnz' MYID = 'forgetz' #optional COMPUTERNEME = 'Bnz-PC' TOKEN = '' try: client = LineClient(id=USERNAME, password=PASSWORD) TOKEN = client.authToken print "TOKEN : %s\r\n" % TOKEN except Exception as ex: print "Login Failed" print ex exit() client_group = client.getGroupByName(GROUPNAME) client_group.sendMessage("Hello!!") recent_group_msg = client_group.getRecentMessages(count=10) print "RecentMessages : %s\r\n" % recent_group_msg while True:
hosts = os.path.join(scriptDir, 'hosts.txt') hostsFile = open(hosts, "r") lines = hostsFile.readlines() if plat == "Windows": for line in lines: line = line.strip() ping = subprocess.Popen( ["ping", "-n", "1", "-l", "1", "-w", "100", line], stdout = subprocess.PIPE, stderr = subprocess.PIPE ) out, error = ping.communicate() client = LineClient(user , passw) kitti = client.groups[No] kitti.sendMessage(out) if plat == "Linux": for line in lines: line = line.strip( ) line = line.strip( ) ping = subprocess.Popen( ["ping", "-c", "1", "-l", "1", "-s", "1", "-W", "1", line], stdout = subprocess.PIPE, stderr = subprocess.PIPE )
class LineLib(object): def __init__(self): self._inst = None self.token = None self.cname = "Ubuntu" self.timeStarted = None self.sleep = 0.2 self.autoAcceptInviteTimer = 20 self._tasks = {} self.Login() def setInterval(self, interval, func, *args, **kw): """ runs every x seconds @interval: seconds until run @func: function to call once interval has been reached @args: function arguments @example1: self.setInterval(3, function, pr1, pr2) @example2: self.setInterval(3, function) returns the task you can use this to cancel using the cancel() method """ task = _Task(interval, func, *args, **kw) task.interval() return task def setTimeout(self, interval, func, *args, **kw): """ @interval: seconds until run @func: function to call once interval has been reached @args: function arguments @example1: self.setTimeout(3, function, pr1, pr2) @example2: self.setTimeout(3, function) returns the task you can use this to cancel using the cancel() method """ task = _Task(interval, func, *args, **kw) task.timeout() return task def setIntervalByName(self, name, interval, func, *args, **kw): if name in self._tasks.keys(): return False else: self._tasks[name] = self.setInterval(interval, func, *args, **kw) return True def setTimeoutByName(self, name, interval, func, *args, **kw): if name in self._tasks.keys(): return False else: self._tasks[name] = self.setTimeout(interval, func, *args, **kw) return True def getTaskByName(self, name): """ @name: name of task returns the task set by a name """ if name in self._tasks.keys(): return self._tasks[name] def Login(self): try: self.onInit() self._inst = LineClient(authToken=self.token, com_name=self.cname) self.timeStarted = float(time.time()) self.onLoginSuccessfull() except: self.onLoginFailure() def getRooms(self): return self._inst.rooms def getGroups(self): return self._inst.groups def getContacts(self): return self._inst.contacts def sendImage(self, recv, url): recv.sendImageWithUrl(url) def getRecentMessages(self, recv, count): return recv.getRecentMessages(count) def acceptAll(self): for grp in self.getGroups(): try: grp.acceptGroupInvitation() except: pass def main(self): self.setIntervalByName("acceptAll", self.autoAcceptInviteTimer, self.acceptAll) while True: task.do_all_tasks() # we use the loop to our avantage :) ops = [] for op in self._inst.longPoll(): ops.append(op) for op in ops: sender = op[0] recv = op[1] message = op[2] self.onMessage(recv, sender, message) time.sleep(self.sleep) def onMessage(self, recv, user, msg): pass """ @recv: needed to send the message. It probably has other uses but, not sure yet. @user: this holds the user info @msg: this holds the msg info """ def onLoginSuccessFull(self): pass """ basically says we were able to connect """ def onLoginFailure(self): pass """ basically it means we failed to connect most likely due to a bad token """ def onInit(self): pass """ this just allows us to set some params """ def cred(self): return """
def lineLogin(data): self = lineDemo(data) """Login to LINE server.""" j = self.get_json(self.LINE_SESSION_LINE_URL) session_key = j['session_key'] message = (chr(len(session_key)) + session_key + chr(len(self.id)) + self.id + chr(len(self.password)) + self.password).encode('utf-8') keyname, n, e = j['rsa_key'].split(",") pub_key = rsa.PublicKey(int(n,16), int(e,16)) crypto = rsa.encrypt(message, pub_key).encode('hex') self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL) self.transport.setCustomHeaders(self._headers) self.protocol = TCompactProtocol.TCompactProtocol(self.transport) self._client = CurveThrift.Client(self.protocol) msg = self._client.loginWithIdentityCredentialForCertificate( self.id, self.password, keyname, crypto, False, self.ip, self.com_name, self.provider, "") self._headers['X-Line-Access'] = msg.verifier self._pinCode = msg.pinCode message = "Enter PinCode '%s' to your mobile phone in 2 minutes"\ % self._pinCode yield message print message j = self.get_json(self.LINE_CERTIFICATE_URL) self.verifier = j['result']['verifier'] msg = self._client.loginWithVerifierForCertificate(self.verifier) if msg.type == 1: self.certificate = msg.certificate self.authToken = self._headers['X-Line-Access'] = msg.authToken client = LineClient(authToken= self.authToken) authToken = msg.authToken id = str(client.getProfile().id) email = str(self.id) yield '<BR>ID :'+ id conn = sqlite3.connect('line_api.db') c = conn.cursor() c.execute("SELECT count(line_id) FROM line_authtoken WHERE line_id = '"+id+"'") count = c.fetchone() if (count[0] == 0 ) : c.execute("INSERT INTO line_authtoken (line_id, email, line_authtoken ) VALUES ('"+id+"','"+email+"','"+authToken+"')") else: c.execute("UPDATE line_authtoken SET line_authtoken = '"+msg.authToken+"' ") conn.commit() yield '<br> Your Token is <br> <textarea readonly="readonly" cols="20" rows="5">'+ authToken+'</textarea>' return elif msg.type == 2: msg = "require QR code" self.raise_error(msg) else: msg = "require device confirm" self.raise_error(msg) return
file_array.append(os.path.join(dirPath, f)) #append the file name to array save to next time for use File_len=len(file_array) #the file array len in this variable for i in range(File_len): Msg_Str=io.open(file_array[i], 'r',encoding = 'utf-8') #the Txt location Msg_Str_contant.append(Msg_Str.read()) Read_Txt() #client = LineClient(authToken="") Line_user=Txt_io(0) Line_pass=Txt_io(1) print u"需驗證的使用者: ",Line_user client = LineClient(Line_user,Line_pass) #print client.authToken #print the Line access token #client.contacts[13].sendMessage("Test") #Send message to user Len_Msg_Arr=len(Msg_Str_contant) #User want to send message array all_friend=len(client.contacts) #total user friend Select_user_send(all_friend,Len_Msg_Arr) #send all friend print u"傳送成功"
import re import urllib2 from line import LineClient, LineGroup, LineContact try: client = LineClient("*****@*****.**", "saintzreddevil02") #client = LineClient(authToken="AUTHTOKEN") except: print "Login Failed" while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0] receiver = op[1] message = op[2] msg = message.text url = re.findall(r"(http://.+)", msg)[0] if url: req = urllib2.urlopen(url).read() title = re.findall(r'<title>(.+?)<\/title>', req)[0] receiver.sendMessage("[title] %s" % (str(title))) else: pass ''' if msg == None:
from line import LineClient, LineGroup, LineContact try: client = LineClient() #client = LineClient(authToken="") except Exception as error: print(error) while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0] receiver = op[1] message = op[2] msg = message text = msg.text to = msg.to dari = msg._from if msg.toType == 0 or msg.toType == 1 or msg.toType == 2: if msg.toType == 0: if sender != client.getProfile().id: to = dari else: to = to elif msg.toType == 1: to = to
pfilename = "%s/%s.pid" % ( logfolder, pidid) if os.path.isfile(pfilename): errmsg = "NAIBOT (Code name: NAI - %s) is running" % pidid logging.info(errmsg) exit(0) else: pfile = open(pfilename,'w') pfile.write(str(PID)) pfile.close() try: if LoginMethod: client = LineClient(authToken=LineToken, is_mac=1, com_name="NaiBot") else: client = LineClient(LineLogin, LinePassword, is_mac=1, com_name="NaiBot") except: print "Login Failed" client.ready() ### Notify Bot Start ### boss = client.getContactOrRoomOrGroupById(NAIBOSS) ext_ip = ipgetter.myip()
# -*- coding: utf-8 -*- """ 列出朋友與群組的ID List 注意有可能每次朋友的ID List都會變化, 例如可能新加好友就會發生變化. """ from line import LineClient, LineGroup, LineContact # Line API model for i in open('authToken.txt'): ID = i try: z = LineClient(authToken=ID) # 登入後的authToken except: print "Login Failed" # users的list print u"朋友的ID List" i = 0 while i < len(z.contacts): print i, z.contacts[i] i += 1 print '\n' # Groups的list print u"群組的ID List" i = 0 while i < len(z.groups): print i, z.groups[i]
from line import LineClient, LineGroup, LineContact USERNAME = '' PASSWORD = '' GROUPNAME = 'Evolution CS #13' MSG = 'test' #optional COMPUTERNEME = 'yo' #TOKEN = 'DV0yPSYwYQe1dLNZhJn1.oxhXCYbL5mot1nyKC+t0eq.w/+1EMvF/1L8/7Ht+UY852MvgUyv/xoZ0MvGLeg7+nI=' TOKEN = '' try: client = LineClient(id=USERNAME, password=PASSWORD, authToken=TOKEN, com_name=COMPUTERNEME) #TOKEN = client.authToken print "TOKEN : %s\r\n" % TOKEN client_group = client.getGroupByName(GROUPNAME) recent_group_msg = client_group.getRecentMessages(count=10) print "RecentMessages : %s\r\n" % recent_group_msg client_group.sendMessage(MSG) except: print "Login Failed"
from suds.client import Client from line import LineClient, LineGroup, LineContact from config import * from function import * import time configlist = config_list() GROUPNAME = configlist[2] TOKEN = '' try: lineclient = LineClient(id=configlist[0], password=configlist[1], authToken=TOKEN) TOKEN = lineclient.authToken print "TOKEN : %s\r\n" % TOKEN except: print "Login Failed\r\n" exit() url = 'http://10.10.150.187/PythonService/line.asmx?WSDL' client = Client(url) client_group = lineclient.getGroupByName(GROUPNAME) client_group.sendMessage("Login Complete!!") #recent_group_msg = client_group.getRecentMessages(count=10) #print "RecentMessages : %s\r\n" % recent_group_msg while True:
from line import LineClient, LineGroup, LineContact try: client = LineClient("email ID line", "password") #client = LineClient(authToken="AUTHTOKEN") except: print "Login Failed" while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0] receiver = op[1] message = op[2] msg = message.text receiver.sendMessage("[%s] %s" % (sender.name, msg))
# coding: utf-8 """ :copyright: (c) 2014 by Taehoon Kim. :license: BSD, see LICENSE for more details. このライブラリはTaehoon Kim氏が開発し、Sh1maが改良したライブラリです。 """ from line import LineClient, PollManager from LineThrift.ttypes import Message try: client = LineClient(authToken="") print("{}: Login Success".format(client.profile.displayName)) except Exception as e: print(e) fetch = PollManager(client) def sendMessage(text, to, _from, toType=0, contentMetadata=0): msg = Message() if to[0] == "c": msg.to = to msg._from = _from msg.toType = 2 elif to[0] == "u": msg.to = _from
# original: https://github.com/carpedm20/LINE/blob/master/examples/echobot.py from line import LineClient, LineGroup, LineContact from curve.ttypes import TalkException import os try: line_id = os.environ["LINE_CLIENT_ID"] line_pass = os.environ["LINE_CLIENT_PASS"] except KeyError: print "Environment variables not found" exit(0) try: client = LineClient(line_id, line_pass, com_name=os.uname()[1], is_mac=False) client = LineClient(authToken=client.authToken, com_name=os.uname()[1], is_mac=False) except TalkException as e: print "Login Failed:", e.reason exit(0) else: print "Login successful" while client is not None: op_list = [] try: for op in client.longPoll():
import subprocess, re, os from line import LineClient, LineGroup, LineContact, LineAPI try: client = LineClient("bot1line1@yopmail", "bot1line123") print client.authToken except: print "Login Failed" while True: op_list = [] timeSeen = [] appendSeen = [] dataResult = [] #recheck userList = [] timelist = [] contacts = [] recheckData = [] #cancelAll myListMember = [] #getFriend list @ listFriend = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0]
import line from line import models, api, client, LineClient, LineGroup, LineContact try: client = LineClient("christ.revolusioner", "satuaja1") #client = LineClient(authToken = "AUTHTOKEN") except: print "Login Failed" while True: op_list = [] for op in client.longPoll(): op_list.append(op) for op in op_list: sender = op[0] receiver = op[1] message = op[2] msg = message.text receiver.sendMessage("[%s] %s" % (sender.name, msg))
def GetLineAuthToken(username, password): return LineClient(aallen258963 @ gmail.com, k112711271127).authToken
if __name__ == "__main__": from os.path import expanduser home = expanduser("~") session_file = "%s/LINE.session" % home com_name = __file__ session = None try: session = file(session_file,"r").read() print "Loaded AuthToken: %s" % session except IOError as e: client = None if session: try: print "Trying login..." client = LineClient(authToken=session,com_name=com_name) except Exception as e: print e client = None if client is None: print "falling back to manual login..." try: USR_LINE_ID = raw_input("Enter your LINE ID(e-mail): ").strip() USR_LINE_PASSWORD = getpass.getpass("Enter your LINE PASSWORD: "******"Login Failed ERROR: %s" % e if client is None: exit(-1) print "Your authtoken is : %s" % client.authToken with open(session_file,"w") as f:
AS = '' # Accesss Token Secert url = "https://api.twitter.com/1.1/statuses/update.json" def tweet(text): params = {"status": text} twitter = OAuth1Session(CK, CS, AT, AS) req = twitter.post(url, params = params) if req.status_code == 200: print "OK" else: print "Error: %d" % req.status_code try: client = LineClient(mail, password) #メアド, パス #authToken = client.authToken #print authToken #client = LineClient(authToken="トークン") print "Logined" except: print "Login Failed" cnt = 0 for i in client.contacts: if str(i)[13:-1] == "twitter": #ユーザー名「twitter」を探す(サブ垢) print cnt,str(i)[13:-1] break cnt+=1 friend = client.contacts[cnt]
from line import LineClient, LineGroup, LineContact USERNAME = "" PASSWORD = "" GROUPNAME = "Evolution CS #13" MSG = "test" # optional COMPUTERNEME = "yo" # TOKEN = 'DV0yPSYwYQe1dLNZhJn1.oxhXCYbL5mot1nyKC+t0eq.w/+1EMvF/1L8/7Ht+UY852MvgUyv/xoZ0MvGLeg7+nI=' TOKEN = "" try: client = LineClient(id=USERNAME, password=PASSWORD, authToken=TOKEN, com_name=COMPUTERNEME) # TOKEN = client.authToken print "TOKEN : %s\r\n" % TOKEN client_group = client.getGroupByName(GROUPNAME) recent_group_msg = client_group.getRecentMessages(count=10) print "RecentMessages : %s\r\n" % recent_group_msg client_group.sendMessage(MSG) except: print "Login Failed"