% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/channel_downloads.R
\name{download_channel_messages}
\alias{download_channel_messages}
\title{Download Channel Messages By Channel}
\usage{
download_channel_messages(
  client,
  channel,
  limit = Inf,
  include_channel = TRUE,
  start_date = NULL,
  end_date = NULL,
  since_message_id = NULL,
  show_progress = TRUE,
  timeout_sec = getOption("telegramR.iter_timeout", 60),
  max_timeouts = 3,
  reconnect_on_timeout = TRUE,
  output_file = NULL,
  chunk_size = 5000L,
  partial_on_error = TRUE,
  ...
)
}
\arguments{
\item{client}{TelegramClient instance.}

\item{channel}{character or numeric. Channel username (with or without "@") or numeric id.}

\item{limit}{integer or Inf. Maximum number of messages to fetch.}

\item{include_channel}{logical. If TRUE, include channel fields on every row.}

\item{start_date}{POSIXct/Date/character. Earliest date to include (UTC).}

\item{end_date}{POSIXct/Date/character. Latest date to include (UTC).}

\item{since_message_id}{integer or NULL. If set, only fetch messages with id > this value
(incremental/resume download). Maps to \code{min_id} in the API.}

\item{show_progress}{logical. If TRUE, display a progress bar.}

\item{timeout_sec}{numeric. Max seconds to wait per fetch before retrying. Use 0 to disable.}

\item{max_timeouts}{integer. Number of timeouts to tolerate before aborting.}

\item{reconnect_on_timeout}{logical. If TRUE, reconnect client on timeout.}

\item{output_file}{character or NULL. When set, rows are written to this CSV file in chunks
rather than accumulated in memory. Returns the row count invisibly instead of a tibble.
Appends to the file if it already exists (adds header only on first write).}

\item{chunk_size}{integer. Number of rows to buffer before each write when
\code{output_file} is set. Default 5000.}

\item{partial_on_error}{logical. If TRUE (default), non-timeout errors emit a warning and
return the rows collected so far rather than throwing. If FALSE, errors propagate immediately.}

\item{...}{Passed to client$iter_messages() (e.g. offset_id, max_id, min_id).}
}
\value{
A tibble (or invisible row count when \code{output_file} is set).
}
\description{
Fetches messages for a channel by username or numeric id and returns a tibble with
message fields and nested structures as list columns.
}
