Compare commits

...

No commits in common. "main" and "master" have entirely different histories.
main ... master

13 changed files with 514 additions and 321 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

120
.gitignore vendored
View File

@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
@ -12,52 +13,73 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015 cache/options directory
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# VS Code
.vscode/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
@ -67,6 +89,7 @@ artifacts/
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
@ -95,6 +118,9 @@ ipch/
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
@ -106,15 +132,21 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
@ -150,7 +182,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
@ -162,12 +194,14 @@ PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
@ -185,12 +219,15 @@ AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
!?*.[Cc]ache/
# Others
ClientBin/
@ -203,6 +240,10 @@ ClientBin/
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
@ -217,15 +258,22 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
@ -237,9 +285,6 @@ FakesAssemblies/
.ntvs_analysis.dat
node_modules/
# Typescript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
@ -264,12 +309,8 @@ paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
@ -279,6 +320,9 @@ __pycache__/
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
@ -287,3 +331,33 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

25
Chatbot_v0.8.1Beta.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35931.197 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chatbot_v0.8.1Beta", "Chatbot_v0.8.1Beta\Chatbot_v0.8.1Beta.csproj", "{8DF403AC-FAB2-4607-B5B1-B0964E43ED12}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8DF403AC-FAB2-4607-B5B1-B0964E43ED12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DF403AC-FAB2-4607-B5B1-B0964E43ED12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DF403AC-FAB2-4607-B5B1-B0964E43ED12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DF403AC-FAB2-4607-B5B1-B0964E43ED12}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E3A49929-220B-45FE-A161-0101E469E51B}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,9 @@
<Application x:Class="Chatbot_v0._8._1Beta.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Chatbot_v0._8._1Beta"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,14 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace Chatbot_v0._8._1Beta
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>Chatbot_v0._8._1Beta</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,44 @@
<Window x:Class="Chatbot_WPF_Projekt.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Chatbot_WPF_Projekt"
mc:Ignorable="d"
Title="ChatBot" Height="450" Width="880">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<!-- Chatverlauf -->
<RowDefinition Height="Auto" />
<!-- Eingabefeld und Buttons -->
</Grid.RowDefinitions>
<!-- Chat-Ausgabe (oben) -->
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
<TextBlock Name="ChatOutput"
TextWrapping="Wrap"
FontSize="14"
Background="#FFF0F0F0"
Padding="10"
/>
</ScrollViewer>
<!-- Eingabe + Buttons (unten) -->
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Bottom" Margin="0,10,0,0">
<TextBox Name="InputTextBox"
Width="500"
Height="30"
Margin="0,0,10,0"
KeyDown="InputTextBox_KeyDown"
VerticalContentAlignment="Center"
FontSize="14" Text=""
/>
<Button Name="SendButton" Content="Senden" Width="80" Height="30" Click="SendButton_Click"/>
<Button Name="ClearButton" Content="Löschen" Width="80" Height="30" Margin="10,0,0,0" Click="ClearButton_Click"/>
<Button Name="SaveButton" Content="Speichern" Click="SaveButton_Click" Margin="5"/>
<CheckBox x:Name="Color_theme" Content="Colortheme" Width="88" Cursor="Arrow" Checked="Color_theme_Checked" Unchecked="Color_theme_Unchecked" Margin="10,0,0,0" Background="#FFDDDDDD"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,240 @@
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using System.IO;
namespace Chatbot_WPF_Projekt
{
public partial class MainWindow : Window
{
// Variable für standort
private string currentLocation = "";
public MainWindow()
{
InitializeComponent();
}
// Methode für Senden-Button
private async void SendButton_Click(object sender, RoutedEventArgs e)
{
// Hole den Text und entferne führende Leerzeichen
string userInput = InputTextBox.Text.Trim();
// Überprüfe, ob der Text leer ist
if (string.IsNullOrEmpty(userInput))
{
MessageBox.Show("Bitte gib eine Nachricht ein!");
return;
}
// Füge die Nachricht des Benutzers zum Chat-Verlauf hinzu
ChatOutput.Text += $"Du: {userInput}\n";
// Deklariere die Variable botResponse
string botResponse = "";
// Überprüfe die Eingabe und reagiere entsprechend
if (userInput.ToLower() == "!hilfe")
{
botResponse = "Ich bin ein Chatbot. Du kannst folgende Befehle verwenden:\n!hilfe - Zeigt diese Nachricht\n!joke - Erzählt einen Witz\n!standort - Setzt deinen Standort\n!zeit - Zeigt die aktuelle Zeit am Standort\n!wetter - Zeigt das Wetter am Standort\n";
}
else if (userInput.ToLower() == "!joke")
{
string[] witze = new string[10];
witze[0] = "Warum können Geister so schlecht lügen? Weil man durch sie hindurchsieht.";
witze[1] = "Programmierer beim Bäcker: 'Ich hätte gern 2^3 Brötchen.'";
witze[2] = "Warum war der Entwickler pleite? Weil er in C# gearbeitet hat, aber nur in Cent bezahlt wurde.";
witze[3] = "Was sagt ein Bit zum anderen? 'Bist du noch ganz bei 0?'";
witze[4] = "Warum ging der Java-Entwickler ins Kloster? Er wollte finally blocken.";
witze[5] = "Wie nennt man einen falschen Programmierer? Einen *C#arlatan*.";
witze[6] = "Warum weinen Entwickler nie? Sie behandeln ihre Gefühle mit Try-Catch.";
witze[7] = "Was macht ein Informatiker beim Sport? Er läuft in Schleifen.";
witze[8] = "Warum ging der C#-Code nicht ins Kino? Zu viele Exceptions.";
witze[9] = "Was macht ein Arduino im Gefängnis? Er sitzt wegen Widerstands.";
Random zufall = new Random();
int zahl = zufall.Next(0, 10);
string output = witze[zahl];
botResponse = output;
}
else if (userInput.ToLower().StartsWith("!standort"))
{
string[] parts = userInput.Split(' ', 2);
if (parts.Length == 2)
{
currentLocation = parts[1].Trim();
botResponse = $"Standort wurde auf '{currentLocation}' gesetzt.";
}
else
{
botResponse = "Verwendung: !standort [stadtname]";
}
}
else if (userInput.ToLower() == "!zeit")
{
if (string.IsNullOrEmpty(currentLocation))
{
botResponse = "Bitte gib zuerst einen Standort mit !standort an.";
}
else
{
botResponse = $"Aktuelle Uhrzeit in {currentLocation}: {DateTime.Now.ToShortTimeString()}";
}
}
else if (userInput.ToLower() == "!wetter")
{
if (string.IsNullOrEmpty(currentLocation))
{
botResponse = "Bitte gib zuerst einen Standort mit !standort an.";
}
else
{
botResponse = await GetWeatherAsync(currentLocation);
}
}
else
{
botResponse = "Befehl nicht erkannt. Versuche es mit !hilfe.";
}
// Füge die Antwort des Bots zum Chat-Verlauf hinzu
ChatOutput.Text += $"Bot: {botResponse}\n";
// Eingabefeld leeren
InputTextBox.Clear();
}
// Methode für Enter-Taste, um eine Nachricht zu senden
private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
SendButton_Click(sender, e); // Gleich wie der Button
}
}
// Methode für Löschen-Button
private void ClearButton_Click(object sender, RoutedEventArgs e)
{
ChatOutput.Text = string.Empty; // Lösche den Chatverlauf
}
private void Color_theme_Checked(object sender, RoutedEventArgs e)
{
MessageBox.Show("Colortheme Charcoleblack aktiviert!");
//dunkles Theme
this.Background = new SolidColorBrush(Color.FromRgb(30, 30, 30));
SendButton.Background = new SolidColorBrush(Color.FromRgb(70, 70, 70));
SendButton.Foreground = new SolidColorBrush(Color.FromRgb(230, 230, 230));
ClearButton.Background = new SolidColorBrush(Color.FromRgb(70, 70, 70));
ClearButton.Foreground = new SolidColorBrush(Color.FromRgb(230, 230, 230));
Color_theme.Background = new SolidColorBrush(Color.FromRgb(70, 70, 70));
Color_theme.Foreground = new SolidColorBrush(Color.FromRgb(230, 230, 230));
SaveButton.Background = new SolidColorBrush(Color.FromRgb(70, 70, 70));
SaveButton.Foreground = new SolidColorBrush(Color.FromRgb(230, 230, 230));
ChatOutput.Background = new SolidColorBrush(Color.FromRgb(70, 70, 70));
ChatOutput.Foreground = new SolidColorBrush(Color.FromRgb(230, 230, 230));
InputTextBox.Background = new SolidColorBrush(Color.FromRgb(70, 70, 70));
InputTextBox.Foreground = new SolidColorBrush(Color.FromRgb(230, 230, 230));
}
private void Color_theme_Unchecked(object sender, RoutedEventArgs e)
{
MessageBox.Show("Colortheme Perlwhite aktiviert!");
//helles Theme
this.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
SendButton.Background = new SolidColorBrush(Color.FromRgb(221, 221, 221));
SendButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
ClearButton.Background = new SolidColorBrush(Color.FromRgb(221, 221, 221));
ClearButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
SaveButton.Background = new SolidColorBrush(Color.FromRgb(221, 221, 221));
SaveButton.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
Color_theme.Background = new SolidColorBrush(Color.FromRgb(221, 221, 221));
Color_theme.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
ChatOutput.Background = new SolidColorBrush(Color.FromRgb(240, 240, 240));
ChatOutput.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
InputTextBox.Background = new SolidColorBrush(Color.FromRgb(240, 240, 240));
InputTextBox.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
}
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
try
{
// Hole das Verzeichnis, in dem die .exe liegt
string projectDirectory = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName;
// Erstelle Dateinamen mit Zeitstempel, z.B. Chat_2025-05-06_1532.txt
string fileName = $"Chat_{DateTime.Now:yyyy-MM-dd_HHmm}.txt";
// Kompletter Pfad zur Datei
string fullPath = System.IO.Path.Combine(projectDirectory, fileName);
// Schreibe den Chatverlauf in die Datei
System.IO.File.WriteAllText(fullPath, ChatOutput.Text);
MessageBox.Show($"Chatverlauf gespeichert als:\n{fileName}", "Gespeichert", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
MessageBox.Show("Fehler beim Speichern:\n" + ex.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//mehtohde für die wetter Api
private async Task<string> GetWeatherAsync(string city)
{
string apiKey = "";
string url = $"https://api.openweathermap.org/data/2.5/weather?q={Uri.EscapeDataString(city)}&units=metric&lang=de&appid={apiKey}";
using HttpClient client = new HttpClient();
try
{
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string json = await response.Content.ReadAsStringAsync();
using JsonDocument doc = JsonDocument.Parse(json);
JsonElement root = doc.RootElement;
double temp = root.GetProperty("main").GetProperty("temp").GetDouble();
string description = root.GetProperty("weather")[0].GetProperty("description").GetString();
return $"Aktuelles Wetter in {city}: {temp}°C, {description}";
}
catch (Exception ex)
{
return $"Fehler beim Abrufen der Wetterdaten: {ex.Message}";
}
}
}
}

View File

@ -1,186 +0,0 @@
## MainWindow.xaml.cs Erklärung Zeile für Zeile
using-Anweisungen:
Diese laden verschiedene Bibliotheken, die für die Funktionen des Programms benötigt werden z.B. für GUI (WPF), Netzwerk, JSON-Verarbeitung, Textverarbeitung, usw.
```csharp
System.Text Für z.B. StringBuilder oder Kodierungen.
System.Windows.* Alles was WPF betrifft: Fenster, Controls, Styles etc.
System.Net.Http Für HTTP-Anfragen, hier verwendet für Wetter-API.
System.Text.Json Zum Lesen/Verarbeiten von JSON-Daten.
System.Threading.Tasks Für async/await, also asynchrone Methoden.
System.IO Für Dateioperationen wie Speichern des Chatverlaufs.
```
```csharp
namespace Chatbot_WPF_Projekt
{
public partial class MainWindow : Window
```
- namespace: Projektname.
- MainWindow: Hauptfenster des Programms.
- : Window: Erbt von WPF-Fensterklasse.
```csharp
private string currentLocation = "";
public MainWindow()
{
InitializeComponent();
}
```
- currentLocation: Speicherort für die aktuelle Stadt.
- InitializeComponent(): Verbindet XAML und C#-Code.
```csharp
private async void SendButton_Click(object sender, RoutedEventArgs e)
```
- private → Die Methode gehört nur zu dieser Klasse, andere Klassen sehen sie nicht.
- async → Die Methode kann auf Dinge warten, wie z.B. eine Antwort vom Wetterdienst.
- void → Die Methode gibt nichts zurück.
- SendButton_Click → So heißt die Methode, typisch für Button-Klicks.
- (object sender, RoutedEventArgs e) → Das sind Infos über das Klick-Ereignis. Wird von WPF automatisch mitgegeben.
```csharp
string userInput = InputTextBox.Text.Trim();
```
- Holt Nutzereingabe, entfernt Leerzeichen.
```csharp
if (string.IsNullOrEmpty(userInput)) ...
```
- Wenn Eingabe leer → Hinweis.
```csharp
ChatOutput.Text += $"Du: {userInput}\n";
```
- Gibt Nutzereingabe im Chatverlauf aus.
```csharp
string botResponse = "";
```
- Legt Bot-Antwortvariable an.
```csharp
botResponse = "Liste aller Befehle: !hilfe, !joke, !standort <stadt>, !zeit, !wetter";
```
- Listet alle befehle auf bei schreiben des !hilfe commands
```csharp
string[] witze = new string[10]; ...
Random zufall = new Random(); ...
```
- Zufälliger Witz aus Liste.
```csharp
string[] parts = userInput.Split(' ', 2);
currentLocation = parts[1];
```
- Stadt speichern.
```csharp
botResponse = $"Aktuelle Uhrzeit in {currentLocation}: {DateTime.Now.ToShortTimeString()}";
```
- Gibt lokale Uhrzeit aus
```csharp
botResponse = await GetWeatherAsync(currentLocation);
```
- Ruft Wetterdaten über API ab.
```csharp
botResponse = "Befehl nicht erkannt.";
```
- befehl falsch oder garnicht geschrieben
```csharp
private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
SendButton_Click(sender, e);
}
```
- Drücken von Enter löst SendButton aus.
```csharp
private void ClearButton_Click(object sender, RoutedEventArgs e)
{
ChatOutput.Text = string.Empty;
}
```
- löscht den verlauf wenn man auf den clearbutton drückt
```csharp
private void Color_theme_Checked ...
private void Color_theme_Unchecked ...
```
- Checked: Dunkler Hintergrund, helle Schrift.
- Unchecked: Heller Hintergrund, dunkle Schrift.
```csharp
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
string fileName = $"Chat_{DateTime.Now:yyyy-MM-dd_HHmm}.txt";
...
}
```
- Speichert Chat als .txt mit Datum/Uhrzeit im Namen.
```csharp
private async Task<string> GetWeatherAsync(string city)
string url = $"https://api.openweathermap.org/data/2.5/weather?...";
```
- URL zusammenbauen:
- HTTP-Anfrage senden mit HttpClient
```csharp
double temp = root.GetProperty("main").GetProperty("temp").GetDouble();
string description = root.GetProperty("weather")[0].GetProperty("description").GetString();
```
- JSON-Daten parsen:
```csharp
return $"Aktuelles Wetter in {city}: {temp}°C, {description}";
```
- atntwort erzeugen
```csharp
catch (Exception ex)
{
return "Fehler beim Abrufen der Wetterdaten.";
}
```
- fehler behandlung

View File

@ -1,21 +0,0 @@
MUSTHAVE:
1. Textfeld zum Reinschreiben
2. Textfeld zum ausgeben von Information
3. Senden-Button für Nachrichten
4. Fehlerbehandlung bei leeren Nachrichten
5. Erkennbare Unterscheidung zwischen Benutzer- und Bot-Nachrichten
6. Möglichkeit den Chat zu löschen/zurückzusetzen
7. Basis-Kommandos (wie "Hilfe", "Ende", "Neustart")
SHOUDHAVE:
1. Chatverlauf
2. Tastatur-Shortcuts (Enter zum Senden)
3. Speichern des Chatverlaufs in eine Datei
5. Sound-Effekte für neue Nachrichten
NICETOHAVE:
1. KI funktion
2. Wetter und Uhrzeit befehle
3. Standort änderung durch verändern der Variable
4. Taschenrechner funktion
5. Verschiedene Themes/Farbschemata

View File

@ -1,48 +0,0 @@
## 1.Tag
- Daniel war krank
- Brainstorming Daniel hatte idee zu einem Chatbot
## 2.Tag
- Daniel war krank
- (Daniel) Repo wurde angelegt
- (Daniel) Grundstrucktur (Das aussehn war fertig ein und ausgabe auch)
- (bei beiden) versuch zu pushen (ging nicht! erst mal so belassen)
- (Nik) befehl aufgabe bekommen
- datein wurden über Discord ausgetauscht
## 3.Tag
- einziger tag wo beide da wahren
- (Nik) befehl noch nicht fertig
- (Daniel)Die ersten befehle wie !hilfe und !joke waren drinne
- (Daniel) Man konnte cloretheme auf darkmode ändern
## 4.Tag
- garnichts zu wenig zeit
## 5.Tag
- Nik ist krank
- (Daniel)wollte chatgpt integrieren hatt fast funktioniert es kam aber nie etwas zurück (gesagt es ist noch zu schwer)
- (Nik)probleme mit den befehlen wegen dem standort (wurde gelöst indem man den abgefragt hatt und in eine variable eingesetzt hatt)
## 6.Tag
- Nik ist krank
- (Daniel)chat verlauf save button hinzugefügt
- (Nik)Wetter und Uhrzeit befehl wurde hinzugefügt erst ohne dann mit API (standort wurde gelöst indem man den abgefragt hatt und in eine variable eingesetzt hatt)
- presentierfertiges projekt über den browser hochgeladen, hatt nicht gut funktioniert datein wahren abgeschnitten und nicht komplett war noch ohne .gitignor
- (Daniel)Protokolierung vom projekt (hatte noch nicht angefangen durch fehlende information der wichtigkeit)
- murgen von hand war etwas schwerer weil code übersehen wurde
## 7.Tag
- Nik ist krank
- (Daniel) Entlich halb richtig pushen in Master über vs2022 mit hilfe von Raphael
## Probleme:
- Krankheitsfälle und die dadurch entstehnde fehl komunikation aber auch fehl information
- lösung: durch chat aushebel bar
- noch zu komplexe oder undurchsichtige verknüpfung zu chatgpt
- -> mann hatt etwas geshickt und es wurde nichts zurück geschickt
- lösung: erstmal keine
- server probleme beim pushen von datein
- lösung: erst versucht von beiden seiten zu pushen hatt nicht funktioniert dann uploud über den browser als ich raphael gefragt habe und es dann über vs 2022 konnte es nur auf einen anderen branch pushen naja funktioniert irgendwie
- nicht funktioniern der standort abfrage - mehr dazu können sie Nik fragen
- lösung: kurz mit team mitglied um rahd fragen und lösung finden. Daniel kam mit dem vorschlag den standort extren abzufargen
- arbeitsweise: abgesprochen wer was macht Nik macht befehle Daniel den Rahmen/ grundfunktionalietät (natürlich inspiration von GPT und einfache arbeiten zumbeispiel witze generieren und so aber auch die save funktion erklärt bekommen und ausbesserungen am code)

View File

@ -1,43 +0,0 @@
# ChatBot-Projekt
Wir als kleine Gruppe von 2 Personen (Nik & Daniel) entwickeln einen kleinen Chatbot wo man befehle einsenden kann wir hoffen es KI Features einzubinden, das gehört aber in den nice to have Bereich.
## Entwicklung
- Entwickelt in C#
- Windows Desktop-Anwendung
- WPF für die Benutzeroberfläche
## Projektfortschritt
### Must-Have Features
[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
- [x] Textfeld für Benutzereingaben
- [x] Ausgabefeld für Bot-Antworten
- [x] Senden-Button für Nachrichten
- [x] Fehlerbehandlung bei leeren Nachrichten
- [x] Unterscheidung zwischen Benutzer- und Bot-Nachrichten
- [x] Chat zurücksetzen/löschen Funktion
- [x] Basis-Kommandos
### Should-Have Features
[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░] 75%
- [x] Chatverlauf-Anzeige
- [x] Tastatur-Shortcuts(Enter taste zum bestätigen)
- [x] Speicherfunktion für Chatverläufe
- [ ] Sound-Effekte
### Nice-to-Have Features
[▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░] 60%
- [ ] Taschenrechner-Funktion
- [ ] KI-Funktionalität
- [x] Wetter- und Uhrzeitabfragen
- [x] Variable Standortänderung
- [x] Verschiedene Themes/Farbschemata
### Gesamtfortschritt
[▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░] 81,25%
## Status
🚧 In Entwicklung - v0.8.1
---
*Dieses Projekt ist Teil einer Ausbildung*