Merge pull request #14 from star-inc/rolling

v6.5.1-stable_RC2 from Rolling
This commit is contained in:
SuperSonic 2019-09-12 20:49:30 +08:00 committed by GitHub
commit aa36d4f221
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 93 additions and 48 deletions

View file

@ -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)

View file

@ -27,19 +27,22 @@ 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.",
"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...",
"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"
}

View file

@ -27,19 +27,22 @@ 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.": "這個臭小子在我們的黑名單中 =.=",
"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...": "測試中...",
"Speed:\n%ss": "速度為:\n%ss",
"Speed:\n %s com/s": "速度為:\n%s 指令/秒",
"Bye Bye": "掰掰 ><",
"Not Found": "404 不存在 0.0...",
"Okay": "好的",
"Unknown": "未知",
"Exit.": "已退出",
"Added": "已增加"
}

View file

@ -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",
@ -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:
@ -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,29 @@ 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))
if int(code) <= 3:
status.append(int(code))
else:
unknown_msg.append(code.replace(" ", ""))
except:
pass
unknown_msg.append(code.replace(" ", ""))
self.configSecurityStatus(ncMessage.message.to, status)
if 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)
@ -502,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:
@ -511,7 +524,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"))
@ -523,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,
)
@ -536,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)
@ -560,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)
@ -587,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]
@ -671,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
@ -697,12 +732,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: