@@ -315,7 +315,6 @@ def get_all_chat_ids(self):
315315 def get_unread (self , include_me = False , include_notifications = False , use_unread_count = False ):
316316 """
317317 Fetches unread messages
318-
319318 :param include_me: Include user's messages
320319 :type include_me: bool or None
321320 :param include_notifications: Include events happening on chat
@@ -443,7 +442,7 @@ def get_chat_from_id(self, chat_id):
443442
444443 raise ChatNotFoundError ("Chat {0} not found" .format (chat_id ))
445444
446- def get_chat_from_phone_number (self , number ):
445+ def get_chat_from_phone_number (self , number , createIfNotFound = False ):
447446 """
448447 Gets chat by phone number
449448 Number format should be as it appears in Whatsapp ID
@@ -460,13 +459,14 @@ def get_chat_from_phone_number(self, number):
460459 if not isinstance (chat , UserChat ) or number not in chat .id :
461460 continue
462461 return chat
462+ if createIfNotFound :
463+ self .create_chat_by_number (number )
464+ self .wait_for_login ()
465+ for chat in self .get_all_chats ():
466+ if not isinstance (chat , UserChat ) or number not in chat .id :
467+ continue
468+ return chat
463469
464- self .create_chat_by_number (number )
465- self .wait_for_login ()
466- for chat in self .get_all_chats ():
467- if not isinstance (chat , UserChat ) or number not in chat .id :
468- continue
469- return chat
470470 raise ChatNotFoundError ('Chat for phone {0} not found' .format (number ))
471471
472472 def reload_qr (self ):
@@ -512,6 +512,13 @@ def chat_send_message(self, chat_id, message):
512512 return factory_message (result , self )
513513 return result
514514
515+ def chat_reply_message (self , message_id , message ):
516+ result = self .wapi_functions .ReplyMessage (message_id , message )
517+
518+ if not isinstance (result , bool ):
519+ return factory_message (result , self )
520+ return result
521+
515522 def send_message_to_id (self , recipient , message ):
516523 """
517524 Send a message to a chat given its ID
0 commit comments