1212from .connection import Yuuki_Connect
1313from .data import Yuuki_Data
1414from .i18n import Yuuki_LangSetting
15- from .thread_control import Yuuki_MultiPross
15+ from .thread_control import Yuuki_Multiprocess
1616
1717class Yuuki_Settings :
1818 """ Yuuki Custom Settings """
1919
2020 config = {
2121 "name" : "Yuuki" ,
22- "version" : "v6.5.1_RC3 " ,
22+ "version" : "v6.5.1_RC4 " ,
2323 "project_url" : "https://tinyurl.com/syb-yuuki" ,
2424 "man_page" : "https://tinyurl.com/yuuki-manual" ,
2525 "privacy_page" : "OpenSource - Licensed under MPL 2.0" ,
@@ -38,14 +38,17 @@ class Yuuki_Settings:
3838class Yuuki :
3939 def __init__ (self , Yuuki_Settings , Yuuki_Connection , threading = False ):
4040
41+ # Enforce Disable Threading in v6.5.1_RC4
42+ threading = False
43+
4144 global _ , YuukiVariable
4245
4346 # Static Variable
4447
4548 self .YuukiConfigs = Yuuki_Settings .config
4649
4750 self .Threading = threading
48- self .Thread_Control = Yuuki_MultiPross ()
51+ self .Thread_Control = Yuuki_Multiprocess ()
4952
5053 self .Seq = self .YuukiConfigs ["Seq" ]
5154 self .Admin = self .YuukiConfigs ["Admin" ]
@@ -64,7 +67,7 @@ def __init__(self, Yuuki_Settings, Yuuki_Connection, threading=False):
6467 self .data = Yuuki_Data (self .Threading )
6568
6669 if self .Threading :
67- YuukiVariable = self .Thread_Control .dataManager () .dict ()
70+ YuukiVariable = self .Thread_Control .dataManager .dict ()
6871 else :
6972 YuukiVariable = {}
7073
@@ -85,7 +88,6 @@ def __init__(self, Yuuki_Settings, Yuuki_Connection, threading=False):
8588 self .data .updateData (self .data .Data , "LimitInfo" , self .data .LimitType )
8689
8790 YuukiVariable ["Power" ] = True
88- YuukiVariable ["Sync" ] = self .data .Data
8991 YuukiVariable ["GroupJoined" ] = self .client .getGroupIdsJoined ()
9092 YuukiVariable ["SecurityService" ] = self .YuukiConfigs ["SecurityService" ]
9193
@@ -272,7 +274,6 @@ def cancelSomeone(self, groupInfo, userId, exceptUserId=None):
272274 self .data .updateData (self .data .getData ("LimitInfo" )["CancelLimit" ], helper , Limit - 1 )
273275 else :
274276 self .sendText (groupInfo .id , _ ("Cancel Limit." ))
275- YuukiVariable ["Sync" ] = self .data .Data
276277 return helper
277278
278279 def kickSomeone (self , groupInfo , userId , exceptUserId = None ):
@@ -295,7 +296,6 @@ def kickSomeone(self, groupInfo, userId, exceptUserId=None):
295296 self .data .updateData (self .data .getData ("LimitInfo" )["KickLimit" ], helper , Limit - 1 )
296297 else :
297298 self .sendText (groupInfo .id , _ ("Kick Limit." ))
298- YuukiVariable ["Sync" ] = self .data .Data
299299 return helper
300300
301301 @staticmethod
@@ -389,14 +389,14 @@ def JoinGroup(self, ncMessage):
389389 GroupID = ncMessage .param1
390390 Inviter = ncMessage .param2
391391 GroupInfo = self .getClient (self .MyMID ).getGroup (GroupID )
392- GroupMember = [Catched .mid for Catched in GroupInfo .members ]
393- GroupInvite = [Catched .mid for Catched in GroupInfo .invitee ]
394392 if GroupInfo .members :
393+ GroupMember = [Catched .mid for Catched in GroupInfo .members ]
394+ GroupInfo .invitee = []
395+ if GroupInfo .invitee :
396+ GroupInvite = [Catched .mid for Catched in GroupInfo .invitee ]
395397 self .getClient (self .MyMID ).acceptGroupInvitation (self .Seq , GroupID )
396398 if len (GroupMember ) >= self .YuukiConfigs ["GroupMebers_Demand" ]:
397- GroupJoined_ = YuukiVariable ["GroupJoined" ]
398- GroupJoined_ .append (GroupID )
399- YuukiVariable ["GroupJoined" ] = GroupJoined_
399+ YuukiVariable ["GroupJoined" ].append (GroupID )
400400 self .sendText (GroupID , _ ("Helllo^^\n My name is %s ><\n Nice to meet you OwO" ) % self .YuukiConfigs ["name" ])
401401 self .sendText (GroupID , _ ("Type:\n \t %s/Help\n to get more information\n \n Main Admin of the Group:\n %s" ) %
402402 (self .YuukiConfigs ["name" ], self .sybGetGroupCreator (GroupInfo ).displayName ,))
@@ -417,7 +417,6 @@ def JoinGroup(self, ncMessage):
417417 # Log
418418 self .data .updateLog ("JoinGroup" , (self .data .getTime (), ncMessage .param1 , userId , ncMessage .param2 ))
419419 self .Security (ncMessage )
420- YuukiVariable ["Sync" ] = self .data .Data
421420
422421 def Commands (self , ncMessage ):
423422 """
@@ -501,8 +500,7 @@ def Commands(self, ncMessage):
501500 GroupInfo = self .getClient (self .MyMID ).getGroup (ncMessage .message .to )
502501 GroupPrivilege = self .Admin + [self .sybGetGroupCreator (GroupInfo ).mid ] + self .data .getGroup (GroupInfo .id )["Ext_Admin" ]
503502 if not YuukiVariable ["SecurityService" ]:
504- self .sendText (self .sendToWho (ncMessage ),
505- _ ("SecurityService of %s was disable" ) % (self .YuukiConfigs ["name" ],))
503+ self .sendText (self .sendToWho (ncMessage ), _ ("SecurityService of %s was disable" ) % (self .YuukiConfigs ["name" ],))
506504 elif ncMessage .message .from_ in GroupPrivilege :
507505 self .configSecurityStatus (ncMessage .message .to , [])
508506 self .sendText (self .sendToWho (ncMessage ), _ ("Okay" ))
@@ -595,9 +593,7 @@ def Commands(self, ncMessage):
595593 for userId in self .Connect .helper_ids :
596594 if userId in [member .mid for member in GroupInfo .members ]:
597595 self .getClient (userId ).leaveGroup (self .Seq , GroupInfo .id )
598- GroupJoined_ = YuukiVariable ["GroupJoined" ]
599- GroupJoined_ .remove (GroupInfo .id )
600- YuukiVariable ["GroupJoined" ] = GroupJoined_
596+ YuukiVariable ["GroupJoined" ].remove (GroupInfo .id )
601597
602598 elif self .YuukiConfigs ["name" ] + '/Exit' == ncMessage .message .text :
603599 if ncMessage .message .from_ in self .Admin :
@@ -621,7 +617,6 @@ def Commands(self, ncMessage):
621617 (contactInfo .displayName , self .LINE_Media_server , contactInfo .pictureStatus ,
622618 contactInfo .statusMessage , contactInfo .mid )
623619 self .sendText (self .sendToWho (ncMessage ), msg )
624- YuukiVariable ["Sync" ] = self .data .Data
625620
626621 def Security (self , ncMessage ):
627622 """
@@ -653,7 +648,7 @@ def Security(self, ncMessage):
653648 if YuukiVariable ["SecurityService" ]:
654649 if ncMessage .type == OpType .NOTIFIED_UPDATE_GROUP and Security_Access :
655650 if Another == '4' :
656- if not GroupInfo .preventJoinByTicket :
651+ if not GroupInfo .preventJoinByTicket and Action not in self . Connect . helper_ids :
657652 self .Thread_Exec (self .changeGroupUrlStatus , (GroupInfo , False ))
658653 self .Thread_Exec (self .sendText , (GroupID , _ ("DO NOT ENABLE THE GROUP URL STATUS, see you..." )))
659654 Kicker = self .kickSomeone (GroupInfo , Action )
@@ -664,11 +659,21 @@ def Security(self, ncMessage):
664659 if "\x1e " in Another :
665660 for userId in Another .split ("\x1e " ):
666661 if userId not in self .AllAccountIds + GroupPrivilege :
667- Canceler = self .cancelSomeone (GroupInfo , userId )
662+ if GroupInfo .invitee and userId in [user .mid for user in GroupInfo .invitee ]:
663+ Canceler = self .cancelSomeone (GroupInfo , userId )
664+ else :
665+ Canceler = self .kickSomeone (GroupInfo , userId )
666+ # Log
667+ self .data .updateLog ("KickEvent" , (self .data .getTime (), GroupInfo .name , GroupID , Canceler , Action , userId , ncMessage .type * 10 ))
668668 # Log
669669 self .data .updateLog ("CancelEvent" , (self .data .getTime (), GroupInfo .name , GroupID , Canceler , Action , Another .replace ("\x1e " , "," )))
670670 elif Another not in self .AllAccountIds + GroupPrivilege :
671- Canceler = self .cancelSomeone (GroupInfo , Another )
671+ if GroupInfo .invitee and Another in [user .mid for user in GroupInfo .invitee ]:
672+ Canceler = self .cancelSomeone (GroupInfo , Another )
673+ else :
674+ Canceler = self .kickSomeone (GroupInfo , Another )
675+ # Log
676+ self .data .updateLog ("KickEvent" , (self .data .getTime (), GroupInfo .name , GroupID , Canceler , Action , Another , ncMessage .type * 10 ))
672677 # Log
673678 self .data .updateLog ("CancelEvent" , (self .data .getTime (), GroupInfo .name , GroupID , Canceler , Action , Another ))
674679 if Canceler != "None" :
@@ -710,9 +715,7 @@ def Security(self, ncMessage):
710715 self .sendText (Root , "Star Yuuki BOT - SecurityService Failure\n \n %s\n %s\n %s\n \n %s" %
711716 (err1 , err2 , err3 , ErrorInfo ))
712717 if Another == self .MyMID :
713- GroupJoined_ = YuukiVariable ["GroupJoined" ]
714- GroupJoined_ .remove (GroupID )
715- YuukiVariable ["GroupJoined" ] = GroupJoined_
718+ YuukiVariable ["GroupJoined" ].remove (GroupID )
716719 # Log
717720 self .data .updateLog ("KickEvent" , (self .data .getTime (), GroupInfo .name , GroupID , Kicker , Action , Another , ncMessage .type * 10 + 3 ))
718721 if Action not in self .data .getData ("BlackList" ):
@@ -727,7 +730,6 @@ def Security(self, ncMessage):
727730 self .data .updateLog ("KickEvent" , (self .data .getTime (), GroupInfo .name , GroupID , Kicker , Action , Another , ncMessage .type ))
728731 self .Thread_Exec (self .sendText , (GroupID , _ ("The one who was been kicked:" )))
729732 self .Thread_Exec (self .sendUser , (GroupID , Another ))
730- YuukiVariable ["Sync" ] = self .data .Data
731733
732734 # Main
733735
@@ -771,9 +773,7 @@ def Main(self):
771773 if len (cacheOperations ) > 1 :
772774 self .revision = max (cacheOperations [- 1 ].revision , cacheOperations [- 2 ].revision )
773775
774- if self .data .Data != YuukiVariable ["Sync" ]:
775- self .data .Data = YuukiVariable ["Sync" ]
776- self .data .syncData ()
776+ self .data .syncData ()
777777
778778 except KeyboardInterrupt :
779779 self .exit ()
0 commit comments