Skip to content

Commit

Permalink
更正 location 的传值
Browse files Browse the repository at this point in the history
  • Loading branch information
sisi0318 committed Oct 28, 2024
1 parent 0fd926c commit 7b72657
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Lagrange.OneBot/Message/Entity/LocationSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public partial class LocationSegment(float latitude, float longitude)
{
public LocationSegment() : this(0f, 0f) { }

[JsonPropertyName("lat")] [CQProperty] public string Latitude { get; set; } = latitude.ToString("F5");
[JsonPropertyName("lat")][CQProperty] public string Latitude { get; set; } = latitude.ToString("F5");

[JsonPropertyName("lon")] [CQProperty] public string Longitude { get; set; } = longitude.ToString("F5");
[JsonPropertyName("lon")][CQProperty] public string Longitude { get; set; } = longitude.ToString("F5");

[JsonPropertyName("title")] public string Title { get; set; } = string.Empty;

Expand All @@ -24,22 +24,22 @@ public LocationSegment() : this(0f, 0f) { }
[SegmentSubscriber(typeof(LightAppEntity), "location")]
public partial class LocationSegment : SegmentBase
{
private static readonly JsonSerializerOptions Options = new() { Converters = { new AutosizeConverter() } };
private static readonly JsonSerializerOptions Options = new() { Converters = { new AutosizeConverter() }, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };

public override void Build(MessageBuilder builder, SegmentBase segment)
{
if (segment is not LocationSegment location) return;

var json = new LightApp
{
App = "com.tencent.map",
Config = new Config
{
Autosize = false,
Ctime = DateTimeOffset.UtcNow.Second,
Token = "626399d3453d0693fe19e12cd3747c56",
Type = "normal"
},
// Config = new Config
// {
// Autosize = false,
// Ctime = DateTimeOffset.UtcNow.Second,
// Token = "626399d3453d0693fe19e12cd3747c56",
// Type = "normal",
// },
Desc = "",
From = 1,
Meta = new Meta
Expand All @@ -59,8 +59,8 @@ public override void Build(MessageBuilder builder, SegmentBase segment)
Ver = "1.1.2.21",
View = "LocationShare"
};
builder.LightApp(JsonSerializer.Serialize(json));

builder.LightApp(JsonSerializer.Serialize(json, Options));
}

public override SegmentBase? FromEntity(MessageChain chain, IMessageEntity entity)
Expand All @@ -72,12 +72,12 @@ public override void Build(MessageBuilder builder, SegmentBase segment)
return new LocationSegment
{
Latitude = app.Meta.LocationSearch.Lat,
Longitude =app.Meta.LocationSearch.Lng,
Longitude = app.Meta.LocationSearch.Lng,
Content = app.Meta.LocationSearch.Address,
Title = app.Meta.LocationSearch.Name,
};
}

return null;
}
}

0 comments on commit 7b72657

Please sign in to comment.