This commit is contained in:
Florian Späth
2025-08-12 12:48:36 +02:00
parent f2f011343f
commit 0703373b48
40 changed files with 460 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}|NTFYlistener.csproj|c:\\local\\code\\privat\\server-tools\\adminpi\\ntfylistener\\ntfylistener\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}|NTFYlistener.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\Program.cs",
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\Program.cs*",
"RelativeToolTip": "Program.cs*",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAoAAAA2AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-08-08T18:54:16.293Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@@ -0,0 +1,37 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}|NTFYlistener.csproj|c:\\local\\code\\privat\\server-tools\\adminpi\\ntfylistener\\ntfylistener\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}|NTFYlistener.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\Program.cs",
"RelativeDocumentMoniker": "Program.cs",
"ToolTip": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\Program.cs",
"RelativeToolTip": "Program.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAoAAAA2AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-08-08T18:54:16.293Z",
"EditorCaption": ""
}
]
}
]
}
]
}

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36301.6 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTFYlistener", "NTFYlistener.csproj", "{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{667A302A-64F9-4E95-81D3-B2D7D15D5FE1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8CFFC1EE-C02C-4204-8570-15C0741EF7E3}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,41 @@
using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
class NtfyListener
{
static async Task Main(string[] args)
{
string topic = "MC"; // Replace with your topic
string server = "https://ntfy.spaeth-bayern.de"; // Or your own server
string url = $"{server}/{topic}";
Console.WriteLine($"Listening to topic '{topic}' on {server}...");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Timeout = Timeout.Infinite;
request.ReadWriteTimeout = Timeout.Infinite;
try
{
using WebResponse response = await request.GetResponseAsync();
using Stream stream = response.GetResponseStream();
using StreamReader reader = new StreamReader(stream);
while (!reader.EndOfStream)
{
string? line = await reader.ReadLineAsync();
if (!string.IsNullOrWhiteSpace(line))
{
Console.WriteLine($"[NTFY] {line}");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error listening to ntfy: {ex.Message}");
}
}
}

View File

@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"NTFYlistener/1.0.0": {
"runtime": {
"NTFYlistener.dll": {}
}
}
}
},
"libraries": {
"NTFYlistener/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

View File

@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.42000
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("NTFYlistener")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f2f011343f9f9a6a899bc234d7774a8653289dce")]
[assembly: System.Reflection.AssemblyProductAttribute("NTFYlistener")]
[assembly: System.Reflection.AssemblyTitleAttribute("NTFYlistener")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.

View File

@@ -0,0 +1 @@
82ef8a6b158508ce23b0cc9a52e5de41e1867114eb7c69465f5631593f7dd1e2

View File

@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = NTFYlistener
build_property.ProjectDir = C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =

View File

@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

View File

@@ -0,0 +1 @@
f0ca746650d2f1d550cd37916c160bc07234929cef55559f3a83d2d168593ef7

View File

@@ -0,0 +1,14 @@
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\bin\Debug\net8.0\NTFYlistener.exe
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\bin\Debug\net8.0\NTFYlistener.deps.json
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\bin\Debug\net8.0\NTFYlistener.runtimeconfig.json
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\bin\Debug\net8.0\NTFYlistener.dll
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\bin\Debug\net8.0\NTFYlistener.pdb
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\NTFYlistener.GeneratedMSBuildEditorConfig.editorconfig
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\NTFYlistener.AssemblyInfoInputs.cache
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\NTFYlistener.AssemblyInfo.cs
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\NTFYlistener.csproj.CoreCompileInputs.cache
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\NTFYlistener.dll
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\refint\NTFYlistener.dll
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\NTFYlistener.pdb
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\NTFYlistener.genruntimeconfig.cache
C:\local\Code\PRIVAT\server-tools\AdminPi\NTFYListener\NTFYlistener\obj\Debug\net8.0\ref\NTFYlistener.dll

View File

@@ -0,0 +1 @@
34a2addcf64f9530c9309400b9f5448fd80705b99294020fced60a7289bc3ff6

View File

@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\NTFYlistener.csproj": {}
},
"projects": {
"C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\NTFYlistener.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\NTFYlistener.csproj",
"projectName": "NTFYlistener",
"projectPath": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\NTFYlistener.csproj",
"packagesPath": "C:\\Users\\flori\\.nuget\\packages\\",
"outputPath": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\flori\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.302/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\flori\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\flori\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@@ -0,0 +1,79 @@
{
"version": 3,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"C:\\Users\\flori\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\NTFYlistener.csproj",
"projectName": "NTFYlistener",
"projectPath": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\NTFYlistener.csproj",
"packagesPath": "C:\\Users\\flori\\.nuget\\packages\\",
"outputPath": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\flori\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.300"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.302/PortableRuntimeIdentifierGraph.json"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "HAu+uNKjs2o=",
"success": true,
"projectFilePath": "C:\\local\\Code\\PRIVAT\\server-tools\\AdminPi\\NTFYListener\\NTFYlistener\\NTFYlistener.csproj",
"expectedPackageFiles": [],
"logs": []
}

30
AdminPi/listener.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Your command to run on "/start"
execute_command() {
echo "Received /start command! Executing..."
# Replace this line with your actual command
your_command_here
}
while true; do
now=$(date +%s)
cutoff=$((now - 8))
# Get all messages from the server
response=$(curl -s "https://ntfy.spaeth-bayern.de/MC/json?poll=1")
# Get the last (most recent) message line
last_line=$(echo "$response" | tail -n 1)
# Extract timestamp and message
msg_time=$(echo "$last_line" | jq -r '.time')
msg_text=$(echo "$last_line" | jq -r '.message')
# Check if message is recent and is "/start"
if [[ "$msg_time" -ge "$cutoff" && "$msg_text" == "/start" ]]; then
execute_command
fi
sleep 5
done