Skip to content

Commit da8cf68

Browse files
committed
feat: 移除 Patreon & 新增綠界贊助方案,並修正無法獲取表情的問題
1 parent bbbd8b9 commit da8cf68

11 files changed

Lines changed: 48 additions & 81 deletions

File tree

Discord Stream Notify Bot/BotConfig.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public class BotConfig
3131
public string TwitterCSRFToken { get; set; } = "";
3232
public string TwitterSpaceRecordPath { get; set; } = "";
3333

34+
public ulong YouTubeEmoteId { get; set; } = 1265158558299848827;
35+
public ulong PayPalEmoteId { get; set; } = 1265158658015236107;
36+
public ulong ECPayEmoteId { get; set; } = 1379272194210795622;
37+
3438
public void InitBotConfig()
3539
{
3640
try { File.WriteAllText("bot_config_example.json", JsonConvert.SerializeObject(new BotConfig(), Formatting.Indented)); } catch { }
@@ -98,6 +102,9 @@ public void InitBotConfig()
98102
GoogleClientId = config.GoogleClientId;
99103
GoogleClientSecret = config.GoogleClientSecret;
100104
UptimeKumaPushUrl = config.UptimeKumaPushUrl;
105+
YouTubeEmoteId = config.YouTubeEmoteId;
106+
PayPalEmoteId = config.PayPalEmoteId;
107+
ECPayEmoteId = config.ECPayEmoteId;
101108

102109
if (string.IsNullOrWhiteSpace(config.RedisTokenKey) || string.IsNullOrWhiteSpace(RedisTokenKey))
103110
{

Discord Stream Notify Bot/Command/Extensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Discord.Commands;
2-
using Discord_Stream_Notify_Bot.DataBase;
32
using Microsoft.Extensions.DependencyInjection;
43
using System.Data;
54
using System.Reflection;

Discord Stream Notify Bot/Interaction/Help/Help.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public async Task H([Summary("模組名稱"), Autocomplete(typeof(HelpGetModules
117117
embed.Title += " (測試版)";
118118
#endif
119119
embed.WithDescription(File.ReadAllText(Discord_Stream_Notify_Bot.Utility.GetDataFilePath("HelpDescription.txt")).Replace("\\n", "\n") +
120-
$"\n\n您可以透過 {Format.Url("Patreon", Discord_Stream_Notify_Bot.Utility.PatreonUrl)}{Format.Url("Paypal", Discord_Stream_Notify_Bot.Utility.PaypalUrl)} 來贊助直播小幫手");
120+
$"\n\n您可以透過 {Format.Url("綠界", Discord_Stream_Notify_Bot.Utility.ECPayUrl)}{Format.Url("Paypal", Discord_Stream_Notify_Bot.Utility.PaypalUrl)} 來贊助直播小幫手");
121121
await RespondAsync(embed: embed.Build());
122122
return;
123123
}

Discord Stream Notify Bot/SharedService/EmojiService.cs

Lines changed: 30 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,45 @@ namespace Discord_Stream_Notify_Bot.SharedService
44
{
55
public class EmojiService : IInteractionService
66
{
7-
// 好像要把 Emote Id 給拉到 BotConfig 設定還是怎樣的
8-
public Emote YouTubeEmote
7+
public Emote YouTubeEmote { get; private set; }
8+
public Emote PayPalEmote { get; private set; }
9+
public Emote ECPayEmote { get; private set; }
10+
11+
private readonly DiscordSocketClient _client;
12+
13+
public EmojiService(DiscordSocketClient client, BotConfig botConfig)
914
{
10-
get
15+
_client = client;
16+
17+
try
1118
{
12-
#if !RELEASE
13-
return null;
14-
#endif
15-
if (youTubeEmote == null)
16-
{
17-
try
18-
{
19-
Task.Run(async () => youTubeEmote = await _client.GetApplicationEmoteAsync(1265158558299848827));
20-
}
21-
catch (Exception ex)
22-
{
23-
Log.Error($"無法取得YouTube Emote: {ex}");
24-
youTubeEmote = null;
25-
}
26-
}
27-
return youTubeEmote;
19+
YouTubeEmote = _client.GetApplicationEmoteAsync(botConfig.YouTubeEmoteId).GetAwaiter().GetResult();
2820
}
29-
}
30-
31-
public Emote PatreonEmote
32-
{
33-
get
21+
catch (Exception ex)
3422
{
35-
#if !RELEASE
36-
return null;
37-
#endif
38-
if (patreonEmote == null)
39-
{
40-
try
41-
{
42-
Task.Run(async () => patreonEmote = await _client.GetApplicationEmoteAsync(1265158902962458769));
43-
}
44-
catch (Exception ex)
45-
{
46-
Log.Error($"無法取得Patreon Emote: {ex}");
47-
patreonEmote = null;
48-
}
49-
}
50-
return patreonEmote;
23+
Log.Error($"無法取得 YouTube Emote: {ex}");
24+
YouTubeEmote = null;
5125
}
52-
}
5326

54-
public Emote PayPalEmote
55-
{
56-
get
27+
try
5728
{
58-
#if !RELEASE
59-
return null;
60-
#endif
61-
if (payPalEmote == null)
62-
{
63-
try
64-
{
65-
Task.Run(async () => payPalEmote = await _client.GetApplicationEmoteAsync(1265158658015236107));
66-
}
67-
catch (Exception ex)
68-
{
69-
Log.Error($"無法取得PayPal Emote: {ex}");
70-
payPalEmote = null;
71-
}
72-
}
73-
return payPalEmote;
29+
PayPalEmote = _client.GetApplicationEmoteAsync(botConfig.PayPalEmoteId).GetAwaiter().GetResult();
30+
}
31+
catch (Exception ex)
32+
{
33+
Log.Error($"無法取得 PayPal Emote: {ex}");
34+
PayPalEmote = null;
7435
}
75-
}
76-
77-
private Emote youTubeEmote, patreonEmote, payPalEmote;
78-
private readonly DiscordSocketClient _client;
7936

80-
public EmojiService(DiscordSocketClient client)
81-
{
82-
_client = client;
37+
try
38+
{
39+
ECPayEmote = _client.GetApplicationEmoteAsync(botConfig.ECPayEmoteId).GetAwaiter().GetResult();
40+
}
41+
catch (Exception ex)
42+
{
43+
Log.Error($"無法取得 ECPay Emote: {ex}");
44+
ECPayEmote = null;
45+
}
8346
}
8447
}
8548
}

Discord Stream Notify Bot/SharedService/TwitCasting/TwitCastingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private async Task SendStreamMessageAsync(TwitcastingStream twitcastingStream, b
187187
else embedBuilder.WithOkColor();
188188

189189
MessageComponent comp = new ComponentBuilder()
190-
.WithButton("贊助小幫手 (Patreon) #ad", style: ButtonStyle.Link, emote: _emojiService.PatreonEmote, url: Utility.PatreonUrl, row: 1)
190+
.WithButton("贊助小幫手 (綠界) #ad", style: ButtonStyle.Link, emote: _emojiService.ECPayEmote, url: Utility.ECPayUrl, row: 1)
191191
.WithButton("贊助小幫手 (Paypal) #ad", style: ButtonStyle.Link, emote: _emojiService.PayPalEmote, url: Utility.PaypalUrl, row: 1).Build();
192192

193193
foreach (var item in noticeGuildList)

Discord Stream Notify Bot/SharedService/Twitch/TwitchService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public TwitchService(DiscordSocketClient client, BotConfig botConfig, EmojiServi
104104

105105
_messageComponent = new ComponentBuilder()
106106
.WithButton("好手氣,隨機帶你到一個影片或直播", style: ButtonStyle.Link, emote: emojiService.YouTubeEmote, url: "https://api.konnokai.me/randomvideo")
107-
.WithButton("贊助小幫手 (Patreon) #ad", style: ButtonStyle.Link, emote: emojiService.PatreonEmote, url: Utility.PatreonUrl, row: 1)
107+
.WithButton("贊助小幫手 (綠界) #ad", style: ButtonStyle.Link, emote: emojiService.ECPayEmote, url: Utility.ECPayUrl, row: 1)
108108
.WithButton("贊助小幫手 (Paypal) #ad", style: ButtonStyle.Link, emote: emojiService.PayPalEmote, url: Utility.PaypalUrl, row: 1).Build();
109109

110110
#nullable enable

Discord Stream Notify Bot/SharedService/Twitter/TwitterSpacesService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Runtime.InteropServices;
66

77
#if RELEASE
8-
using Microsoft.EntityFrameworkCore;
98
using Polly;
109
#endif
1110

@@ -204,7 +203,7 @@ private async Task SendSpaceMessageAsync(Result userModel, DataBase.Table.Twitte
204203
else embedBuilder.WithOkColor();
205204

206205
MessageComponent comp = new ComponentBuilder()
207-
.WithButton("贊助小幫手 (Patreon) #ad", style: ButtonStyle.Link, emote: _emojiService.PatreonEmote, url: Utility.PatreonUrl, row: 1)
206+
.WithButton("贊助小幫手 (綠界) #ad", style: ButtonStyle.Link, emote: _emojiService.ECPayEmote, url: Utility.ECPayUrl, row: 1)
208207
.WithButton("贊助小幫手 (Paypal) #ad", style: ButtonStyle.Link, emote: _emojiService.PayPalEmote, url: Utility.PaypalUrl, row: 1).Build();
209208

210209
foreach (var item in noticeGuildList)

Discord Stream Notify Bot/SharedService/Youtube/ChangeGuildBanner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private async Task ChangeGuildBannerAsync(string channelId, string videoId)
6060
Image image = new Image(memStream);
6161
await guild.ModifyAsync((func) => func.Banner = image);
6262
}
63-
63+
6464
item.LastChangeStreamId = videoId;
6565

6666
using (var db = _dbService.GetDbContext())

Discord Stream Notify Bot/SharedService/Youtube/YoutubeStreamService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public YoutubeStreamService(DiscordSocketClient client, IHttpClientFactory httpC
7272

7373
_messageComponent = new ComponentBuilder()
7474
.WithButton("好手氣,隨機帶你到一個影片或直播", style: ButtonStyle.Link, emote: emojiService.YouTubeEmote, url: "https://api.konnokai.me/randomvideo")
75-
.WithButton("贊助小幫手 (Patreon) #ad", style: ButtonStyle.Link, emote: emojiService.PatreonEmote, url: Utility.PatreonUrl, row: 1)
75+
.WithButton("贊助小幫手 (綠界) #ad", style: ButtonStyle.Link, emote: emojiService.ECPayEmote, url: Utility.ECPayUrl, row: 1)
7676
.WithButton("贊助小幫手 (Paypal) #ad", style: ButtonStyle.Link, emote: emojiService.PayPalEmote, url: Utility.PaypalUrl, row: 1).Build();
7777

7878
if (Bot.Redis != null)
@@ -668,9 +668,9 @@ public async Task<Embed> GetNowStreamingChannel(NowStreamingHost host)
668668
.Select((x) => x.Attributes["href"].Value.Split("?v=")[1]));
669669
}
670670
break;
671-
//case NowStreamingHost.Niji: //Todo: 實作2434現正直播查詢
672-
// return null;
673-
// break;
671+
//case NowStreamingHost.Niji: //Todo: 實作2434現正直播查詢
672+
// return null;
673+
// break;
674674
}
675675

676676
var video = YouTubeService.Videos.List("snippet");

Discord Stream Notify Bot/SharedService/YoutubeMember/CheckMemberShip.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Discord;
2-
using Discord_Stream_Notify_Bot.DataBase.Table;
1+
using Discord_Stream_Notify_Bot.DataBase.Table;
32
using Google.Apis.Auth.OAuth2;
43
using Google.Apis.Services;
54
using Google.Apis.YouTube.v3;

0 commit comments

Comments
 (0)