diff options
| author | 2024-07-20 17:22:25 +0300 | |
|---|---|---|
| committer | 2024-07-20 17:22:25 +0300 | |
| commit | c70ffd095a6de5cd5b872796a0d82a8c5afc1511 (patch) | |
| tree | 56183274b05a294e357bad4d06b523472a1c4a4a /src/types/User.zig | |
| download | ukkobot-c70ffd095a6de5cd5b872796a0d82a8c5afc1511.tar.gz ukkobot-c70ffd095a6de5cd5b872796a0d82a8c5afc1511.tar.xz ukkobot-c70ffd095a6de5cd5b872796a0d82a8c5afc1511.zip | |
Initial commit
Diffstat (limited to 'src/types/User.zig')
| -rw-r--r-- | src/types/User.zig | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/types/User.zig b/src/types/User.zig new file mode 100644 index 0000000..dc06097 --- /dev/null +++ b/src/types/User.zig | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | const textutils = @import("../textutils.zig"); | ||
| 2 | |||
| 3 | const User = @This(); | ||
| 4 | |||
| 5 | id: i64, | ||
| 6 | is_bot: bool, | ||
| 7 | first_name: []const u8, | ||
| 8 | last_name: ?[]const u8 = null, | ||
| 9 | username: ?[]const u8 = null, | ||
| 10 | language_code: ?[]const u8 = null, | ||
| 11 | is_premium: bool = false, | ||
| 12 | added_to_attachment_menu: bool = false, | ||
| 13 | can_join_groups: bool = false, | ||
| 14 | can_read_all_group_messages: bool = false, | ||
| 15 | supports_inline_queries: bool = false, | ||
| 16 | can_connect_to_business: bool = false, | ||
| 17 | |||
| 18 | pub fn writeFormattedName(self: User, w: anytype) !void { | ||
| 19 | try w.print("<a href=\"tg://user?id={}\"><i>", .{self.id}); | ||
| 20 | try textutils.escapeXml(w, self.first_name); | ||
| 21 | if (self.last_name) |last_name| { | ||
| 22 | try w.writeByte(' '); | ||
| 23 | try textutils.escapeXml(w, last_name); | ||
| 24 | } | ||
| 25 | try w.writeAll("</i>"); | ||
| 26 | |||
| 27 | if (self.username) |username| { | ||
| 28 | try w.writeAll(" @"); | ||
| 29 | try textutils.escapeXml(w, username); | ||
| 30 | } | ||
| 31 | try w.print("</a> [<code>{}</code>]", .{self.id}); | ||
| 32 | } | ||