This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1001,14 +1001,29 @@ export const Commands = [
10011001 description : _td ( "Opens chat with the given user" ) ,
10021002 args : "<user-id>" ,
10031003 runFn : function ( roomId , userId ) {
1004- if ( ! userId || ! userId . startsWith ( "@" ) || ! userId . includes ( ":" ) ) {
1004+ // easter-egg for now: look up phone numbers through the thirdparty API
1005+ // (very dumb phone number detection...)
1006+ const isPhoneNumber = userId && / ^ \+ ? [ 0 1 2 3 4 5 6 7 8 9 ] + $ / . test ( userId ) ;
1007+ if ( ! userId || ( ! userId . startsWith ( "@" ) || ! userId . includes ( ":" ) ) && ! isPhoneNumber ) {
10051008 return reject ( this . getUsage ( ) ) ;
10061009 }
10071010
10081011 return success ( ( async ( ) => {
1012+ if ( isPhoneNumber ) {
1013+ const results = await MatrixClientPeg . get ( ) . getThirdpartyUser ( 'im.vector.protocol.pstn' , {
1014+ 'm.id.phone' : userId ,
1015+ } ) ;
1016+ if ( ! results || results . length === 0 || ! results [ 0 ] . userid ) {
1017+ throw new Error ( "Unable to find Matrix ID for phone number" ) ;
1018+ }
1019+ userId = results [ 0 ] . userid ;
1020+ }
1021+
1022+ const roomId = await ensureDMExists ( MatrixClientPeg . get ( ) , userId ) ;
1023+
10091024 dis . dispatch ( {
10101025 action : 'view_room' ,
1011- room_id : await ensureDMExists ( MatrixClientPeg . get ( ) , userId ) ,
1026+ room_id : roomId ,
10121027 } ) ;
10131028 } ) ( ) ) ;
10141029 } ,
You can’t perform that action at this time.
0 commit comments