Skip to content

Commit f0dc35e

Browse files
authored
Fix: Update demo and test to newer version (#49)
1 parent c33ea53 commit f0dc35e

25 files changed

Lines changed: 200 additions & 62 deletions

‎TwitcherSharp.Demo/Scenes/Main.cs‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System;
33
using TwitcherSharp.Api.Generated;
44
using TwitcherSharp.Chat;
5+
using TwitcherSharp.EventSub;
6+
using TwitcherSharp.EventSub.Generated.ChannelChatMessage;
57

68
namespace TwitcherSharp.Demo.Scenes;
79

@@ -10,9 +12,16 @@ public partial class Main : Node3D
1012
// Called when the node enters the scene tree for the first time.
1113
public override async void _Ready()
1214
{
13-
await TwitchService.GetInstance().Setup();
14-
TwitchApi.GetInstance();
15-
TwitchChat.GetInstance();
16-
TwitchBot.GetInstance();
15+
await TwitchService.Instance.Setup();
16+
GD.Print("test");
17+
var user = await TwitchService.Instance.GetCurrentUser();
18+
var test = await TwitchService.Instance.SubscribeEvent(TwitchEventSubDefinition.ChannelChatMessage,
19+
new TwitchChannelChatMessageCondition()
20+
{
21+
BroadcasterUserId = user.Id,
22+
UserId = user.Id,
23+
});
24+
GD.Print("test2");
25+
GD.Print(test);
1726
}
1827
}

‎TwitcherSharp.Demo/Scenes/Main.tscn‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ created_at = "2020-06-12T11:47:24Z"
7575
[sub_resource type="Resource" id="Resource_ss7yp"]
7676
script = ExtResource("12_c4ay3")
7777

78-
[sub_resource type="Resource" id="Resource_kpo4j"]
78+
[sub_resource type="Resource" id="Resource_aht7i"]
7979
script = ExtResource("11_aht7i")
8080
token_url = "https://id.twitch.tv/oauth2/token"
8181
authorization_url = "https://id.twitch.tv/oauth2/authorize"
@@ -183,23 +183,23 @@ metadata/_custom_type_script = "uid://bf3mvh373suhc"
183183
[node name="BotApi" type="Node" parent="Twitcher/TwitchBot" unique_id=536885245]
184184
script = ExtResource("10_c4ay3")
185185
token = SubResource("Resource_xvtyr")
186-
oauth_setting = SubResource("Resource_kpo4j")
186+
oauth_setting = SubResource("Resource_aht7i")
187187

188188
[node name="BotAuth" type="Node" parent="Twitcher/TwitchBot" unique_id=2047592989]
189189
script = ExtResource("12_5jffn")
190-
oauth_setting = SubResource("Resource_kpo4j")
190+
oauth_setting = SubResource("Resource_aht7i")
191191
token = SubResource("Resource_xvtyr")
192192
scopes = ExtResource("13_kpo4j")
193193

194194
[node name="OAuth" type="Node" parent="Twitcher/TwitchBot/BotAuth" unique_id=1775236126 node_paths=PackedStringArray("token_handler")]
195195
script = ExtResource("14_4n42c")
196-
oauth_setting = SubResource("Resource_kpo4j")
196+
oauth_setting = SubResource("Resource_aht7i")
197197
scopes = ExtResource("13_kpo4j")
198198
token_handler = NodePath("../TokenHandler")
199199

200200
[node name="TokenHandler" type="Node" parent="Twitcher/TwitchBot/BotAuth" unique_id=1613340214]
201201
script = ExtResource("15_c5snn")
202-
oauth_setting = SubResource("Resource_kpo4j")
202+
oauth_setting = SubResource("Resource_aht7i")
203203
token = SubResource("Resource_xvtyr")
204204

205205
[node name="TwitchChat" type="Node" parent="Twitcher" unique_id=1477573617 node_paths=PackedStringArray("media_loader", "eventsub", "api")]

‎TwitcherSharp.Demo/Scenes/NumbersGame/Numbers404.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override async void _Ready()
4343

4444
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
4545

46-
TwitchChat.GetInstance().MessageReceived += async message => await OnMessageReceived(message);
46+
TwitchChat.Instance.MessageReceived += async message => await OnMessageReceived(message);
4747
this.GetTwitcherNode<TwitchCommand>("StartCommand").CommandReceived += async (_, _, _) => await Start();
4848
this.GetTwitcherNode<TwitchCommand>("StopCommand").CommandReceived += async (_, _, _) => await Stop();
4949
}

‎TwitcherSharp.Demo/Scenes/WordGames/WordTemptation.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override async void _Ready()
3737

