예제 #1
0
        /// <summary>
        /// 채팅방을 조건으로 조회 한다.
        /// </summary>
        /// <param name="ctype"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task <DataRow> ChatGetFromChats(enChatsInfoType ctype, string info)
        {
            DataRow[] rtn;

            //연락처 조회전이면 조회 한다.
            if (_contacts == null)
            {
                await ContactsGet();
            }

            string con = "";

            switch (ctype)
            {
            case enChatsInfoType.id:
                con += "id = {0}";
                break;

            case enChatsInfoType.title:
                con += "title = '{0}'";
                break;
            }

            con = string.Format(con, info);

            rtn = _chatList.Select(con);

            return(rtn.Length > 0 ? rtn[0] : null);
        }
예제 #2
0
        /// <summary>
        /// 채팅방에 메시지를 보낸다.
        /// </summary>
        /// <param name="ctype"></param>
        /// <param name="info"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public async Task SendMessageToChat(enChatsInfoType ctype, string info, string msg)
        {
            //인증 확인
            isAuth(true);


            //채팅방 리스트 조회전이면 조회 한다.
            if (_chatList == null)
            {
                await ChatListGet();
            }

            DataRow row = await ChatGetFromChats(ctype, info);

            if (row == null || info == null || info.Trim().Equals(string.Empty))
            {
                throw new Exception(string.Format("[Type]{0} [Info]{1} 로 채팅방 정보를 찾을 수 없습니다.", ctype, info));
            }

            await client.SendMessageAsync(new TLInputPeerChannel()
            {
                channel_id = Fnc.obj2int(row["id"]), access_hash = Fnc.obj2Long(row["access_hash"])
            }, msg);
        }