Ejemplo n.º 1
0
        public async Task <List <Update> > GetUpdates(
            long?offset  = null,
            long?limit   = null,
            long?timeout = null,  // in seconds
            List <String> allowed_updates = null
            )
        {
            var ub = new UriBuilder(BaseUriForGetUpdates);

            if (offset != null)
            {
                ub.AddArgument("offset", offset.Value);
            }
            if (limit != null)
            {
                ub.AddArgument("limit", limit.Value);
            }
            if (timeout != null)
            {
                ub.AddArgument("timeout", timeout.Value);
            }
            if (allowed_updates != null)
            {
                ub.AddArgument("allowed_updates", JsonConvert.SerializeObject(allowed_updates));
            }

            return(await DoGetMethodCall <List <Telegram.Update> >(ub.ToString()));
        }
Ejemplo n.º 2
0
        public async Task <Telegram.Message> SendMessage(
            string chat_id, // required, can be integer
            string text,    // required
            string parse_mode             = null,
            bool?disable_web_page_preview = null,
            bool?disable_notification     = null,
            long?reply_to_message_id      = null,
            string reply_markup           = null)
        {
            var ub = new UriBuilder(BaseUriForSendMessage);

            ub.AddArgument("chat_id", chat_id);
            ub.AddArgument("text", text);

            if (parse_mode != null)
            {
                ub.AddArgument("parse_mode", parse_mode);
            }
            if (disable_web_page_preview != null)
            {
                ub.AddArgument("disable_web_page_preview", disable_web_page_preview.Value ? "true" : "false");
            }
            if (disable_notification != null)
            {
                ub.AddArgument("disable_notification", disable_notification.Value ? "true" : "false");
            }
            if (reply_to_message_id != null)
            {
                ub.AddArgument("reply_to_message_id", reply_to_message_id.Value);
            }
            if (reply_markup != null)
            {
                ub.AddArgument("reply_markup", reply_markup);
            }

            return(await DoGetMethodCall <Telegram.Message>(ub.ToString()));
        }