ChatRepository
extends AbstractRepository
in package
The chats this client has seen in an update or looked up - `$telegram->chats`.
Entries arrive as Chat stubs off incoming updates and are upgraded in place to the full ChatFullInfo whenever fetch() runs, so a cached chat gains attributes over time rather than being replaced.
Tags
Table of Contents
Properties
- $discrim : string
- The attribute that identifies a row.
- $items : Collection<string|int, TPart>
- $part : string
- The part class this repository holds.
- $telegram : Telegram
Methods
- __construct() : mixed
- all() : Collection<string|int, TPart>
- cache() : TPart
- Remembers a part, or merges it into the one already held under that id.
- clear() : void
- count() : int
- countMembers() : PromiseInterface<string|int, int>
- The number of members in a chat, which the Bot API answers without handing back a chat object.
- fetch() : PromiseInterface<string|int, ChatFullInfo>
- Looks a chat up with `getChat`.
- fetchOrGet() : PromiseInterface<string|int, TPart>
- The cached part if there is one, otherwise a fresh copy from Telegram.
- get() : TPart|null
- The cached part with this id, if it has been seen.
- getIterator() : Traversable
- has() : bool
- normalise() : int|string
- Telegram ids are integers, but they arrive as strings often enough - out of a config file, off a command argument - that a lookup has to accept both.
Properties
$discrim
The attribute that identifies a row.
protected
string
$discrim
= 'id'
$items
protected
Collection<string|int, TPart>
$items
$part
The part class this repository holds.
protected
string
$part
= \Telegram\Parts\Chat::class
$telegram read-only
protected
Telegram
$telegram
Methods
__construct()
public
__construct(Telegram $telegram) : mixed
Parameters
- $telegram : Telegram
all()
public
all() : Collection<string|int, TPart>
Return values
Collection<string|int, TPart>cache()
Remembers a part, or merges it into the one already held under that id.
public
cache(TPart $part) : TPart
Parameters
- $part : TPart
Return values
TPart —The cached part - the merged one when an entry already existed.
clear()
public
clear() : void
count()
public
count() : int
Return values
intcountMembers()
The number of members in a chat, which the Bot API answers without handing back a chat object.
public
countMembers(int|string $id) : PromiseInterface<string|int, int>
Parameters
- $id : int|string
Return values
PromiseInterface<string|int, int>fetch()
Looks a chat up with `getChat`.
public
fetch(int|string $id) : PromiseInterface<string|int, ChatFullInfo>
Parameters
- $id : int|string
-
A chat id, or an
@channelusername.
Return values
PromiseInterface<string|int, ChatFullInfo>fetchOrGet()
The cached part if there is one, otherwise a fresh copy from Telegram.
public
fetchOrGet(int|string $id) : PromiseInterface<string|int, TPart>
Parameters
- $id : int|string
Return values
PromiseInterface<string|int, TPart>get()
The cached part with this id, if it has been seen.
public
get(int|string $id) : TPart|null
Parameters
- $id : int|string
Return values
TPart|nullgetIterator()
public
getIterator() : Traversable
Return values
Traversablehas()
public
has(int|string $id) : bool
Parameters
- $id : int|string
Return values
boolnormalise()
Telegram ids are integers, but they arrive as strings often enough - out of a config file, off a command argument - that a lookup has to accept both.
protected
static normalise(int|string $id) : int|string
A @channelusername is left alone; it is not an id at all.
Parameters
- $id : int|string