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 auth(_id, _password, _token=None): try: if _token == None: print "ID:" + _id print "password:"******"auth Failed" raise
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 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 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 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 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
# -*- 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 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 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
# 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():
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))
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"
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:
self.gen_button_attrmap(login, 'submit'), self.gen_button_attrmap(exit, 'cancel') ])) return self.gen_top(self.gen_padding(listbox)) def get_authToken(): authToken = None try: json_data = open('.pyline') data = json.load(json_data) authToken = data['authToken'] json_data.close() except: pass return authToken if __name__ == '__main__': authToken = get_authToken() try: client = LineClient(authToken=authToken) context = Context(client=client) context.loop = urwid.MainLoop(MainPage(None, context).page, palette) context.loop.run() except: context = Context() context.loop = urwid.MainLoop(LoginPage(None, context).page, palette) context.loop.run()
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]
# 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
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')
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))
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 )
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"傳送成功"
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:
res = '1 [Line group is not exist]' pass return res #------------------------------------------------------------------------------- # I N I T I A L P R O G R A M #------------------------------------------------------------------------------- # Login line account try: print "[%s] [%s] [Initial] Start login line client" % (str( datetime.now()), botuser) client = LineClient(botuser, botpass, authToken=None, is_mac=False, com_name=botcom, bypass=True) print "[%s] [%s] [Initial] Login Success" % (str(datetime.now()), botuser) authToken = client.authToken print "[%s] [Login] [%s] - AuthToken=%s" % (str( datetime.now()), botuser, authToken) 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)
def GetLineAuthToken(username, password): return LineClient(username, password).authToken;
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:
def GetLineAuthToken(username, password): return LineClient(aallen258963 @ gmail.com, k112711271127).authToken
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)
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]
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: