/// <summary> /// 사용자에게 메시지를 보낸다. /// </summary> /// <param name="ctype">조회 할 필드</param> /// <param name="info">조회 할 정보</param> /// <param name="msg">보낼 메시지</param> /// <returns></returns> public async Task SendMessageByContacts(enContactInfoType ctype, string info, string msg) { //인증 확인 isAuth(true); //연락처 조회전이면 조회 한다. if (_contacts == null) { await ContactsGet(); } DataRow[] rows = await UserInfoGetFromContact(ctype, info); if (rows.Length < 1 || info == null || info.Trim().Equals(string.Empty)) { throw new Exception(string.Format("[Type]{0} [Info]{1} 로 연락처 정보를 찾을 수 없습니다.", ctype, info)); } foreach (DataRow dr in rows) { await client.SendMessageAsync(new TLInputPeerUser() { user_id = Fnc.obj2int(dr["id"]) }, msg); } }
/// <summary> /// 연락처에서 사용자 정보를 조회 한다. /// </summary> /// <param name="ctype">조회 할 필드</param> /// <param name="info">조회 할 정보</param> /// <returns></returns> public async Task <DataRow[]> UserInfoGetFromContact(enContactInfoType ctype, string info) { DataRow[] rtn; //연락처 조회전이면 조회 한다. if (_contacts == null) { await ContactsGet(); } string con = "deleted = false and "; switch (ctype) { case enContactInfoType.id: con += "id = {0}"; break; case enContactInfoType.name: con += "( first_name like '%{0}%' or last_name like '%{0}%' )"; break; case enContactInfoType.phoneNumber: con += string.Format("phone = '{0}'", fnc.PhoneNumberInit(info)); break; case enContactInfoType.username: con += "username = '******'"; break; } con = string.Format(con, info); rtn = _contacts.Select(con); return(rtn); }