示例#1
0
        /// <summary>
        /// sends a video to the chat
        /// </summary>
        /// <returns>on success, the sent message is returned</returns>
        public Message SendAnimation(Chat chat, InputFile animation, long duration = long.MinValue, long width = long.MinValue, long height = long.MinValue, InputFile thumb = null, string caption = null, MarkdownStyles markdownStyle = MarkdownStyles.None, bool supportsStreaming = false, bool disableNotification = false, Message replyToMessage = null)
        {
            Require(chat, animation);

            var parameters = new List <MultiPartParameter>()
            {
                new MultiPartStringParameter("chat_id", chat.Id.ToString()),
                animation.GetMultiPartParameter("animation")
            };

            if (duration > long.MinValue)
            {
                parameters.Add(new MultiPartStringParameter("duration", duration.ToString()));
            }

            if (width > long.MinValue)
            {
                parameters.Add(new MultiPartStringParameter("width", duration.ToString()));
            }

            if (height > long.MinValue)
            {
                parameters.Add(new MultiPartStringParameter("height", duration.ToString()));
            }

            if (thumb != null)
            {
                parameters.Add(thumb.GetMultiPartParameter("thumb"));
            }

            if (!string.IsNullOrEmpty(caption))
            {
                parameters.Add(new MultiPartStringParameter("caption", caption));
            }

            if (markdownStyle != MarkdownStyles.None)
            {
                parameters.Add(new MultiPartStringParameter("parse_mode", Enum.GetName(typeof(MarkdownStyles), markdownStyle)));
            }

            if (disableNotification)
            {
                parameters.Add(new MultiPartStringParameter("disable_notification", disableNotification.ToString()));
            }

            if (replyToMessage != null)
            {
                parameters.Add(new MultiPartStringParameter("reply_to_message_id", replyToMessage.MessageId.ToString()));
            }

            var result = _communicator.GetMultiPartReply <SendAnimationReply>("sendAnimation", parameters.ToArray());

            if (result.Ok)
            {
                return(result.SentMessage);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// sends a video note to the chat
        /// </summary>
        /// <returns>on success, the sent message is returned</returns>
        public Message SendVideoNote(Chat chat, InputFile videoNote, long duration = long.MinValue, long length = long.MinValue, InputFile thumb = null, bool disableNotification = false, Message replyToMessage = null)
        {
            Require(chat, videoNote);

            var parameters = new List <MultiPartParameter>()
            {
                new MultiPartStringParameter("chat_id", chat.Id.ToString()),
                videoNote.GetMultiPartParameter("video_note")
            };

            if (duration > long.MinValue)
            {
                parameters.Add(new MultiPartStringParameter("duration", duration.ToString()));
            }

            if (length > long.MinValue)
            {
                parameters.Add(new MultiPartStringParameter("length", length.ToString()));
            }

            if (thumb != null)
            {
                parameters.Add(thumb.GetMultiPartParameter("thumb"));
            }

            if (disableNotification)
            {
                parameters.Add(new MultiPartStringParameter("disable_notification", disableNotification.ToString()));
            }

            if (replyToMessage != null)
            {
                parameters.Add(new MultiPartStringParameter("reply_to_message_id", replyToMessage.MessageId.ToString()));
            }

            var result = _communicator.GetMultiPartReply <SendVideoNoteReply>("sendVideoNote", parameters.ToArray());

            if (result.Ok)
            {
                return(result.SentMessage);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// sends an audio file to the chat
        /// </summary>
        /// <returns>on success, the sent Message is returned</returns>
        public Message SendAudio(Chat chat, InputFile audio, string caption = null, MarkdownStyles markdownStyle = MarkdownStyles.None, long duration = long.MinValue, string performer = null, string title = null, InputFile thumb = null, bool disableNotification = false, Message replyToMessage = null)
        {
            Require(chat, audio);

            var parameters = new List <MultiPartParameter>
            {
                new MultiPartStringParameter("chat_id", chat.Id.ToString()),
                audio.GetMultiPartParameter("audio")
            };

            if (!string.IsNullOrEmpty(caption))
            {
                parameters.Add(new MultiPartStringParameter("caption", caption));
            }

            if (markdownStyle != MarkdownStyles.None)
            {
                parameters.Add(new MultiPartStringParameter("parse_mode", Enum.GetName(typeof(MarkdownStyles), markdownStyle)));
            }

            if (duration > long.MinValue)
            {
                parameters.Add(new MultiPartStringParameter("duration", duration.ToString()));
            }

            if (!string.IsNullOrEmpty(performer))
            {
                parameters.Add(new MultiPartStringParameter("performer", performer));
            }

            if (!string.IsNullOrEmpty(title))
            {
                parameters.Add(new MultiPartStringParameter("title", title));
            }

            if (thumb != null)
            {
                parameters.Add(thumb.GetMultiPartParameter("thumb"));
            }

            if (disableNotification)
            {
                parameters.Add(new MultiPartStringParameter("disable_notification", disableNotification.ToString()));
            }

            if (replyToMessage != null)
            {
                parameters.Add(new MultiPartStringParameter("reply_to_message_id", replyToMessage.MessageId.ToString()));
            }

            var result = _communicator.GetMultiPartReply <SendAudioReply>("sendAudio", parameters.ToArray());

            if (result.Ok)
            {
                return(result.SentMessage);
            }
            else
            {
                return(null);
            }
        }