GitWatcherBot 1.0.0
A Telegram Bot that notifies you when a new change is made in your repositories (issues, pull requests, stars, forks, and watches)
Loading...
Searching...
No Matches
User.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <cstring>
6#include <ctime>
7#include <sqlite_orm/sqlite_orm.h>
8#include <tgbotxx/tgbotxx.hpp>
9#include "enums/UserStatus.inl"
10
11namespace models {
12 using UserId = decltype(tgbotxx::User::id);
13 using ChatId = decltype(tgbotxx::Chat::id);
14
15 struct User {
16 UserId id{};
18 UserStatus status{UserStatus::ACTIVE};
19 std::string firstName;
20 std::string lastName;
21 std::string username;
22 std::string languageCode;
23 bool isBot{};
24 bool isPremium{};
26 std::time_t createdAt{};
27 std::time_t updatedAt{};
28
29 static auto table() {
30 using namespace sqlite_orm;
31 return make_table("Users",
32 make_column("id", &User::id, primary_key()),
33 make_column("chatId", &User::chatId),
34 make_column("status", &User::status),
35 make_column("firstName", &User::firstName),
36 make_column("lastName", &User::lastName),
37 make_column("username", &User::username),
38 make_column("languageCode", &User::languageCode),
39 make_column("isBot", &User::isBot),
40 make_column("isPremium", &User::isPremium),
41 make_column("addedToAttachmentMenu", &User::addedToAttachmentMenu),
42 make_column("createdAt", &User::createdAt),
43 make_column("updatedAt", &User::updatedAt)
44 );
45 }
46
47 User() = default;
48
49 User(tgbotxx::Ptr<tgbotxx::User> tgUser, ChatId chatId) {
50 id = tgUser->id;
51 this->chatId = chatId;
52 status = UserStatus::ACTIVE;
53 firstName = tgUser->firstName;
54 lastName = tgUser->lastName;
55 username = tgUser->username;
56 languageCode = tgUser->languageCode;
57 isBot = tgUser->isBot;
58 isPremium = tgUser->isPremium;
59 addedToAttachmentMenu = tgUser->addedToAttachmentMenu;
60 createdAt = std::time(nullptr);
62 }
63 };
64}
65
Definition Log.hpp:12
decltype(tgbotxx::Chat::id) ChatId
Definition User.hpp:13
decltype(tgbotxx::User::id) UserId
Definition User.hpp:12
bool isBot
Definition User.hpp:23
std::string username
Definition User.hpp:21
std::time_t createdAt
Definition User.hpp:26
static auto table()
Definition User.hpp:29
UserId id
Definition User.hpp:16
std::time_t updatedAt
Definition User.hpp:27
bool isPremium
Definition User.hpp:24
User(tgbotxx::Ptr< tgbotxx::User > tgUser, ChatId chatId)
Definition User.hpp:49
UserStatus status
Definition User.hpp:18
User()=default
ChatId chatId
Definition User.hpp:17
bool addedToAttachmentMenu
Definition User.hpp:25
std::string lastName
Definition User.hpp:20
std::string languageCode
Definition User.hpp:22
std::string firstName
Definition User.hpp:19