comment badges/colors
This commit is contained in:
parent
f0090f75bc
commit
d2ae842f8b
|
@ -18,56 +18,20 @@ CrystalGauntlet.endpoints["/getGJComments21.php"] = ->(context : HTTP::Server::C
|
|||
users_str = [] of String
|
||||
has_users_str = false
|
||||
|
||||
DATABASE.query("select comments.id, comment, comments.created_at, likes, percent, user_id, users.username, users.udid, users.account_id, users.icon_type, users.color1, users.color2, users.cube, users.ship, users.ball, users.ufo, users.wave, users.robot, users.spider, users.special from comments left join users on users.id == user_id where level_id = ? order by #{params["mode"]? == 1 ? "likes" : "comments.created_at"} desc limit #{comments_per_page} offset #{comment_offset}", level_id) do |rs|
|
||||
rs.each do
|
||||
id = rs.read(Int32)
|
||||
comment = rs.read(String)
|
||||
created_at = rs.read(String)
|
||||
likes = rs.read(Int32)
|
||||
percent = rs.read(Int32 | Nil)
|
||||
user_id = rs.read(Int32)
|
||||
username = rs.read(String | Nil)
|
||||
udid = rs.read(String | Nil)
|
||||
account_id = rs.read(Int32 | Nil)
|
||||
icon_type = rs.read(Int32)
|
||||
color1 = rs.read(Int32)
|
||||
color2 = rs.read(Int32)
|
||||
DATABASE.query_all("select comments.id, comment, comments.created_at, likes, percent, user_id, users.username, users.udid, users.account_id, users.icon_type, users.color1, users.color2, users.cube, users.ship, users.ball, users.ufo, users.wave, users.robot, users.spider, users.special from comments left join users on users.id == user_id where level_id = ? order by #{params["mode"]? == 1 ? "likes" : "comments.created_at"} desc limit #{comments_per_page} offset #{comment_offset}", level_id, as: {Int32, String, String, Int32, Int32?, Int32, String?, String?, Int32?, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32}).each() do |id, comment, created_at, likes, percent, user_id, username, udid, account_id, icon_type, color1, color2, i1, i2, i3, i4, i5, i6, i7, special|
|
||||
icon_value = [i1, i2, i3, i4, i5, i6, i7][icon_type]
|
||||
|
||||
icon_value = [rs.read(Int32), rs.read(Int32), rs.read(Int32), rs.read(Int32), rs.read(Int32), rs.read(Int32), rs.read(Int32)][icon_type]
|
||||
if (params["gameVersion"]? || "19").to_i32 >= 20
|
||||
comment = Base64.urlsafe_encode(comment)
|
||||
end
|
||||
|
||||
special = rs.read(Int32)
|
||||
user_rank = account_id ? Ranks.get_rank(account_id) : nil
|
||||
LOG.debug { user_rank.not_nil!.name }
|
||||
LOG.debug { user_rank.not_nil!.text_color }
|
||||
|
||||
if (params["gameVersion"]? || "19").to_i32 >= 20
|
||||
comment = Base64.urlsafe_encode(comment)
|
||||
end
|
||||
|
||||
if Versions.parse(params["gameVersion"]? || "19") >= Versions::V2_1
|
||||
comments_str << [
|
||||
Format.fmt_comment({
|
||||
2 => comment,
|
||||
3 => user_id,
|
||||
4 => likes,
|
||||
5 => 0,
|
||||
6 => id,
|
||||
7 => likes <= config_get("comments.spam_thres", -3_i64),
|
||||
8 => account_id,
|
||||
9 => Time.parse(created_at, Format::TIME_FORMAT, Time::Location::UTC),
|
||||
10 => percent || 0,
|
||||
11 => "0",
|
||||
12 => "0,0,0", # todo: badge
|
||||
}),
|
||||
Format.fmt_comment({
|
||||
1 => username || "-",
|
||||
9 => icon_value,
|
||||
10 => color1,
|
||||
11 => color2,
|
||||
14 => icon_type,
|
||||
15 => special,
|
||||
16 => account_id || udid
|
||||
})
|
||||
].join(":")
|
||||
else
|
||||
comments_str << Format.fmt_comment({
|
||||
if Versions.parse(params["gameVersion"]? || "19") >= Versions::V2_1
|
||||
comments_str << [
|
||||
Format.fmt_comment({
|
||||
2 => comment,
|
||||
3 => user_id,
|
||||
4 => likes,
|
||||
|
@ -77,13 +41,36 @@ CrystalGauntlet.endpoints["/getGJComments21.php"] = ->(context : HTTP::Server::C
|
|||
8 => account_id,
|
||||
9 => Time.parse(created_at, Format::TIME_FORMAT, Time::Location::UTC),
|
||||
10 => percent || 0,
|
||||
11 => "0",
|
||||
12 => "0,0,0", # todo: badge
|
||||
11 => user_rank ? user_rank.badge : 0,
|
||||
12 => ((user_rank ? user_rank.text_color : nil) || [0, 0, 0]).join(","),
|
||||
}),
|
||||
Format.fmt_comment({
|
||||
1 => username || "-",
|
||||
9 => icon_value,
|
||||
10 => color1,
|
||||
11 => color2,
|
||||
14 => icon_type,
|
||||
15 => special,
|
||||
16 => account_id || udid
|
||||
})
|
||||
].join(":")
|
||||
else
|
||||
comments_str << Format.fmt_comment({
|
||||
2 => comment,
|
||||
3 => user_id,
|
||||
4 => likes,
|
||||
5 => 0,
|
||||
6 => id,
|
||||
7 => likes <= config_get("comments.spam_thres", -3_i64),
|
||||
8 => account_id,
|
||||
9 => Time.parse(created_at, Format::TIME_FORMAT, Time::Location::UTC),
|
||||
10 => percent || 0,
|
||||
11 => user_rank ? user_rank.badge : 0,
|
||||
12 => ((user_rank ? user_rank.text_color : nil) || [0, 0, 0]).join(","),
|
||||
})
|
||||
|
||||
users_str << [user_id, username || "-", account_id || udid ].join(":")
|
||||
has_users_str = true
|
||||
end
|
||||
users_str << [user_id, username || "-", account_id || udid ].join(":")
|
||||
has_users_str = true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,12 +25,13 @@ module CrystalGauntlet::Ranks
|
|||
config_get("ranks").as(Hash(String, TOML::Type)).each() do |key, value_|
|
||||
value = value_.as(Hash(String, TOML::Type))
|
||||
perms = value["permissions"]?.as?(Hash(String, TOML::Type)) || Hash(String, Bool).new
|
||||
color = value["text_color"]?.as?(Array(TOML::Type))
|
||||
@@ranks << Rank.new(
|
||||
name: key,
|
||||
position: value["position"].as(Int64),
|
||||
badge: value["badge"]?.as?(Int64) || 0_i64,
|
||||
is_mod: value["is_mod"]?.as?(Bool) || false,
|
||||
text_color: value["text_color"]?.as?(Array(Int64)),
|
||||
text_color: color ? color.map { |v| v.as(Int64) } : nil,
|
||||
permissions: perms.transform_values { |v| v.as?(Bool) || false }
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue