Merge pull request #4 from star-inc/rolling

v6.5.0-alpha_RC2 from Rolling
This commit is contained in:
SuperSonic 2019-08-28 00:17:32 +08:00 committed by GitHub
commit 80f3df3261
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 31 deletions

View file

@ -22,7 +22,8 @@ class Yuuki_Data:
self.GroupType = {
"SEGroup":None,
"Ext_Admin":[]
"Ext_Admin":[],
"GroupTicket":{}
}
self.LimitType = {

View file

@ -19,10 +19,10 @@ class Yuuki_Settings:
config = {
"name": "Yuuki",
"version": "v6.5.0-alpha_RC1",
"project_url": "https://line.starinc.xyz/star-yuuki-bot/",
"man_page": "https://line.starinc.xyz/star-yuuki-bot/",
"privacy_page": "OpenSource - License under MPL 2.0",
"version": "v6.5.0-alpha_RC2",
"project_url": "https://tinyurl.com/syb-yuuki",
"man_page": "None",
"privacy_page": "OpenSource - Licensed under MPL 2.0",
"copyright": "(c)2019 Star Inc.",
"Seq": 0,
@ -107,13 +107,15 @@ class Yuuki:
inList = False
return inList
def changeGroupUrlStatus(self, group, stat):
if stat == True:
us = False
def changeGroupUrlStatus(self, group, status, userId=None):
if status == True:
group.preventJoinByTicket = False
else:
us = True
group.preventJoinByTicket = True
group.members, group.invitee = None, None
group.preventJoinByTicket = us
if userId != None:
self.getClientByMid(userId).updateGroup(self.Seq, group)
else:
self.client.updateGroup(self.Seq, group)
def enableSecurityStatus(self, groupId, status):
@ -173,6 +175,18 @@ class Yuuki:
if AccountUserId == userId:
return Accounts[count]
def getGroupTicket(self, GroupID, userId, renew=False):
GroupTicket = ""
if "GroupTicket" in self.data.getGroup(GroupID):
if self.data.getGroup(GroupID)["GroupTicket"].get(userId) != None:
GroupTicket = self.data.getGroup(GroupID)["GroupTicket"].get(userId)
else:
self.data.updateData(self.data.getGroup(GroupID), "GroupTicket", self.data.GroupType["GroupTicket"])
if GroupTicket == "" or renew:
GroupTicket = self.getClientByMid(userId).reissueGroupTicket(GroupID)
self.data.updateData(self.data.getGroup(GroupID)["GroupTicket"], userId, GroupTicket)
return GroupTicket
def limitReset(self, reconnect=False):
for userId in [self.MyMID] + self.Connect.helper_ids:
if reconnect:
@ -298,6 +312,7 @@ class Yuuki:
self.sendText(GroupID, _("Helllo^^\nMy name is %s ><\nNice to meet you OwO") % self.YuukiConfigs["name"])
self.sendText(GroupID, _("Type:\n\t%s/Help\nto get more information\n\nAdmin of the Group:\n%s") %
(self.YuukiConfigs["name"], self.sybGetGroupCreator(GroupInfo).displayName,))
self.getGroupTicket(GroupID, self.MyMID, True)
# Log
self.data.updateLog("JoinGroup", (self.data.getTime(), GroupInfo.name, GroupID, Inviter))
else:
@ -310,6 +325,7 @@ class Yuuki:
for userId in self.Connect.helper_ids:
if self.checkInInvitationList(ncMessage, userId):
self.getClientByMid(userId).acceptGroupInvitation(self.Seq, ncMessage.param1)
self.getGroupTicket(ncMessage.param1, userId, True)
# Log
self.data.updateLog("JoinGroup", (self.data.getTime(), ncMessage.param1, userId, ncMessage.param2))
self.Security(ncMessage)
@ -456,19 +472,24 @@ class Yuuki:
NOTIFIED_ACCEPT_GROUP_INVITATION (17)
NOTIFIED_KICKOUT_FROM_GROUP (19)
"""
Security_Access = False
(GroupID, Action, Another) = self.securityForWhere(ncMessage)
SEGroup = self.data.getSEGroup(GroupID)
GroupInfo = self.client.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 SEGroup == None:
return
Security_Access = self.SecurityService
elif SEGroup[ncMessage.type]:
Security_Access = SEGroup[ncMessage.type]
if SEGroup[ncMessage.type] and self.SecurityService:
if Security_Access and self.SecurityService:
if ncMessage.type == OpType.NOTIFIED_UPDATE_GROUP:
if Another == '4':
if not GroupInfo.preventJoinByTicket:
@ -502,13 +523,19 @@ class Yuuki:
if Action in self.Connect.helper_ids:
# Log
self.data.updateLog("KickEvent", (self.data.getTime(), GroupInfo.name, GroupID, Action, Action, Another, ncMessage.type*10+1))
else:
if Another in [self.MyMID] + self.Connect.helper_ids:
elif Another in [self.MyMID] + self.Connect.helper_ids:
Kicker = "None"
try:
Kicker = self.kickSomeone(GroupID, Action, Another)
# Log
self.data.updateLog("KickEvent", (self.data.getTime(), GroupInfo.name, GroupID, Kicker, Action, Another, ncMessage.type*10+2))
if GroupInfo.preventJoinByTicket:
self.changeGroupUrlStatus(GroupInfo, True, Kicker)
GroupTicket = self.getGroupTicket(GroupID, Kicker)
self.getClientByMid(Another).acceptGroupInvitationByTicket(self.Seq, GroupID, GroupTicket)
if not GroupInfo.preventJoinByTicket:
self.changeGroupUrlStatus(GroupInfo, False, Another)
self.getGroupTicket(GroupID, Another, True)
except:
# Log
self.data.updateLog("KickEvent", (self.data.getTime(), GroupInfo.name, GroupID, Kicker, Action, Another, ncMessage.type*10+3))