Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit 6754e61

Browse files
committed
Annictからハッシュタグ取得機能を追加 silane#7
1 parent 3f57d97 commit 6754e61

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

TVTComment/Model/ChatCollectService/TwitterLiveChatCollectService.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using TVTComment.Model.ChatCollectServiceEntry;
1212
using TVTComment.Model.NiconicoUtils;
1313
using TVTComment.Model.TwitterUtils;
14+
using TVTComment.Model.TwitterUtils.AnnictUtils;
1415
using static TVTComment.Model.ChatCollectServiceEntry.TwitterLiveChatCollectServiceEntry.ChatCollectServiceCreationOption;
1516

1617
namespace TVTComment.Model.ChatCollectService
@@ -37,15 +38,16 @@ public ChatPostObject(string text, string suffixtext) : base(text)
3738
private readonly ConcurrentQueue<Status> statusQueue = new ConcurrentQueue<Status>();
3839
private readonly CancellationTokenSource cancel = new CancellationTokenSource();
3940
private readonly ObservableValue<string> SearchWord = new ObservableValue<string>("");
41+
private readonly ObservableValue<string> EventTextWord = new ObservableValue<string>("");
4042
private readonly SearchWordResolver SearchWordResolver;
4143
private readonly ModeSelectMethod ModeSelect;
42-
44+
private readonly AnnictApis Annict;
4345

4446
public TwitterLiveChatCollectService(IChatCollectServiceEntry serviceEntry, string searchWord, ModeSelectMethod modeSelect, SearchWordResolver searchWordResolver, TwitterAuthentication twitter)
4547
{
48+
Twitter = twitter;
4649
ServiceEntry = serviceEntry;
4750
SearchWord.Value = searchWord;
48-
Twitter = twitter;
4951
ModeSelect = modeSelect;
5052
SearchWordResolver = searchWordResolver;
5153
switch (modeSelect)
@@ -58,6 +60,10 @@ public TwitterLiveChatCollectService(IChatCollectServiceEntry serviceEntry, stri
5860
chatCollectTask = SearchStreamAsync(searchWord, cancel.Token);
5961
break;
6062
}
63+
if (Twitter.AnnictToken != null && !Twitter.AnnictToken.Equals("")) {
64+
Annict = new(Twitter.AnnictToken);
65+
EventTextWord.Where(x => x != null && !x.Equals("")).Subscribe(res => _ = annictSearch(EventTextWord.Value));
66+
}
6167
}
6268

6369
public string GetInformationText()
@@ -81,11 +87,16 @@ await Task.Run(() =>
8187
}, cancel);
8288
}
8389

90+
private async Task annictSearch(string evetnText)
91+
{
92+
var result = await Annict.GetTwitterHashtagAsync(evetnText);
93+
if (result != null && !result.Equals("")) SearchWord.Value += " OR #" + result;
94+
}
95+
8496
public IEnumerable<Chat> GetChats(ChannelInfo channel,EventInfo events, DateTime time)
8597
{
8698
if (ModeSelect == ModeSelectMethod.Auto)
8799
{
88-
89100
SearchWord.Value = SearchWordResolver.Resolve(channel.NetworkId, channel.ServiceId);
90101
}
91102
if (chatCollectTask != null)
@@ -100,6 +111,9 @@ public IEnumerable<Chat> GetChats(ChannelInfo channel,EventInfo events, DateTime
100111
}
101112
}
102113

114+
var result = AnnimeTitleGetter.Convert(events.EventName);
115+
if (result != null && !result.Equals("")) EventTextWord.Value = result;
116+
103117
var list = new List<Chat>();
104118
while (statusQueue.TryDequeue(out var status))
105119
{

0 commit comments

Comments
 (0)