/// <summary>
        /// Use this method when you need to tell the user that something is happening on the bot's side.
        /// The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
        /// See <see href="https://core.telegram.org/bots/api#sendchataction">API</see>
        /// </summary>
        /// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format @channelusername)</param>
        /// <param name="action">Type of action to broadcast. Choose one, depending on what the user is about to receive:
        /// typing for text messages, upload_photo for photos, record_video or upload_video for videos,
        /// record_audio or upload_audio for audio files, upload_document for general files, find_location for location data.</param>
        public BooleanResult SendChatAction(object chatId, ChatActions action)
        {
            RestRequest request = NewRestRequest(mSendChatActionUri);

            request.AddParameter("chat_id", chatId);
            request.AddParameter("action", action.ToString().ToLower());

            return(ExecuteRequest <BooleanResult>(request) as BooleanResult);
        }
Example #2
0
        /// <summary>
        /// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
        /// </summary>
        /// <param name="chatId">Unique identifier for the message recipient — User or GroupChat id</param>
        /// <param name="action">Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data.</param>
        public void SendChatAction(int chatId, ChatActions action)
        {
            var request = new RestRequest(string.Format(sendChatActionUri, Token), Method.POST);

            request.AddParameter("chat_id", chatId);
            request.AddParameter("action", action.ToString().ToLower());
            var response = restClient.Execute(request);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new Exception(response.StatusDescription);
            }
        }
        /// <summary>
        /// Use this method when you need to tell the user that something is happening on the bot's side.
        /// The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
        /// See <see href="https://core.telegram.org/bots/api#sendchataction">API</see>
        /// </summary>
        /// <param name="chatId">Unique identifier for the message recipient — User or GroupChat id</param>
        /// <param name="action">Type of action to broadcast. Choose one, depending on what the user is about to receive:
        /// typing for text messages, upload_photo for photos, record_video or upload_video for videos,
        /// record_audio or upload_audio for audio files, upload_document for general files, find_location for location data.</param>
        /// <remarks>Test NetTelebot.Tests.TelegramMockBotClientTest.SendChatActionTest()</remarks>
        public BooleanResult SendChatAction(object chatId, ChatActions action)
        {
            RestRequest request = new RestRequest(string.Format(sendChatActionUri, Token), Method.POST);

            request.AddParameter("chat_id", chatId);
            request.AddParameter("action", action.ToString().ToLower());

            IRestResponse response = RestClient.Execute(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(new BooleanResult(response.Content));
            }

            throw new Exception(response.StatusDescription);
        }
Example #4
0
        /// <summary>
        /// Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
        /// We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
        /// </summary>
        /// <param name="chat_id">Unique identifier for the message recipient — User or GroupChat id.</param>
        /// <param name="action">Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data.</param>
        public void SendChatAction(int chat_id, ChatActions action)
        {
            string url = BaseUrl + "sendChatAction?chat_id=" + chat_id + "&action=" + action.ToString().ToLower();

            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";

            var response = (HttpWebResponse)request.GetResponse();
        }