Skip to content

Instantly share code, notes, and snippets.

@uburuntu
Created March 11, 2022 17:02
Show Gist options
  • Save uburuntu/77b65b3d061e80ec4d322609738d8337 to your computer and use it in GitHub Desktop.
Save uburuntu/77b65b3d061e80ec4d322609738d8337 to your computer and use it in GitHub Desktop.
Telegram bot schema for EdgeDB
module meta {
abstract type HasCreated {
required property created -> datetime {
default := std::datetime_current();
}
}
abstract type HasMetadata {
required property metadata -> json {
default := <json>'{}';
}
}
}
module telegram {
type BotUpdate extending meta::HasCreated {
annotation title := 'Telegram update';
annotation description := 'This object represents an incoming update';
required property data -> json;
required property handled -> bool {
default := false;
}
}
type User extending meta::HasCreated, meta::HasMetadata {
annotation title := 'Telegram user';
annotation description := 'This object represents a Telegram user or bot';
required property user_id -> int64 {
constraint exclusive;
}
required property is_bot -> bool;
required property first_name -> str;
property last_name -> str;
property username -> str;
property language_code -> str;
# Computed
property full_name := .first_name ++ ' ' ++ .last_name if exists .last_name else .first_name;
}
type Chat extending meta::HasCreated, meta::HasMetadata {
annotation title := 'Telegram chat';
annotation description := 'This object represents a chat';
required property chat_id -> int64 {
constraint exclusive;
}
required property type -> str;
property title -> str;
property username -> str;
property first_name -> str;
property last_name -> str;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment