@@ -19,7 +19,7 @@ class Yuuki_Settings:
1919
2020 config = {
2121 "name" : "Yuuki" ,
22- "version" : "v6.5.1_RC1 " ,
22+ "version" : "v6.5.1_RC2 " ,
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" ,
@@ -135,7 +135,7 @@ def readCommandLine(self, msgs):
135135 return replymsg
136136
137137 def checkInInvitationList (self , ncMessage , userId = None ):
138- if userId == None :
138+ if userId is None :
139139 userId = self .MyMID
140140 if ncMessage .param3 == userId :
141141 inList = True
@@ -153,11 +153,11 @@ def changeGroupUrlStatus(self, group, status, userId=None):
153153 for key in group .__dict__ :
154154 if key != "members" or key != "invitee" :
155155 result .__dict__ [key ] = group .__dict__ [key ]
156- if status == True :
156+ if status :
157157 result .preventJoinByTicket = False
158158 else :
159159 result .preventJoinByTicket = True
160- if userId != None :
160+ if userId is not None :
161161 self .getClient (userId ).updateGroup (self .Seq , result )
162162 else :
163163 self .getClient (self .MyMID ).updateGroup (self .Seq , result )
@@ -199,20 +199,20 @@ def getContact(self, userId):
199199 contactInfo = False
200200 return contactInfo
201201
202- def securityForWhere (self , Message ):
203- if Message .type == OpType .NOTIFIED_UPDATE_GROUP :
204- return Message .param1 , Message .param2 , Message .param3
205- elif Message .type == OpType .NOTIFIED_INVITE_INTO_GROUP :
206- return Message .param1 , Message .param2 , Message .param3
207- elif Message .type == OpType .NOTIFIED_ACCEPT_GROUP_INVITATION :
208- return Message .param1 , Message .param2 , Message .param3
209- elif Message .type == OpType .NOTIFIED_KICKOUT_FROM_GROUP :
210- return Message .param1 , Message .param2 , Message .param3
202+ def securityForWhere (self , ncMessage ):
203+ if ncMessage .type == OpType .NOTIFIED_UPDATE_GROUP :
204+ return ncMessage .param1 , ncMessage .param2 , ncMessage .param3
205+ elif ncMessage .type == OpType .NOTIFIED_INVITE_INTO_GROUP :
206+ return ncMessage .param1 , ncMessage .param2 , ncMessage .param3
207+ elif ncMessage .type == OpType .NOTIFIED_ACCEPT_GROUP_INVITATION :
208+ return ncMessage .param1 , ncMessage .param2 , ncMessage .param3
209+ elif ncMessage .type == OpType .NOTIFIED_KICKOUT_FROM_GROUP :
210+ return ncMessage .param1 , ncMessage .param2 , ncMessage .param3
211211
212212 def getGroupTicket (self , GroupID , userId , renew = False ):
213213 GroupTicket = ""
214214 if "GroupTicket" in self .data .getGroup (GroupID ):
215- if self .data .getGroup (GroupID )["GroupTicket" ].get (userId ) != None :
215+ if self .data .getGroup (GroupID )["GroupTicket" ].get (userId ) is not None :
216216 GroupTicket = self .data .getGroup (GroupID )["GroupTicket" ].get (userId )
217217 else :
218218 self .data .updateData (self .data .getGroup (GroupID ), "GroupTicket" , self .data .GroupType ["GroupTicket" ])
@@ -232,16 +232,16 @@ def limitReset(self, reconnect=False):
232232 self .data .updateData (self .data .getData ("LimitInfo" )["KickLimit" ], userId , self .KickLimit )
233233 self .data .updateData (self .data .getData ("LimitInfo" )["CancelLimit" ], userId , self .CancelLimit )
234234
235- def dictShuffle (self , dict , requirement = None ):
236- dict_key = [key for key in dict ]
235+ def dictShuffle (self , dict_object , requirement = None ):
236+ dict_key = [key for key in dict_object ]
237237 random .shuffle (dict_key )
238238 result = {}
239239 for key in dict_key :
240- if requirement == None :
241- result [key ] = dict [key ]
240+ if requirement is None :
241+ result [key ] = dict_object [key ]
242242 else :
243243 if key in requirement :
244- result [key ] = dict [key ]
244+ result [key ] = dict_object [key ]
245245 return result
246246
247247 def cancelSomeone (self , groupInfo , userId , exceptUserId = None ):
@@ -287,13 +287,13 @@ def kickSomeone(self, groupInfo, userId, exceptUserId=None):
287287 self .sendText (groupInfo .id , _ ("Kick Limit." ))
288288 return helper
289289
290- def sendToWho (self , Message ):
291- if Message .message .toType == MIDType .USER :
292- return Message .message .from_
293- elif Message .message .toType == MIDType .ROOM :
294- return Message .message .to
295- elif Message .message .toType == MIDType .GROUP :
296- return Message .message .to
290+ def sendToWho (self , ncMessage ):
291+ if ncMessage .message .toType == MIDType .USER :
292+ return ncMessage .message .from_
293+ elif ncMessage .message .toType == MIDType .ROOM :
294+ return ncMessage .message .to
295+ elif ncMessage .message .toType == MIDType .GROUP :
296+ return ncMessage .message .to
297297
298298 def sendText (self , toid , msg ):
299299 message = Message (to = toid , text = msg )
@@ -311,18 +311,18 @@ def sendUser(self, toid, userId):
311311 )
312312 self .getClient (self .MyMID ).sendMessage (self .Seq , message )
313313
314- def sendMedia (self , toid , type , path ):
314+ def sendMedia (self , send_to , send_type , path ):
315315 if os .path .exists (path ):
316316 file_name = ntpath .basename (path )
317317 file_size = len (open (path , 'rb' ).read ())
318- message = Message (to = toid , text = None )
319- message .contentType = type
318+ message = Message (to = send_to , text = None )
319+ message .contentType = send_type
320320 message .contentPreview = None
321321 message .contentMetadata = {
322322 'FILE_NAME' : str (file_name ),
323323 'FILE_SIZE' : str (file_size ),
324324 }
325- if type == ContentType .FILE :
325+ if send_type == ContentType .FILE :
326326 media_name = file_name
327327 else :
328328 media_name = 'media'
@@ -334,7 +334,7 @@ def sendMedia(self, toid, type, path):
334334 'name' : media_name ,
335335 'oid' : message_id ,
336336 'size' : file_size ,
337- 'type' : ContentType ._VALUES_TO_NAMES [type ].lower (),
337+ 'type' : ContentType ._VALUES_TO_NAMES [send_type ].lower (),
338338 'ver' : '1.0' ,
339339 }
340340 data = {
@@ -343,7 +343,7 @@ def sendMedia(self, toid, type, path):
343343 url = self .LINE_Media_server + '/talk/m/upload.nhn'
344344 r = requests .post (url , headers = self .connectHeader , data = data , files = files )
345345 if r .status_code != 201 :
346- self .sendText (toid , "Error!" )
346+ self .sendText (send_to , "Error!" )
347347
348348 def Thread_Exec (self , Function , args ):
349349 if self .Threading :
@@ -437,7 +437,7 @@ def Commands(self, ncMessage):
437437 Time1 = time .time ()
438438 self .sendText (self .sendToWho (ncMessage ), _ ("Testing..." ))
439439 Time2 = time .time ()
440- self .sendText (self .sendToWho (ncMessage ), _ ("Speed:\n %ss " ) % (Time2 - Time1 ,))
440+ self .sendText (self .sendToWho (ncMessage ), _ ("Speed:\n %s com/s " ) % (Time2 - Time1 ,))
441441 elif self .YuukiConfigs ["name" ] + '/SecurityMode' == msgSep [0 ]:
442442 if ncMessage .message .from_ in self .Admin :
443443 if len (msgSep ) == 2 :
@@ -458,16 +458,29 @@ def Commands(self, ncMessage):
458458 _ ("SecurityService of %s was disable" ) % (self .YuukiConfigs ["name" ],))
459459 elif ncMessage .message .from_ in GroupPrivilege :
460460 status = []
461+ unknown_msg = []
462+ unknown_msgtext = ""
461463 for code in msgSep :
462464 try :
463- status .append (int (code ))
465+ if int (code ) <= 3 :
466+ status .append (int (code ))
467+ else :
468+ unknown_msg .append (code .replace (" " , "" ))
464469 except :
465- pass
470+ unknown_msg . append ( code . replace ( " " , "" ))
466471 self .configSecurityStatus (ncMessage .message .to , status )
467- if status != []:
472+ if unknown_msg :
473+ for count , msg in enumerate (unknown_msg ):
474+ if count + 1 == len (unknown_msg ) and count != 0 :
475+ unknown_msgtext += msg
476+ elif count != 0 :
477+ unknown_msgtext += (msg + ", " )
478+ if status :
468479 self .sendText (self .sendToWho (ncMessage ), _ ("Okay" ))
469480 else :
470481 self .sendText (self .sendToWho (ncMessage ), _ ("Not Found" ))
482+ if unknown_msgtext != "" :
483+ self .sendText (self .sendToWho (ncMessage ), _ ("Notice: Unknown command line argument(s)" ) + "\n ({})" .format (unknown_msgtext ))
471484 elif self .YuukiConfigs ["name" ] + '/DisableAll' == ncMessage .message .text :
472485 if ncMessage .message .toType == MIDType .GROUP :
473486 GroupInfo = self .getClient (self .MyMID ).getGroup (ncMessage .message .to )
@@ -502,7 +515,7 @@ def Commands(self, ncMessage):
502515 else :
503516 self .sendText (self .sendToWho (ncMessage ), _ ("Not Found" ))
504517 else :
505- if self .data .getGroup (GroupInfo .id )["Ext_Admin" ] != [] :
518+ if self .data .getGroup (GroupInfo .id )["Ext_Admin" ]:
506519 status = ""
507520 status_added = []
508521 for member in GroupInfo .members :
@@ -511,7 +524,7 @@ def Commands(self, ncMessage):
511524 status_added .append (member .mid )
512525 for userId in self .data .getGroup (GroupInfo .id )["Ext_Admin" ]:
513526 if userId not in status_added :
514- status += "Unknown : {}\n " .format (userId )
527+ status += "{} : {}\n " .format (_ ( "Unknown" ), userId )
515528 self .sendText (self .sendToWho (ncMessage ), status + _ ("\n Extend Administrator(s)" ))
516529 else :
517530 self .sendText (self .sendToWho (ncMessage ), _ ("Not Found" ))
@@ -523,7 +536,7 @@ def Commands(self, ncMessage):
523536 status = _ ("SecurityService of %s was disable" ) % (
524537 self .YuukiConfigs ["name" ],
525538 )
526- elif group_status == None :
539+ elif group_status is None :
527540 status = _ ("Default without Initialize\n Main Admin of the Group:\n %s" ) % (
528541 self .sybGetGroupCreator (GroupInfo ).displayName ,
529542 )
@@ -536,6 +549,24 @@ def Commands(self, ncMessage):
536549 self .sybGetGroupCreator (GroupInfo ).displayName ,
537550 )
538551 self .sendText (self .sendToWho (ncMessage ), status )
552+ elif self .YuukiConfigs ["name" ] + '/GroupBackup' == ncMessage .message .text :
553+ if ncMessage .message .toType == MIDType .GROUP :
554+ GroupInfo = self .getClient (self .MyMID ).getGroup (ncMessage .message .to )
555+ GroupPrivilege = self .Admin + [self .sybGetGroupCreator (GroupInfo ).mid ] + self .data .getGroup (GroupInfo .id )["Ext_Admin" ]
556+ if ncMessage .message .from_ in GroupPrivilege :
557+ GroupMembers = [User .mid for User in GroupInfo .members ]
558+ GroupInvites = None
559+ if GroupInfo .invitee :
560+ GroupInvites = [User .mid for User in GroupInfo .invitee ]
561+ LayoutInfo = {
562+ "OriginID" : GroupInfo .id ,
563+ "Members" : GroupMembers ,
564+ "Invites" : GroupInvites
565+ }
566+ self .sendText (ncMessage .message .from_ , GroupInfo .name )
567+ self .sendText (ncMessage .message .from_ , json .dumps (LayoutInfo ))
568+ self .sendText (ncMessage .message .to , _ ("Okay" ))
569+
539570 elif self .YuukiConfigs ["name" ] + '/Quit' == ncMessage .message .text :
540571 if ncMessage .message .toType == MIDType .GROUP :
541572 GroupInfo = self .getClient (self .MyMID ).getGroup (ncMessage .message .to )
@@ -560,7 +591,7 @@ def Commands(self, ncMessage):
560591 elif ncMessage .message .contentType == ContentType .CONTACT :
561592 Catched = ncMessage .message .contentMetadata ["mid" ]
562593 contactInfo = self .getContact (Catched )
563- if contactInfo == False :
594+ if not contactInfo :
564595 msg = _ ("Not Found" )
565596 elif contactInfo .mid in self .data .getData ("BlackList" ):
566597 msg = "{}\n {}" .format (_ ("The User(s) was in our blacklist database." ), contactInfo .mid )
@@ -587,11 +618,13 @@ def Security(self, ncMessage):
587618 GroupInfo = self .getClient (self .MyMID ).getGroup (GroupID )
588619 GroupPrivilege = self .Admin + [self .sybGetGroupCreator (GroupInfo ).mid ] + self .data .getGroup (GroupInfo .id )["Ext_Admin" ]
589620
590-
591621 if Action in GroupPrivilege or Another in GroupPrivilege :
592- return
622+ if ncMessage .type != OpType .NOTIFIED_KICKOUT_FROM_GROUP :
623+ return
624+ elif Action in GroupPrivilege :
625+ return
593626
594- if SEGroup == None :
627+ if SEGroup is None :
595628 Security_Access = self .YuukiVariable ["SecurityService" ]
596629 elif SEGroup [ncMessage .type ]:
597630 Security_Access = SEGroup [ncMessage .type ]
@@ -671,6 +704,8 @@ def Security(self, ncMessage):
671704 Kicker = self .kickSomeone (GroupInfo , Action )
672705 # Log
673706 self .data .updateLog ("KickEvent" , (self .data .getTime (), GroupInfo .name , GroupID , Kicker , Action , Another , ncMessage .type ))
707+ self .Thread_Exec (self .sendText , (GroupID , _ ("The one who was been kicked:" )))
708+ self .Thread_Exec (self .sendUser , (GroupID , Another ))
674709 self .YuukiVariable ["Sync" ] = self .data .Data
675710
676711 # Main
@@ -697,12 +732,16 @@ def Main(self):
697732
698733 if NoWork >= NoWorkLimit :
699734 NoWork = 0
700- self .revision = self .client .getLastOpRevision ()
735+ for ncMessage in catchedNews :
736+ if ncMessage .reqSeq != - 1 and ncMessage .revision > self .revision :
737+ self .revision = ncMessage .revision
738+ break
739+ if ncMessage .revision != self .revision :
740+ self .revision = self .client .getLastOpRevision ()
701741
702742 try :
703743 catchedNews = self .listen .fetchOperations (self .revision , fetchNum )
704744 except socket .timeout :
705- print ("Timeout" )
706745 NoWork += 1
707746
708747 if catchedNews :
0 commit comments