aboutsummaryrefslogtreecommitdiff
path: root/telegram/formatter
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-14 23:00:00 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-14 23:00:00 +0300
commitd6b3ed3aaa518c5f80f7eceddede507af592a45c (patch)
treecfb790b0c8b025e08e9fa759b22f5e1300dd1db0 /telegram/formatter
parent8aa5187e2ec93ec0a0864725cb158b0eb3331499 (diff)
Check for nil entity types
Diffstat (limited to 'telegram/formatter')
-rw-r--r--telegram/formatter/formatter.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/telegram/formatter/formatter.go b/telegram/formatter/formatter.go
index 53b4625..4d37be1 100644
--- a/telegram/formatter/formatter.go
+++ b/telegram/formatter/formatter.go
@@ -77,7 +77,7 @@ func MergeAdjacentEntities(entities []*client.TextEntity) []*client.TextEntity {
excludedIndices := make(map[int]bool)
for i, entity := range entities {
- if excludedIndices[i] {
+ if excludedIndices[i] || entity.Type == nil {
continue
}
@@ -88,7 +88,7 @@ func MergeAdjacentEntities(entities []*client.TextEntity) []*client.TextEntity {
// collect continuations
for j, entity2 := range entities[i+1:] {
- if entity2.Type.TextEntityTypeType() == typ && entity2.Offset == end {
+ if entity2.Type != nil && entity2.Type.TextEntityTypeType() == typ && entity2.Offset == end {
end += entity2.Length
ei[j+i+1] = true
}