3838
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
3939

40-
TwitchChat.GetInstance().MessageReceived += OnMessageReceived;
40+
TwitchChat.Instance.MessageReceived += OnMessageReceived;
4141
this.GetTwitcherNode<TwitchCommand>("StartCommand").CommandReceived += async (_, _, _) => await Start();
4242
this.GetTwitcherNode<TwitchCommand>("StopCommand").CommandReceived += async (_, _, _) => await Stop();
4343
this.GetTwitcherNode<TwitchCommand>("ScoreCommand").CommandReceived +=

‎TwitcherSharp.Demo/TwitcherSharp.Demo.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Godot.NET.Sdk/4.6.1">
1+
<Project Sdk="Godot.NET.Sdk/4.6.2">
22
<PropertyGroup>
33
<TargetFramework>net10.0</TargetFramework>
44
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Godot.NET.Sdk/4.6.1">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
5+
<EnableDynamicLoading>true</EnableDynamicLoading>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Temptica.TwitcherSharp" Version="2.4.1-alpha.1" />
9+
</ItemGroup>
10+
<ItemGroup>
11+
<ProjectReference Include="..\TwitcherSharp\TwitcherSharp.csproj" />
12+
</ItemGroup>
13+
</Project>

‎TwitcherSharp.Demo/TwitcherSharp.Demo.sln.DotSettings.user‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAction_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Ftemptica_003F_002Econfig_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F96cdc125bbb64b3b9d71965ddb6d2564ed7910_003Fa8_003Fde74c179_003FAction_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
23
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArray_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Ftemptica_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1c378f459c054fecaf4484a0fa6d44c055a800_003F13_003Fc06683b0_003FArray_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
34
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACharacterBody3D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Ftemptica_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1ca148c7f8944e8994ee3fcff44c79e7580200_003F7d_003F40aa86e3_003FCharacterBody3D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
45
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExecutionContext_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Ftemptica_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fd9c727cdfa9b5b574cd1cf7982619392db38b8e95c074a019c03b7feba5e6_003FExecutionContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
[gd_resource type="Resource" script_class="TwitchOAuthScopes" format=3 uid="uid://fcmfkstye4bq"]
1+
[gd_resource type="Resource" script_class="TwitchOAuthScopes" load_steps=2 format=3 uid="uid://fcmfkstye4bq"]
22

33
[ext_resource type="Script" uid="uid://b3n3et8mebjcc" path="res://addons/twitcher/auth/twitch_oauth_scopes.gd" id="1_2b4sa"]
44

55
[resource]
66
script = ExtResource("1_2b4sa")
7-
used_scopes = Array[StringName]([&"user:read:chat", &"user:write:chat", &"moderator:read:followers", &"bits:read", &"channel:read:redemptions", &"channel:manage:redemptions", &"moderator:manage:announcements"])
7+
used_scopes = Array[StringName]([&"user:read:chat", &"user:write:chat", &"moderator:read:followers", &"bits:read", &"channel:read:redemptions", &"channel:manage:redemptions"])
88
metadata/_custom_type_script = "uid://b3n3et8mebjcc"

‎TwitcherSharp.Demo/addons/twitcher/auth/twitch_token_handler.gd‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ func _ready() -> void:
1717
validate_token()
1818

1919

20-
## Calles the validation endpoint of Twtich to make sure
21-
func validate_token() -> BufferedHTTPClient.ResponseData:
22-
var access_token: String = await get_access_token()
20+
## Cales the validation endpoint of Twitch to make sure that the token is still valid and get more information about it
21+
func validate_token(access_token: String = "") -> BufferedHTTPClient.ResponseData:
22+
if access_token == "":
23+
access_token = await get_access_token()
2324
if access_token == "":
2425
return null
26+
access_token = access_token.trim_prefix(OAuth.DEBUGGER_PROTECTION)
2527

2628
var validation_request = _http_client.request("https://id.twitch.tv/oauth2/validate", HTTPClient.METHOD_GET, {
2729
"Authorization": "OAuth %s" % access_token

‎TwitcherSharp.Demo/addons/twitcher/chat/twitch_bot_scopes.tres‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
[resource]
66
script = ExtResource("1_2uhiy")
7-
used_scopes = Array[StringName]([&"channel:bot", &"user:write:chat", &"user:bot"])
7+
used_scopes = Array[StringName]([&"channel:bot", &"user:write:chat", &"user:bot", &"moderator:manage:announcements"])
88
metadata/_custom_type_script = "uid://b3n3et8mebjcc"

0 commit comments

Comments
 (0)