This repository was archived by the owner on May 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
lib/Zyberspace/Telegram/Cli Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,9 @@ public function msg($peer, $msg)
6363 /**
6464 * Adds a user to the contact list
6565 *
66- * @param int|string $phoneNumber The phone-number of the new contact, needs to be a telegram-user.
67- * Can start with or without '+'.
66+ * @param string $phoneNumber The phone-number of the new contact, needs to be a telegram-user.
67+ * Every char that is not a number gets deleted, so you don't need to care about spaces,
68+ * '+' and so on.
6869 * @param string $firstName The first name of the new contact
6970 * @param string $lastName The last name of the new contact
7071 *
@@ -75,10 +76,10 @@ public function msg($peer, $msg)
7576 */
7677 public function addContact ($ phoneNumber , $ firstName , $ lastName )
7778 {
78- if (is_string ($ phoneNumber ) && $ phoneNumber [0 ] === '+ ' ) {
79- $ phoneNumber = substr ($ phoneNumber , 1 );
79+ $ phoneNumber = preg_replace ('%[^0-9]% ' , '' , (string ) $ phoneNumber );
80+ if (empty ($ phoneNumber )) {
81+ return false ;
8082 }
81- $ phoneNumber = (int ) $ phoneNumber ;
8283
8384 return $ this ->exec ('add_contact ' . $ phoneNumber . ' ' . $ this ->escapeStringArgument ($ firstName )
8485 . ' ' . $ this ->escapeStringArgument ($ lastName ));
You can’t perform that action at this time.
0 commit comments