webhook_telegram_bot.database.models

This file contains independent database models.

Module Contents

Classes

PydanticObjectId

This class provide pydantic compatible representation of ObjectId.

Webhook

This class represents webhook object.

Chat

This class represents chat object.

class webhook_telegram_bot.database.models.PydanticObjectId

Bases: bson.ObjectId

This class provide pydantic compatible representation of ObjectId.

classmethod __get_validators__(cls: Type[PydanticObjectId]) Generator[Callable[[Any], Any], None, None]

Return validators.

Returns

classmethod validate(cls: Type[PydanticObjectId], value: Any) Any

Validate object.

Parameters

value

Returns

class webhook_telegram_bot.database.models.Webhook

Bases: pydantic.BaseModel

This class represents webhook object.

webhook_id :str
service :str
repository_name :Optional[str]
__hash__(self) int

Return hash.

__eq__(self, other: object) bool

Return True if objects are equal.

class webhook_telegram_bot.database.models.Chat

Bases: pydantic.BaseModel

This class represents chat object.

class Config

Configuration of chat model.

allow_population_by_field_name = True
id :Optional[Union[int, PydanticObjectId]]
chat_id :int
webhooks :List[Webhook] = []
get_webhook_by_id(self, webhook_id: str) Optional[Webhook]

Return Webhook object by webhook_id.

Parameters

webhook_id – chat identification string

Returns

Webhook instance or None

set_webhook_repository_name(self, webhook_id: str, name: str) None

Set webhook repository_name.

Parameters
  • webhook_id – chat identification string

  • name – repository name

Returns

None

delete_webhook_by_id(self, webhook_id: str) None

Exclude webhook from webhooks list by id.

Parameters

webhook_id – chat identification string

Returns

None