Skip to content

Commit 46689c7

Browse files
committed
rebuild bot client
1 parent e1fbb1e commit 46689c7

14 files changed

Lines changed: 122 additions & 64 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
방대한 기능과 몇몇 기능은 유료 기반이라 모든 기능을 테스트 완료하진 못하였습니다.
55
LINE Messenger 기반 챗봇을 개발하시는 분들께 도움이 되길 바랍니다.
66
```
7-
Install-Package
7+
Install-Package LineDevelopers -Version 1.0.1
88
```
9+
910
# 1. 사용 가이드 문서
1011
1. [메시지 생성 및 발송 가이드](https://github.com/charles96/LineDevelopers.Net/blob/master/MESSAGE_kor.md)
1112
2. [webhook quick start](https://github.com/charles96/LineDevelopers.Net/blob/master/WEBHOOK_kor.md)
12-
# 2. Library introduction
13+
# 2. 라이브러리 소개
1314

1415
## 2-1. LineChannelAccessTokenClient class
1516
* [Channel access token](https://developers.line.biz/en/reference/messaging-api/#channel-access-token)
@@ -21,7 +22,6 @@ using (var client = new LineChannelAccessTokenClient())
2122
{
2223
try
2324
{
24-
2525
var result = await client.IssueShortLivedChannelAccessTokenAsync("client id", "secret");
2626

2727
await client.VerifyShortLonglivedChannelAccessTokenAsync(result.AccessToken);

Src/LineDevelopers.ConsoleTests/Program.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010

1111

1212

13-
using (var client = new LineChannelAccessTokenClient())
13+
using (var client = new LineMessagingClient(config.ChannelAccessToken))
1414
{
1515
try
1616
{
1717

18-
var result = await client.IssueShortLivedChannelAccessTokenAsync("client id", "secret");
18+
var result = await client.Bot.GetBotInformationAsync();
19+
20+
Console.WriteLine(result.PremiumId);
21+
Console.WriteLine(result.PictureUrl);
22+
Console.WriteLine($"User ID : {result.UserId}");
23+
Console.WriteLine($"ChatMode : {result.ChatMode}");
24+
Console.WriteLine($"MarkAsReadMode : {result.MarkAsReadMode}");
1925

20-
await client.VerifyShortLonglivedChannelAccessTokenAsync(result.AccessToken);
2126
}
2227
catch (LineCredentialException ex)
2328
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Line.Message;
2+
3+
namespace LineDevelopers.Tests
4+
{
5+
[TestFixture]
6+
public class LineBotClientTest : BaseTest
7+
{
8+
[Test]
9+
public void GetBotInformationAsyncTest()
10+
{
11+
DoesNotThrowAsync(async () =>
12+
{
13+
var result = await base._client.Bot.GetBotInformationAsync();
14+
15+
That(result.DisplayName, Is.EqualTo("Atom"));
16+
That(result.MarkAsReadMode, Is.EqualTo(ReadType.Auto));
17+
That(result.ChatMode, Is.EqualTo(ChatType.Bot));
18+
});
19+
}
20+
}
21+
}

Src/LineDevelopers.Tests/LineUserClientTest.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
namespace LineDevelopers.Tests
22
{
33
[TestFixture]
4-
internal class LineUserClientTest : BaseTest
4+
public class LineUserClientTest : BaseTest
55
{
6-
[Test]
7-
public void GetBotInformationAsyncTest()
8-
{
9-
DoesNotThrowAsync(async () =>
10-
{
11-
var result = await base._client.GetBotInformationAsync();
12-
13-
AreEqual(result.DisplayName, "Atom");
14-
});
15-
}
16-
176
[Test]
187
public void GetUserProfileAsyncTest()
198
{

Src/LineDevelopers.Webhook.Sample/LineDevelopers.Webhook.Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.7" />
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
1111
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
1212
</ItemGroup>
1313

Src/LineDevelopers/LineDevelopers.csproj

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,29 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<AssemblyVersion>0.5.0.0</AssemblyVersion>
8-
<PackageProjectUrl>https://github.com/charles96/Line.MessageAPI.Net</PackageProjectUrl>
9-
<Title>Line.MessageAPI</Title>
8+
<PackageProjectUrl>https://github.com/charles96/LineDevelopers.NET</PackageProjectUrl>
9+
<Title>LineDevelopers.NET</Title>
1010
<Authors>Charles Hong</Authors>
1111
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
12-
<Description>C# class library for Line Messaing API </Description>
13-
<PackageTags>LINE;LINE Message;Chatbot</PackageTags>
12+
<Description>C# library for Line Developers API</Description>
13+
<PackageTags>LINE;LINE Message;Chatbot;LINE Developers</PackageTags>
1414
<RepositoryType>git</RepositoryType>
1515
<RootNamespace>Line</RootNamespace>
16+
<Version>0.5.0</Version>
17+
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
18+
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
19+
<PackageReadmeFile>README.md</PackageReadmeFile>
1620
</PropertyGroup>
1721

22+
<ItemGroup>
23+
<None Include="..\..\LICENSE.md">
24+
<Pack>True</Pack>
25+
<PackagePath>\</PackagePath>
26+
</None>
27+
<None Include="..\..\README.md">
28+
<Pack>True</Pack>
29+
<PackagePath>\</PackagePath>
30+
</None>
31+
</ItemGroup>
32+
1833
</Project>

Src/LineDevelopers/Message/Bot/BotInfo.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Line.Message.Bot
3+
namespace Line.Message
44
{
55
/// <summary>
66
/// Gets a bot's basic information.
77
/// </summary>
8-
public class BotInfo
8+
public class BotInformation
99
{
1010
/// <summary>
1111
/// Bot's user ID
@@ -24,7 +24,7 @@ public class BotInfo
2424
/// </summary>
2525
[JsonPropertyName("premiumId")]
2626
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
27-
public string PremiumId { get; set; }
27+
public string? PremiumId { get; set; }
2828

2929
/// <summary>
3030
/// Bot's display name
@@ -37,22 +37,22 @@ public class BotInfo
3737
/// </summary>
3838
[JsonPropertyName("pictureUrl")]
3939
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
40-
public string PictureUrl { get; set; }
40+
public string? PictureUrl { get; set; }
4141

4242
/// <summary>
4343
/// Chat settings set in the LINE Official Account Manager (opens new window). One of:
4444
/// chat: Chat is set to "On".
4545
/// bot: Chat is set to "Off".
4646
/// </summary>
4747
[JsonPropertyName("chatMode")]
48-
public string ChatMode { get; set; }
48+
public ChatType ChatMode { get; set; }
4949

5050
/// <summary>
5151
/// Automatic read setting for messages. If the chat is set to "Off", auto is returned. If the chat is set to "On", manual is returned.
5252
/// auto: Auto read setting is enabled.
5353
/// manual: Auto read setting is disabled.
5454
/// </summary>
5555
[JsonPropertyName("markAsReadMode")]
56-
public string MarkAsReadMode { get; set; }
56+
public ReadType MarkAsReadMode { get; set; }
5757
}
5858
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Line.Message
4+
{
5+
public enum ChatType
6+
{
7+
[EnumMember(Value = "chat")]
8+
Chat,
9+
10+
[EnumMember(Value = "bot")]
11+
Bot
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Line.Message
4+
{
5+
public enum ReadType
6+
{
7+
[EnumMember(Value = "auto")]
8+
Auto,
9+
10+
[EnumMember(Value = "manual")]
11+
Manual
12+
}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Line.Message
2+
{
3+
public interface IBotClient
4+
{
5+
public Task<BotInformation> GetBotInformationAsync();
6+
}
7+
}

0 commit comments

Comments
 (0)