Skip to content

Commit f1f1c7d

Browse files
authored
Merge pull request #180 from utyosu/feature/implements_mixch
ミクチャに接続できるようにする
2 parents fbb4606 + 58f848d commit f1f1c7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3247
-23
lines changed

BouyomiPlugin/BouyomiPlugin.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<ProjectReference Include="..\MirrativIF\MirrativIF.csproj" />
5151
<ProjectReference Include="..\NicoLiveIF\NicoLiveIF.csproj" />
5252
<ProjectReference Include="..\OpenrecIF\OpenrecIF.csproj" />
53+
<ProjectReference Include="..\MixchIF\MixchIF.csproj" />
5354
<ProjectReference Include="..\PeriscopeIF\PeriscopeIF.csproj" />
5455
<ProjectReference Include="..\PluginCommon\PluginCommon.csproj" />
5556
<ProjectReference Include="..\ShowRoomIF\ShowRoomIF.csproj" />
@@ -71,4 +72,4 @@
7172
<Reference Include="System.Xaml" />
7273
<Reference Include="WindowsBase" />
7374
</ItemGroup>
74-
</Project>
75+
</Project>

BouyomiPlugin/ConfigView.xaml

+31-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<RowDefinition Height="Auto" />
7979
<RowDefinition Height="Auto" />
8080
<RowDefinition Height="Auto" />
81+
<RowDefinition Height="Auto" />
8182
<RowDefinition />
8283
</Grid.RowDefinitions>
8384
<Border Grid.Row="0" Grid.Column="0" BorderBrush="Black" BorderThickness="0,0,0,1">
@@ -564,10 +565,38 @@
564565
</Grid>
565566
</Border>
566567

567-
<Border Grid.Row="13" Grid.Column="0" BorderBrush="Black" BorderThickness="0,0,0,1">
568+
<Border Grid.Row="13" Grid.Column="0" BorderBrush="Black" BorderThickness="0 0 0 1">
569+
<TextBlock Text="ミクチャ" Margin="5" />
570+
</Border>
571+
<Border Grid.Row="13" Grid.Column="1" BorderBrush="Black" BorderThickness="0 0 0 1">
572+
<Grid Grid.Row="0" Grid.Column="1" Margin="5">
573+
<Grid.RowDefinitions>
574+
<RowDefinition />
575+
<RowDefinition />
576+
<RowDefinition />
577+
<RowDefinition />
578+
<RowDefinition />
579+
<RowDefinition />
580+
</Grid.RowDefinitions>
581+
<Grid.ColumnDefinitions>
582+
<ColumnDefinition />
583+
<ColumnDefinition />
584+
<ColumnDefinition />
585+
<ColumnDefinition />
586+
</Grid.ColumnDefinitions>
587+
<CheckBox x:Name="CheckMixchComment" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" IsChecked="{Binding IsMixchComment}" Content="コメント" />
588+
<CheckBox IsEnabled="{Binding IsChecked, ElementName=CheckMixchComment}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" IsChecked="{Binding IsMixchCommentNickname}" Content="コテハン" />
589+
<CheckBox IsEnabled="{Binding IsChecked, ElementName=CheckMixchComment}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" IsChecked="{Binding IsMixchCommentOnlyFirst}" Content="最初のコメントだけ読む" />
590+
<CheckBox x:Name="CheckMixchItem" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" IsChecked="{Binding IsMixchItem}" Content="アイテム" />
591+
<CheckBox IsEnabled="{Binding IsChecked, ElementName=CheckMixchItem}" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" IsChecked="{Binding IsMixchItemNickname}" Content="コテハン" />
592+
<CheckBox x:Name="CheckMixchSystem" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" IsChecked="{Binding IsMixchSystem}" Content="システムメッセージ" />
593+
</Grid>
594+
</Border>
595+
596+
<Border Grid.Row="14" Grid.Column="0" BorderBrush="Black" BorderThickness="0,0,0,1">
568597
<TextBlock Text="その他" Margin="5" />
569598
</Border>
570-
<Border Grid.Row="13" Grid.Column="1" BorderBrush="Black" BorderThickness="0,0,0,1">
599+
<Border Grid.Row="14" Grid.Column="1" BorderBrush="Black" BorderThickness="0,0,0,1">
571600
<Grid Margin="5">
572601
<Grid.RowDefinitions>
573602
<RowDefinition />

BouyomiPlugin/ConfigViewModel.cs

+51
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,57 @@ public bool IsOpenrecCommentNickname
213213
//}
214214
#endregion //OPENREC
215215

216+
#region ミクチャ
217+
/// <summary>
218+
/// MIXCHのコメントを読み上げるか
219+
/// </summary>
220+
public bool IsMixchComment
221+
{
222+
get => _options.IsMixchComment;
223+
set => _options.IsMixchComment = value;
224+
}
225+
/// <summary>
226+
/// MIXCHのコメントのコテハンを読み上げるか
227+
/// </summary>
228+
public bool IsMixchCommentNickname
229+
{
230+
get => _options.IsMixchCommentNickname;
231+
set => _options.IsMixchCommentNickname = value;
232+
}
233+
/// <summary>
234+
/// MIXCHのコメントで最初だけ読むか
235+
/// </summary>
236+
public bool IsMixchCommentOnlyFirst
237+
{
238+
get => _options.IsMixchCommentOnlyFirst;
239+
set => _options.IsMixchCommentOnlyFirst = value;
240+
}
241+
/// <summary>
242+
/// MIXCHのアイテムを読み上げるか
243+
/// </summary>
244+
public bool IsMixchItem
245+
{
246+
get => _options.IsMixchItem;
247+
set => _options.IsMixchItem = value;
248+
}
249+
/// <summary>
250+
/// MIXCHのアイテムのコテハンを読み上げるか
251+
/// </summary>
252+
public bool IsMixchItemNickname
253+
{
254+
get => _options.IsMixchItemNickname;
255+
set => _options.IsMixchItemNickname = value;
256+
}
257+
/// <summary>
258+
/// MIXCHのシステムメッセージを読み上げるか
259+
/// </summary>
260+
public bool IsMixchSystem
261+
{
262+
get => _options.IsMixchSystem;
263+
set => _options.IsMixchSystem = value;
264+
}
265+
#endregion //MIXCH
266+
216267
#region Twitch
217268
/// <summary>
218269
/// Twitchの接続メッセージを読み上げるか

BouyomiPlugin/Options.cs

+16
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class Options : DynamicOptionsBase
4040
public bool IsOpenrecComment { get { return GetValue(); } set { SetValue(value); } }
4141
public bool IsOpenrecCommentNickname { get { return GetValue(); } set { SetValue(value); } }
4242

43+
//ミクチャ
44+
public bool IsMixchComment { get { return GetValue(); } set { SetValue(value); } }
45+
public bool IsMixchCommentNickname { get { return GetValue(); } set { SetValue(value); } }
46+
public bool IsMixchCommentOnlyFirst { get { return GetValue(); } set { SetValue(value); } }
47+
public bool IsMixchItem { get { return GetValue(); } set { SetValue(value); } }
48+
public bool IsMixchItemNickname { get { return GetValue(); } set { SetValue(value); } }
49+
public bool IsMixchSystem { get { return GetValue(); } set { SetValue(value); } }
50+
4351
//Twitch
4452
public bool IsTwitchConnect { get { return GetValue(); } set { SetValue(value); } }
4553
public bool IsTwitchDisconnect { get { return GetValue(); } set { SetValue(value); } }
@@ -154,6 +162,14 @@ protected override void Init()
154162
Dict.Add(nameof(IsOpenrecComment), new Item { DefaultValue = true, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
155163
Dict.Add(nameof(IsOpenrecCommentNickname), new Item { DefaultValue = true, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
156164

165+
//ミクチャ
166+
Dict.Add(nameof(IsMixchComment), new Item { DefaultValue = true, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
167+
Dict.Add(nameof(IsMixchCommentNickname), new Item { DefaultValue = true, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
168+
Dict.Add(nameof(IsMixchCommentOnlyFirst), new Item { DefaultValue = false, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
169+
Dict.Add(nameof(IsMixchItem), new Item { DefaultValue = true, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
170+
Dict.Add(nameof(IsMixchItemNickname), new Item { DefaultValue = true, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
171+
Dict.Add(nameof(IsMixchSystem), new Item { DefaultValue = true, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
172+
157173
//Twitch
158174
Dict.Add(nameof(IsTwitchConnect), new Item { DefaultValue = false, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });
159175
Dict.Add(nameof(IsTwitchDisconnect), new Item { DefaultValue = false, Predicate = b => true, Serializer = b => b.ToString(), Deserializer = s => bool.Parse(s) });

BouyomiPlugin/main.cs

+41
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using MirrativSitePlugin;
55
using NicoSitePlugin;
66
using OpenrecSitePlugin;
7+
using MixchSitePlugin;
78
using PeriscopeSitePlugin;
89
using Plugin;
910
using PluginCommon;
@@ -217,6 +218,46 @@ private static (string name, string comment) GetData(ISiteMessage message, Optio
217218
break;
218219
}
219220
}
221+
else if (message is IMixchMessage mixchMessage)
222+
{
223+
switch (mixchMessage.MixchMessageType)
224+
{
225+
case MixchMessageType.Comment:
226+
if (options.IsMixchComment && (!options.IsMixchCommentOnlyFirst || mixchMessage.IsFirstComment))
227+
{
228+
if (options.IsMixchCommentNickname)
229+
{
230+
name = mixchMessage.NameItems.ToText();
231+
}
232+
comment = mixchMessage.MessageItems.ToText();
233+
}
234+
break;
235+
case MixchMessageType.SuperComment:
236+
case MixchMessageType.Stamp:
237+
case MixchMessageType.PoiPoi:
238+
case MixchMessageType.Item:
239+
case MixchMessageType.CoinBox:
240+
if (options.IsMixchItem)
241+
{
242+
if (options.IsMixchItemNickname)
243+
{
244+
name = mixchMessage.NameItems.ToText();
245+
}
246+
comment = mixchMessage.MessageItems.ToText();
247+
}
248+
break;
249+
case MixchMessageType.Share:
250+
case MixchMessageType.EnterNewbie:
251+
case MixchMessageType.EnterLevel:
252+
case MixchMessageType.Follow:
253+
case MixchMessageType.EnterFanclub:
254+
if (options.IsMixchSystem)
255+
{
256+
comment = mixchMessage.MessageItems.ToText();
257+
}
258+
break;
259+
}
260+
}
220261
else if (message is ITwitchMessage twitchMessage)
221262
{
222263
switch (twitchMessage.TwitchMessageType)

ISitePlugin/SiteType.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace SitePlugin
22
{
33
/// <summary>
4-
///
4+
///
55
/// </summary>
66
/// プラグインにはどのサイトなのか伝える必要があると判断。そのためにはこれが必要。
77
/// ただしコメビュ内では使いたくない。抽象化が薄れてしまう。
@@ -11,6 +11,7 @@ public enum SiteType
1111
NicoLive,
1212
YouTubeLive,
1313
Openrec,
14+
Mixch,
1415
/// <summary>
1516
/// ふわっち
1617
/// </summary>

MixchIF/Message.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using SitePlugin;
2+
using System;
3+
using System.Collections.Generic;
4+
5+
namespace MixchSitePlugin
6+
{
7+
public enum MixchMessageType : int
8+
{
9+
Comment = 0,
10+
Status = 10,
11+
SuperComment = 42,
12+
Stamp = 45,
13+
PoiPoi = 46,
14+
Item = 48,
15+
Share = 50,
16+
CoinBox = 53,
17+
EnterNewbie = 60,
18+
EnterLevel = 61,
19+
Follow = 62,
20+
EnterFanclub = 63,
21+
}
22+
23+
public interface IMixchMessage : ISiteMessage
24+
{
25+
MixchMessageType MixchMessageType { get; set; }
26+
IEnumerable<IMessagePart> NameItems { get; }
27+
IEnumerable<IMessagePart> MessageItems { get; }
28+
string Id { get; }
29+
DateTime PostTime { get; }
30+
bool IsFirstComment { get; }
31+
string UserId { get; }
32+
}
33+
}

MixchIF/MixchIF.csproj

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net462</TargetFramework>
4+
<LangVersion>8.0</LangVersion>
5+
<Configurations>Release;Beta;Alpha;Debug</Configurations>
6+
</PropertyGroup>
7+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
8+
<OutputPath>bin\Release\</OutputPath>
9+
<DefineConstants>TRACE</DefineConstants>
10+
<WarningLevel>4</WarningLevel>
11+
<DebugType>pdbonly</DebugType>
12+
<Optimize>true</Optimize>
13+
<ErrorReport>prompt</ErrorReport>
14+
<WarningLevel>4</WarningLevel>
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Beta|AnyCPU'">
17+
<OutputPath>bin\Beta\</OutputPath>
18+
<DefineConstants>TRACE;BETA</DefineConstants>
19+
<WarningLevel>4</WarningLevel>
20+
<Optimize>true</Optimize>
21+
<DebugType>pdbonly</DebugType>
22+
<PlatformTarget>AnyCPU</PlatformTarget>
23+
<ErrorReport>prompt</ErrorReport>
24+
</PropertyGroup>
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Alpha|AnyCPU'">
26+
<DefineConstants>TRACE;DEBUG;ALPHA</DefineConstants>
27+
<WarningLevel>4</WarningLevel>
28+
<DebugType>full</DebugType>
29+
<DebugSymbols>true</DebugSymbols>
30+
<Optimize>false</Optimize>
31+
</PropertyGroup>
32+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
33+
<DefineConstants>DEBUG;TRACE</DefineConstants>
34+
<WarningLevel>4</WarningLevel>
35+
<DebugType>full</DebugType>
36+
<DebugSymbols>true</DebugSymbols>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<ProjectReference Include="..\ISitePlugin\SitePlugin.csproj" />
40+
</ItemGroup>
41+
</Project>

MixchIF/Properties/AssemblyInfo.cs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


MixchSitePlugin/API.cs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Codeplex.Data;
2+
using Newtonsoft.Json;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Net;
7+
using System.Text;
8+
using System.Text.RegularExpressions;
9+
using System.Threading.Tasks;
10+
11+
namespace MixchSitePlugin
12+
{
13+
class Me
14+
{
15+
public string DisplayName { get; set; }
16+
public string UserId { get; set; }
17+
}
18+
static class API
19+
{
20+
public static async Task<Me> GetMeAsync(IDataSource server, CookieContainer cc)
21+
{
22+
var me = new Me();
23+
var url = "https://mixch.tv/mypage";
24+
var res = await server.GetAsync(url, cc);
25+
var match0 = Regex.Match(res, "<p class=\"name\">\\s*([^<\\s]*)?\\s*</p>\\s*<p class=\"id\">");
26+
if (match0.Success)
27+
{
28+
var displayName = match0.Groups[1].Value;
29+
me.DisplayName = displayName;
30+
}
31+
var match1 = Regex.Match(res, "<p class=\"id\">\\s*ID\\s*:\\s*([0-9]+)");
32+
if (match1.Success)
33+
{
34+
me.UserId = match1.Groups[1].Value;
35+
}
36+
return me;
37+
}
38+
}
39+
}

MixchSitePlugin/CommentPostPanel.xaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<UserControl x:Class="MixchSitePlugin.CommentPostPanel"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:MixchSitePlugin"
7+
mc:Ignorable="d"
8+
d:DataContext="{d:DesignInstance local:CommentPostPanelViewModel, IsDesignTimeCreatable=True}"
9+
d:DesignHeight="300" d:DesignWidth="400"
10+
Height="50" Width="400">
11+
<Grid>
12+
<TextBox Text="{Binding Input}" IsEnabled="{Binding CanPostComment}" HorizontalAlignment="Stretch" Height="23" Margin="5,0,45,5" TextWrapping="Wrap" VerticalAlignment="Bottom"/>
13+
<Button Content="投稿" IsEnabled="{Binding CanPostComment}" HorizontalAlignment="Right" Margin="0,0,5,5" VerticalAlignment="Bottom" Width="35"/>
14+
15+
</Grid>
16+
</UserControl>
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace MixchSitePlugin
17+
{
18+
/// <summary>
19+
/// Interaction logic for CommentPostPanel.xaml
20+
/// </summary>
21+
public partial class CommentPostPanel : UserControl
22+
{
23+
public CommentPostPanel()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)