Integrate per-save identity and interaction UI
This commit is contained in:
parent
ac82a28f3b
commit
4fda6e97f6
58 changed files with 3471 additions and 461 deletions
|
|
@ -15,6 +15,9 @@ static var _invisible_edge_pattern: RegEx = RegEx.create_from_string(
|
|||
static var _visible_content_pattern: RegEx = RegEx.create_from_string(
|
||||
"[^\\s\\p{Z}\\p{Cf}\\x{2800}]"
|
||||
)
|
||||
static var _roleplay_separator_pattern: RegEx = RegEx.create_from_string(
|
||||
"^[\\s\\p{Z}\\p{Cf}\\x{2800}]"
|
||||
)
|
||||
|
||||
enum Kind { PLAYER, SYSTEM }
|
||||
|
||||
|
|
@ -40,12 +43,40 @@ static func sanitize_body(value: Variant) -> String:
|
|||
return result
|
||||
|
||||
|
||||
static func is_roleplay_body(value: Variant) -> bool:
|
||||
var body: String = sanitize_body(value)
|
||||
if body.length() < 3 or body.left(3).to_lower() != "/me":
|
||||
return false
|
||||
return (
|
||||
body.length() == 3
|
||||
or _roleplay_separator_pattern.search(body.substr(3, 1)) != null
|
||||
)
|
||||
|
||||
|
||||
static func roleplay_action(value: Variant) -> String:
|
||||
var body: String = sanitize_body(value)
|
||||
if not is_roleplay_body(body):
|
||||
return ""
|
||||
return sanitize_body(body.substr(3))
|
||||
|
||||
|
||||
static func valid_user_body(value: Variant) -> bool:
|
||||
var body: String = sanitize_body(value)
|
||||
return (
|
||||
not body.is_empty()
|
||||
and (
|
||||
not is_roleplay_body(body)
|
||||
or not roleplay_action(body).is_empty()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
static func validate_request(data: Variant) -> bool:
|
||||
return (
|
||||
typeof(data) == TYPE_DICTIONARY
|
||||
and _valid_id(data.get("request_id"))
|
||||
and _valid_id(data.get("session_id"))
|
||||
and not sanitize_body(data.get("body")).is_empty()
|
||||
and valid_user_body(data.get("body"))
|
||||
and NetworkIdentityCrypto.valid_fingerprint(
|
||||
data.get("sender_fingerprint")
|
||||
)
|
||||
|
|
@ -67,7 +98,16 @@ static func validate_message(data: Variant) -> bool:
|
|||
and typeof(data.get("sender_peer_id")) == TYPE_INT
|
||||
and typeof(data.get("sender_display_name")) == TYPE_STRING
|
||||
and str(data["sender_display_name"]).length() <= 24
|
||||
and not sanitize_body(data.get("body")).is_empty()
|
||||
and (
|
||||
(
|
||||
int(data["kind"]) == Kind.SYSTEM
|
||||
and not sanitize_body(data.get("body")).is_empty()
|
||||
)
|
||||
or (
|
||||
int(data["kind"]) == Kind.PLAYER
|
||||
and valid_user_body(data.get("body"))
|
||||
)
|
||||
)
|
||||
and NetworkIdentityCrypto.valid_fingerprint(
|
||||
data.get("sender_fingerprint")
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue