class Main: def __init__(self): self.msgcmd = MessageFunction(self) self.action = OperationFunction(self) self.ops = Operation(self) self.sakura = LINE() self.mid = self.sakura.profile.mid self.sett = self.sakura.getSettings() self.help = """mid >>>個人アカウントのid gid >>>グループのid leave >>>グループから抜ける curl >>>グループうらる拒否 ourl >>>グループうらる許可 ginfo >>>グループ情報 gcreator >>>グループ作成者 setpoint >>>既読ポイント設置 delpoint >>>既読ポイント破棄 checkread >>>既読確認 help >>>helpを表示 url >>>追加URLを発行 mid @ >>>メンションした人のmid確認""" self.poll = OEPoll(self.sakura) self.timesleep = {} self.checkread = {} def running(self): while True: try: ops = self.poll.singleTrace(count=50) if ops: for op in ops: self.poll.setRevision(op.revision) self.ops.getOperation(op) except Exception as e: print(e) def check_time(self, to): if to in self.timesleep: if time.time() - self.timesleep[to] < 3: return False else: self.timesleep[to] = time.time() return True
def jnt(op): if op.type == 25: if op.message.text == 'hi': client.sendMessage(op.message.to, 'Hi too !! How are you ?') if op.message.text == "sp": st = time.time() client.getProfile() client.sendMessage(op.message.to, "%s" % (time.time() - st)) client = LINE() oepoll = OEPoll(client) print(client.authToken) while True: try: ops = oepoll.singleTrace(count=50) if ops: for op in ops: try: jnt(op) except Exception: traceback.print_exc() oepoll.setRevision(op.revision) except Exception: traceback.print_exc() exit() except KeyboardInterrupt: sys.exit(1)
if op.type == 25: if op.message.text == "{}reboot".format(clientSettings["prefix"]): rebootMSG = "" if "rebootTime" in clientSettings: totalTime = str(time.time() - clientSettings["rebootTime"]).split(".") totalTime = totalTime[0] + "." + totalTime[1][:2] rebootMSG = " - {} วินาที".format(totalTime) client.sendMessage( op.message.to, "เริ่มระบบใหม่อีกครั้งเรียบร้อยแล้ว{}".format(rebootMSG)) clientSettings["lastOp"] = None else: execute(op) while True: ops = clientPoll.singleTrace(count=100) if ops != None: for op in ops: try: clientSettings["lastOp"] = str(op) execute(op) except Exception as e: clientErrorOrNewPatch.append(e) client.sendMessage( eval(clientSettings["lastOp"]).message.to, "พบข้อผิดพลาดพิมพ์ '{x}error' เพื่อดูข้อผิดพลาด\nหรือพิมพ์ '{x}reboot' เพื่อเริ่มระบบใหม่อีกครั้ง" .format(x=clientSettings["prefix"])) log(str(e)) clientPoll.setRevision(op.revision)
else: client = LINE(showQr=True) except Exception as e: print("Failed to authenticate") print(e) exit(1) ops = OEPoll(client) whitelist = [client.profile.mid, client, ] while True: try: Operation = ops.singleTrace(count=50) if Operation is not None: for op in Operation: ops.setRevision(op.revision) # self.OpInterrupt[op.type], args=(op,) thread1 = threading.Thread(target=LINE_OP_TYPE, args=(op,)) thread1.start() thread1.join() except Exception as error: print(error) def LINE_OP_TYPE(op): if op.type == 25: # sent message message = op.message content = message.text msg_to = message.to msg_from = message._from