add new card kind, and do not raise error for unknown card kind (#467)

This commit is contained in:
jackyzy823 2021-11-20 22:12:33 +00:00 committed by GitHub
parent 5caf77481f
commit 68136de07b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -169,7 +169,7 @@ proc parseCard(js: JsonNode; urls: JsonNode): Card =
let
vals = ? js{"binding_values"}
name = js{"name"}.getStr
kind = parseEnum[CardKind](name[(name.find(":") + 1) ..< name.len])
kind = parseEnum[CardKind](name[(name.find(":") + 1) ..< name.len], unknown)
result = Card(
kind: kind,
@ -195,7 +195,7 @@ proc parseCard(js: JsonNode; urls: JsonNode): Card =
result.url = vals{"player_url"}.getStrVal
if "youtube.com" in result.url:
result.url = result.url.replace("/embed/", "/watch?v=")
of unified:
of unified, unknown:
result.title = "This card type is not supported."
else: discard

View file

@ -126,6 +126,8 @@ type
videoDirectMessage = "video_direct_message"
imageDirectMessage = "image_direct_message"
audiospace = "audiospace"
newsletter_publication = "newsletter_publication"
unknown
Card* = object
kind*: CardKind