From fefe1ca4612517689d8dd7b579551a5a8e7df988 Mon Sep 17 00:00:00 2001 From: SuperSonic Date: Sat, 7 Sep 2019 16:43:11 +0800 Subject: [PATCH 1/5] v6.5.1_RC2 --- libs/i18n/__init__.py | 2 +- libs/i18n/en.py | 4 +++- libs/i18n/zh_TW.py | 4 +++- libs/yuuki.py | 18 ++++++++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libs/i18n/__init__.py b/libs/i18n/__init__.py index a82e0eb..2385a53 100644 --- a/libs/i18n/__init__.py +++ b/libs/i18n/__init__.py @@ -18,7 +18,7 @@ class Yuuki_LangSetting: return self.support[lang].i18nText[text] return self.support[self.default].i18nText[text] except KeyError: - return text + "\n\n{\n\tLanguage Package is not Work.\n\tPlease inform the Admin of the Yuuki.\n}" + return text + "\n\n{\n\tLanguage Package not work.\n\tPlease inform the Admin of the Yuuki.\n}" def _(self, text, lang=None): return self.gettext(text, lang) diff --git a/libs/i18n/en.py b/libs/i18n/en.py index cd63453..4839284 100644 --- a/libs/i18n/en.py +++ b/libs/i18n/en.py @@ -27,6 +27,7 @@ class English: "LINE System UserID:\n": "LINE System UserID:\n", "SecurityService of %s was disable": "SecurityService of %s was disable", "DO NOT KICK, thank you ^^": "DO NOT KICK, thank you ^^", + "Notice: Unknown command line argument(s)": "Notice: Unknown command line argument(s)", "DO NOT ENABLE THE GROUP URL STATUS, see you...": "DO NOT ENABLE THE GROUP URL STATUS, see you...", "Do not invite anyone...thanks": "Do not invite anyone...thanks", "The User(s) was in our blacklist database.": "The User(s) was in our blacklist database.", @@ -36,10 +37,11 @@ class English: "Kick Limit.": "Kick Limit.", "Cancel Limit.": "Cancel Limit.", "Testing...": "Testing...", - "Speed:\n%ss": "Speed:\n%ss", + "Speed:\n %s com/s": "Speed:\n %s com/s", "Bye Bye": "Bye Bye", "Not Found": "Not Found", "Okay": "Okay", + "Unknown": "Unknown", "Exit.": "Exit.", "Added": "Added" } diff --git a/libs/i18n/zh_TW.py b/libs/i18n/zh_TW.py index 88a4ad1..6ff6c20 100644 --- a/libs/i18n/zh_TW.py +++ b/libs/i18n/zh_TW.py @@ -27,6 +27,7 @@ class Traditional_Chinese: "LINE System UserID:\n": "LINE用戶識別碼:\n", "SecurityService of %s was disable": "%s的安全防護模式被已關閉", "DO NOT KICK, thank you ^^": "請不要踢人,謝謝 =3=", + "Notice: Unknown command line argument(s)": "提醒:未知的指令參數", "DO NOT ENABLE THE GROUP URL STATUS, see you...": "請不要開啟群組網址,再見了 0.0", "Do not invite anyone...thanks": "請不要邀請任何人,感謝配合 OwO", "The User(s) was in our blacklist database.": "這個臭小子在我們的黑名單中 =.=", @@ -36,10 +37,11 @@ class Traditional_Chinese: "Kick Limit.": "踢人次數已達上限", "Cancel Limit.": "取消次數已達上限", "Testing...": "測試中...", - "Speed:\n%ss": "速度為:\n%ss", + "Speed:\n %s com/s": "速度為:\n%s 指令/秒", "Bye Bye": "掰掰 ><", "Not Found": "404 不存在 0.0...", "Okay": "好的", + "Unknown": "未知", "Exit.": "已退出", "Added": "已增加" } diff --git a/libs/yuuki.py b/libs/yuuki.py index e5e7c89..ed5e471 100644 --- a/libs/yuuki.py +++ b/libs/yuuki.py @@ -19,7 +19,7 @@ class Yuuki_Settings: config = { "name": "Yuuki", - "version": "v6.5.1_RC1", + "version": "v6.5.1_RC2", "project_url": "https://tinyurl.com/syb-yuuki", "man_page": "https://tinyurl.com/yuuki-manual", "privacy_page": "OpenSource - Licensed under MPL 2.0", @@ -437,7 +437,7 @@ class Yuuki: Time1 = time.time() self.sendText(self.sendToWho(ncMessage), _("Testing...")) Time2 = time.time() - self.sendText(self.sendToWho(ncMessage), _("Speed:\n%ss") % (Time2 - Time1,)) + self.sendText(self.sendToWho(ncMessage), _("Speed:\n %s com/s") % (Time2 - Time1,)) elif self.YuukiConfigs["name"] + '/SecurityMode' == msgSep[0]: if ncMessage.message.from_ in self.Admin: if len(msgSep) == 2: @@ -458,16 +458,26 @@ class Yuuki: _("SecurityService of %s was disable") % (self.YuukiConfigs["name"],)) elif ncMessage.message.from_ in GroupPrivilege: status = [] + unknown_msg = [] + unknown_msgtext = "" for code in msgSep: try: status.append(int(code)) except: - pass + unknown_msg.append(code.replace(" ", "")) self.configSecurityStatus(ncMessage.message.to, status) + if unknown_msg != []: + for count, msg in enumerate(unknown_msg): + if count+1 == len(unknown_msg) and count != 0: + unknown_msgtext += msg + elif count != 0: + unknown_msgtext += (msg + ", ") if status != []: self.sendText(self.sendToWho(ncMessage), _("Okay")) else: self.sendText(self.sendToWho(ncMessage), _("Not Found")) + if unknown_msgtext != "": + self.sendText(self.sendToWho(ncMessage), _("Notice: Unknown command line argument(s)") + "\n({})".format(unknown_msgtext)) elif self.YuukiConfigs["name"] + '/DisableAll' == ncMessage.message.text: if ncMessage.message.toType == MIDType.GROUP: GroupInfo = self.getClient(self.MyMID).getGroup(ncMessage.message.to) @@ -511,7 +521,7 @@ class Yuuki: status_added.append(member.mid) for userId in self.data.getGroup(GroupInfo.id)["Ext_Admin"]: if userId not in status_added: - status += "Unknown: {}\n".format(userId) + status += "{}: {}\n".format(_("Unknown"), userId) self.sendText(self.sendToWho(ncMessage), status + _("\nExtend Administrator(s)")) else: self.sendText(self.sendToWho(ncMessage), _("Not Found")) From b916190bbbafb8314748893185e478e49582b5e1 Mon Sep 17 00:00:00 2001 From: SuperSonic Date: Sat, 7 Sep 2019 17:07:08 +0800 Subject: [PATCH 2/5] v6.5.1_RC2 --- libs/yuuki.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libs/yuuki.py b/libs/yuuki.py index ed5e471..823cf45 100644 --- a/libs/yuuki.py +++ b/libs/yuuki.py @@ -462,7 +462,10 @@ class Yuuki: unknown_msgtext = "" for code in msgSep: try: - status.append(int(code)) + if int(code) <= 3: + status.append(int(code)) + else: + unknown_msg.append(code.replace(" ", "")) except: unknown_msg.append(code.replace(" ", "")) self.configSecurityStatus(ncMessage.message.to, status) @@ -546,6 +549,24 @@ class Yuuki: self.sybGetGroupCreator(GroupInfo).displayName, ) self.sendText(self.sendToWho(ncMessage), status) + elif self.YuukiConfigs["name"] + '/GroupBackup' == ncMessage.message.text: + if ncMessage.message.toType == MIDType.GROUP: + GroupInfo = self.getClient(self.MyMID).getGroup(ncMessage.message.to) + GroupPrivilege = self.Admin + [self.sybGetGroupCreator(GroupInfo).mid] + self.data.getGroup(GroupInfo.id)["Ext_Admin"] + if ncMessage.message.from_ in GroupPrivilege: + GroupMembers = [User.mid for User in GroupInfo.members] + GroupInvites = None + if GroupInfo.invitee: + GroupInvites = [User.mid for User in GroupInfo.invitee] + LayoutInfo = { + "OriginID": GroupInfo.id, + "Members": GroupMembers, + "Invites": GroupInvites + } + self.sendText(ncMessage.message.from_, GroupInfo.name) + self.sendText(ncMessage.message.from_, json.dumps(LayoutInfo)) + self.sendText(ncMessage.message.to, _("Okay")) + elif self.YuukiConfigs["name"] + '/Quit' == ncMessage.message.text: if ncMessage.message.toType == MIDType.GROUP: GroupInfo = self.getClient(self.MyMID).getGroup(ncMessage.message.to) From e9ec09af52e032d5e05ce9bbab18e7238515433a Mon Sep 17 00:00:00 2001 From: SuperSonic Date: Sat, 7 Sep 2019 19:10:03 +0800 Subject: [PATCH 3/5] v6.5.1_RC2 --- libs/yuuki.py | 80 ++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/libs/yuuki.py b/libs/yuuki.py index 823cf45..2b274e8 100644 --- a/libs/yuuki.py +++ b/libs/yuuki.py @@ -135,7 +135,7 @@ class Yuuki: return replymsg def checkInInvitationList(self, ncMessage, userId=None): - if userId == None: + if userId is None: userId = self.MyMID if ncMessage.param3 == userId: inList = True @@ -153,11 +153,11 @@ class Yuuki: for key in group.__dict__: if key != "members" or key != "invitee": result.__dict__[key] = group.__dict__[key] - if status == True: + if status: result.preventJoinByTicket = False else: result.preventJoinByTicket = True - if userId != None: + if userId is not None: self.getClient(userId).updateGroup(self.Seq, result) else: self.getClient(self.MyMID).updateGroup(self.Seq, result) @@ -199,20 +199,20 @@ class Yuuki: contactInfo = False return contactInfo - def securityForWhere(self, Message): - if Message.type == OpType.NOTIFIED_UPDATE_GROUP: - return Message.param1, Message.param2, Message.param3 - elif Message.type == OpType.NOTIFIED_INVITE_INTO_GROUP: - return Message.param1, Message.param2, Message.param3 - elif Message.type == OpType.NOTIFIED_ACCEPT_GROUP_INVITATION: - return Message.param1, Message.param2, Message.param3 - elif Message.type == OpType.NOTIFIED_KICKOUT_FROM_GROUP: - return Message.param1, Message.param2, Message.param3 + def securityForWhere(self, ncMessage): + if ncMessage.type == OpType.NOTIFIED_UPDATE_GROUP: + return ncMessage.param1, ncMessage.param2, ncMessage.param3 + elif ncMessage.type == OpType.NOTIFIED_INVITE_INTO_GROUP: + return ncMessage.param1, ncMessage.param2, ncMessage.param3 + elif ncMessage.type == OpType.NOTIFIED_ACCEPT_GROUP_INVITATION: + return ncMessage.param1, ncMessage.param2, ncMessage.param3 + elif ncMessage.type == OpType.NOTIFIED_KICKOUT_FROM_GROUP: + return ncMessage.param1, ncMessage.param2, ncMessage.param3 def getGroupTicket(self, GroupID, userId, renew=False): GroupTicket = "" if "GroupTicket" in self.data.getGroup(GroupID): - if self.data.getGroup(GroupID)["GroupTicket"].get(userId) != None: + if self.data.getGroup(GroupID)["GroupTicket"].get(userId) is not None: GroupTicket = self.data.getGroup(GroupID)["GroupTicket"].get(userId) else: self.data.updateData(self.data.getGroup(GroupID), "GroupTicket", self.data.GroupType["GroupTicket"]) @@ -232,16 +232,16 @@ class Yuuki: self.data.updateData(self.data.getData("LimitInfo")["KickLimit"], userId, self.KickLimit) self.data.updateData(self.data.getData("LimitInfo")["CancelLimit"], userId, self.CancelLimit) - def dictShuffle(self, dict, requirement=None): - dict_key = [key for key in dict] + def dictShuffle(self, dict_object, requirement=None): + dict_key = [key for key in dict_object] random.shuffle(dict_key) result = {} for key in dict_key: - if requirement == None: - result[key] = dict[key] + if requirement is None: + result[key] = dict_object[key] else: if key in requirement: - result[key] = dict[key] + result[key] = dict_object[key] return result def cancelSomeone(self, groupInfo, userId, exceptUserId=None): @@ -287,13 +287,13 @@ class Yuuki: self.sendText(groupInfo.id, _("Kick Limit.")) return helper - def sendToWho(self, Message): - if Message.message.toType == MIDType.USER: - return Message.message.from_ - elif Message.message.toType == MIDType.ROOM: - return Message.message.to - elif Message.message.toType == MIDType.GROUP: - return Message.message.to + def sendToWho(self, ncMessage): + if ncMessage.message.toType == MIDType.USER: + return ncMessage.message.from_ + elif ncMessage.message.toType == MIDType.ROOM: + return ncMessage.message.to + elif ncMessage.message.toType == MIDType.GROUP: + return ncMessage.message.to def sendText(self, toid, msg): message = Message(to=toid, text=msg) @@ -311,18 +311,18 @@ class Yuuki: ) self.getClient(self.MyMID).sendMessage(self.Seq, message) - def sendMedia(self, toid, type, path): + def sendMedia(self, send_to, send_type, path): if os.path.exists(path): file_name = ntpath.basename(path) file_size = len(open(path, 'rb').read()) - message = Message(to=toid, text=None) - message.contentType = type + message = Message(to=send_to, text=None) + message.contentType = send_type message.contentPreview = None message.contentMetadata = { 'FILE_NAME': str(file_name), 'FILE_SIZE': str(file_size), } - if type == ContentType.FILE: + if send_type == ContentType.FILE: media_name = file_name else: media_name = 'media' @@ -334,7 +334,7 @@ class Yuuki: 'name': media_name, 'oid': message_id, 'size': file_size, - 'type': ContentType._VALUES_TO_NAMES[type].lower(), + 'type': ContentType._VALUES_TO_NAMES[send_type].lower(), 'ver': '1.0', } data = { @@ -343,7 +343,7 @@ class Yuuki: url = self.LINE_Media_server + '/talk/m/upload.nhn' r = requests.post(url, headers=self.connectHeader, data=data, files=files) if r.status_code != 201: - self.sendText(toid, "Error!") + self.sendText(send_to, "Error!") def Thread_Exec(self, Function, args): if self.Threading: @@ -469,13 +469,13 @@ class Yuuki: except: unknown_msg.append(code.replace(" ", "")) self.configSecurityStatus(ncMessage.message.to, status) - if unknown_msg != []: + if unknown_msg: for count, msg in enumerate(unknown_msg): if count+1 == len(unknown_msg) and count != 0: unknown_msgtext += msg elif count != 0: unknown_msgtext += (msg + ", ") - if status != []: + if status: self.sendText(self.sendToWho(ncMessage), _("Okay")) else: self.sendText(self.sendToWho(ncMessage), _("Not Found")) @@ -515,7 +515,7 @@ class Yuuki: else: self.sendText(self.sendToWho(ncMessage), _("Not Found")) else: - if self.data.getGroup(GroupInfo.id)["Ext_Admin"] != []: + if self.data.getGroup(GroupInfo.id)["Ext_Admin"]: status = "" status_added = [] for member in GroupInfo.members: @@ -536,7 +536,7 @@ class Yuuki: status = _("SecurityService of %s was disable") % ( self.YuukiConfigs["name"], ) - elif group_status == None: + elif group_status is None: status = _("Default without Initialize\nMain Admin of the Group:\n%s") % ( self.sybGetGroupCreator(GroupInfo).displayName, ) @@ -591,7 +591,7 @@ class Yuuki: elif ncMessage.message.contentType == ContentType.CONTACT: Catched = ncMessage.message.contentMetadata["mid"] contactInfo = self.getContact(Catched) - if contactInfo == False: + if not contactInfo: msg = _("Not Found") elif contactInfo.mid in self.data.getData("BlackList"): msg = "{}\n{}".format(_("The User(s) was in our blacklist database."), contactInfo.mid) @@ -618,11 +618,13 @@ class Yuuki: GroupInfo = self.getClient(self.MyMID).getGroup(GroupID) GroupPrivilege = self.Admin + [self.sybGetGroupCreator(GroupInfo).mid] + self.data.getGroup(GroupInfo.id)["Ext_Admin"] - if Action in GroupPrivilege or Another in GroupPrivilege: - return + if ncMessage.type != OpType.NOTIFIED_KICKOUT_FROM_GROUP: + return + elif Action in GroupPrivilege: + return - if SEGroup == None: + if SEGroup is None: Security_Access = self.YuukiVariable["SecurityService"] elif SEGroup[ncMessage.type]: Security_Access = SEGroup[ncMessage.type] From dce0a06b25048a40e0abe453436cf2332233fe18 Mon Sep 17 00:00:00 2001 From: SuperSonic Date: Thu, 12 Sep 2019 20:24:12 +0800 Subject: [PATCH 4/5] v6.5.1_RC2 --- libs/yuuki.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/yuuki.py b/libs/yuuki.py index 2b274e8..8b199ff 100644 --- a/libs/yuuki.py +++ b/libs/yuuki.py @@ -730,12 +730,16 @@ class Yuuki: if NoWork >= NoWorkLimit: NoWork = 0 - self.revision = self.client.getLastOpRevision() + for ncMessage in catchedNews: + if ncMessage.reqSeq != -1 and ncMessage.revision > self.revision: + self.revision = ncMessage.revision + break + if ncMessage.revision != self.revision: + self.revision = self.client.getLastOpRevision() try: catchedNews = self.listen.fetchOperations(self.revision, fetchNum) except socket.timeout: - print("Timeout") NoWork += 1 if catchedNews: From 41b1b474c03604aa09b4a181a012e8d544a36322 Mon Sep 17 00:00:00 2001 From: SuperSonic Date: Thu, 12 Sep 2019 20:30:30 +0800 Subject: [PATCH 5/5] v6.5.1_RC2 --- libs/i18n/en.py | 1 + libs/i18n/zh_TW.py | 1 + libs/yuuki.py | 2 ++ 3 files changed, 4 insertions(+) diff --git a/libs/i18n/en.py b/libs/i18n/en.py index 4839284..345b43d 100644 --- a/libs/i18n/en.py +++ b/libs/i18n/en.py @@ -34,6 +34,7 @@ class English: "You are our blacklist. Bye~": "You are our blacklist. Bye~", "You had been blocked by our database.": "You had been blocked by our database.", "\nExtend Administrator(s)": "\nExtend Administrator(s)", + "The one who was been kicked:": "The one who was been kicked:", "Kick Limit.": "Kick Limit.", "Cancel Limit.": "Cancel Limit.", "Testing...": "Testing...", diff --git a/libs/i18n/zh_TW.py b/libs/i18n/zh_TW.py index 6ff6c20..d2c9bdc 100644 --- a/libs/i18n/zh_TW.py +++ b/libs/i18n/zh_TW.py @@ -34,6 +34,7 @@ class Traditional_Chinese: "You are our blacklist. Bye~": "再見了~黑名單用戶。", "You had been blocked by our database.": "您目前已被本程序封鎖。", "\nExtend Administrator(s)": "\n延伸管理員", + "The one who was been kicked:": "這是那個被踢的可憐孩子:", "Kick Limit.": "踢人次數已達上限", "Cancel Limit.": "取消次數已達上限", "Testing...": "測試中...", diff --git a/libs/yuuki.py b/libs/yuuki.py index 8b199ff..6915265 100644 --- a/libs/yuuki.py +++ b/libs/yuuki.py @@ -704,6 +704,8 @@ class Yuuki: Kicker = self.kickSomeone(GroupInfo, Action) # Log self.data.updateLog("KickEvent", (self.data.getTime(), GroupInfo.name, GroupID, Kicker, Action, Another, ncMessage.type)) + self.Thread_Exec(self.sendText, (GroupID, _("The one who was been kicked:"))) + self.Thread_Exec(self.sendUser, (GroupID, Another)) self.YuukiVariable["Sync"] = self.data.Data # Main