mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
如遇人设崩塌重置聊天系统
This commit is contained in:
parent
e43017a3e8
commit
af42026dd8
@ -1,4 +1,5 @@
|
||||
using LinePutScript;
|
||||
using Panuon.WPF.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
@ -101,6 +102,14 @@ namespace VPet_Simulator.Windows
|
||||
set["aiopen"][(gbol)"startup"] = false;
|
||||
rettype = false;
|
||||
}
|
||||
else if (responseString.ToLower().Contains("是ChatGPT"))
|
||||
{
|
||||
Dispatcher.Invoke(() => btn_startup.Visibility = Visibility.Visible);
|
||||
set["aiopen"][(gbol)"startup"] = false;
|
||||
rettype = false;
|
||||
responseString += "\n检测到模型错误,已重置桌宠聊天系统";
|
||||
ChatGPT_Reset();
|
||||
}
|
||||
m.Say(responseString);
|
||||
}
|
||||
catch (Exception exp)
|
||||
@ -111,6 +120,46 @@ namespace VPet_Simulator.Windows
|
||||
Dispatcher.Invoke(() => this.IsEnabled = true);
|
||||
return rettype;
|
||||
}
|
||||
/// <summary>
|
||||
/// 重置ChatGPT
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ChatGPT_Reset()
|
||||
{
|
||||
try
|
||||
{
|
||||
//请不要使用该API作为其他用途,如有其他需要请联系我(QQ群:430081239)
|
||||
//该API可能会因为其他原因更改
|
||||
string _url = "https://aiopen.exlb.net:5810/VPet/Delete";
|
||||
//参数
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"steamid={Steamworks.SteamClient.SteamId.Value}");
|
||||
var request = (HttpWebRequest)WebRequest.Create(_url);
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/x-www-form-urlencoded";//ContentType
|
||||
byte[] byteData = Encoding.UTF8.GetBytes(sb.ToString());
|
||||
int length = byteData.Length;
|
||||
request.ContentLength = length;
|
||||
using (Stream writer = request.GetRequestStream())
|
||||
{
|
||||
writer.Write(byteData, 0, length);
|
||||
writer.Close();
|
||||
writer.Dispose();
|
||||
}
|
||||
string responseString;
|
||||
using (var response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
responseString = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
|
||||
response.Dispose();
|
||||
}
|
||||
return responseString;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据宠物剩余寿命显示相关UI
|
||||
/// </summary>
|
||||
|
@ -222,11 +222,11 @@
|
||||
<RadioButton Style="{DynamicResource StandardRadioButtonStyle}"
|
||||
Content="使用从ChatGPT 申请的的API" ToolTip="需要去OpenAI官网申请"
|
||||
GroupName="cgpttype" Grid.Column="1" IsEnabled="False" />
|
||||
<RadioButton Style="{DynamicResource StandardRadioButtonStyle}"
|
||||
<RadioButton x:Name="RBCGPTUseLB" Style="{DynamicResource StandardRadioButtonStyle}"
|
||||
Content="使用桌宠开发者 提供的免费API" ToolTip="需遵循相关协议法律法规并有聊天字数限制"
|
||||
GroupName="cgpttype" IsChecked="True" />
|
||||
</Grid>
|
||||
<Button pu:ButtonHelper.CornerRadius="4" Content="初始化桌宠聊天程序" Margin="4" Grid.Column="2"
|
||||
<Button x:Name="BtnCGPTReSet" pu:ButtonHelper.CornerRadius="4" Content="初始化桌宠聊天程序" Margin="4" Grid.Column="2"
|
||||
Background="{DynamicResource SecondaryLight}" Padding="1" Grid.Row="1" Click="ChatGPT_Reset_Click" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
@ -119,6 +119,12 @@ namespace VPet_Simulator.Windows
|
||||
ShowMod((string)((ListBoxItem)ListMod.SelectedItem).Content);
|
||||
|
||||
AllowChange = true;
|
||||
|
||||
if (!mw.IsSteamUser)
|
||||
{
|
||||
RBCGPTUseLB.IsEnabled = false;
|
||||
BtnCGPTReSet.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
public void ShowModList()
|
||||
{
|
||||
@ -655,48 +661,19 @@ namespace VPet_Simulator.Windows
|
||||
}
|
||||
mw.LoadDIY();
|
||||
}
|
||||
|
||||
|
||||
private void ChatGPT_Reset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
string responseString = mw.TalkBox.ChatGPT_Reset();
|
||||
if (responseString == "SUCCESS")
|
||||
{
|
||||
//请不要使用该API作为其他用途,如有其他需要请联系我(QQ群:430081239)
|
||||
//该API可能会因为其他原因更改
|
||||
string _url = "https://aiopen.exlb.net:5810/VPet/Delete";
|
||||
//参数
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"steamid={Steamworks.SteamClient.SteamId.Value}");
|
||||
var request = (HttpWebRequest)WebRequest.Create(_url);
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/x-www-form-urlencoded";//ContentType
|
||||
byte[] byteData = Encoding.UTF8.GetBytes(sb.ToString());
|
||||
int length = byteData.Length;
|
||||
request.ContentLength = length;
|
||||
using (Stream writer = request.GetRequestStream())
|
||||
{
|
||||
writer.Write(byteData, 0, length);
|
||||
writer.Close();
|
||||
writer.Dispose();
|
||||
}
|
||||
string responseString;
|
||||
using (var response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
responseString = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
|
||||
response.Dispose();
|
||||
}
|
||||
if (responseString == "SUCCESS")
|
||||
{
|
||||
mw.TalkBox.btn_startup.Visibility = Visibility.Visible;
|
||||
MessageBoxX.Show("桌宠重置成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBoxX.Show(responseString, "桌宠重置失败");
|
||||
}
|
||||
mw.TalkBox.btn_startup.Visibility = Visibility.Visible;
|
||||
MessageBoxX.Show("桌宠重置成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
else
|
||||
{
|
||||
MessageBoxX.Show(ex.ToString(), "桌宠重置失败");
|
||||
MessageBoxX.Show(responseString, "桌宠重置失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user