Добавил окна добавления интеграций с ОБС

This commit is contained in:
PC1\PTyTb
2025-08-06 09:21:43 +03:00
parent 7e77775cd4
commit d68064187d
16 changed files with 1518 additions and 1012 deletions
+201 -210
View File
@@ -7,10 +7,10 @@ uses
System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl,
FMX.Controls.Presentation, FMX.StdCtrls, System.ImageList, FMX.ImgList,
FMX.Styles,
fSettings, fAI, fNotify, fAutoActions, fChatOBS, FMX.ListBox, fLog, uRecords,
FMX.Styles, ShellAPI, StrUtils,
fSettings, fAI, fNotify, fAutoActions, FMX.ListBox, fLog, uRecords,
System.IOUtils, fCommands, uDataBase, FMX.Edit, FMX.Colors, FMX.SpinBox,
windows;
windows, System.Skia, FMX.Skia, uCreateChat, uCreateNotify, fOBS;
type
TForm1 = class(TForm)
@@ -42,20 +42,23 @@ type
TabItem9: TTabItem;
frNotify1: TfrNotify;
Label1: TLabel;
Label4: TLabel;
Label13: TLabel;
Label14: TLabel;
frAutoActions1: TfrAutoActions;
frChatOBS1: TfrChatOBS;
frOBS1: TfrOBS;
frLog1: TfrLog;
cbTheme: TComboBox;
Label15: TLabel;
frCommands1: TfrCommands;
procedure Label14DblClick(Sender: TObject);
procedure Label13DblClick(Sender: TObject);
procedure Label4DblClick(Sender: TObject);
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
btnCreateChat: TButton;
procedure cbThemeChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure frChatOBS1btnCreateChatClick(Sender: TObject);
procedure frOBS1btnCreateOBSNotifyClick(Sender: TObject);
private
{ Private declarations }
procedure ReadDB();
@@ -138,20 +141,14 @@ begin
end;
procedure TForm1.Label13DblClick(Sender: TObject);
procedure TForm1.frChatOBS1btnCreateChatClick(Sender: TObject);
begin
// https://www.twitch.tv/kuznecogr
fCreateChat.Show;
end;
procedure TForm1.Label14DblClick(Sender: TObject);
procedure TForm1.frOBS1btnCreateOBSNotifyClick(Sender: TObject);
begin
// https://www.flaticon.com/ru/authors/karacis
end;
procedure TForm1.Label4DblClick(Sender: TObject);
begin
// https://www.twitch.tv/incadence
fCreateNotify.Show;
end;
procedure TForm1.ReadDB;
@@ -210,34 +207,49 @@ var
end;
end;
begin
for I := 0 to fSettings.ComponentCount - 1 do
// Çàãðóçêà êîìïîíåíòîâ íàñòðîåê (TEdit, TCheckBox)
procedure LoadSettingsComponents;
var
I: Integer;
c: TComponent;
begin
c := fSettings.components[I];
if c is TEdit then
for I := 0 to fSettings.ComponentCount - 1 do
begin
TEdit(c).text := db.ReadSetting(TEdit(c).Name);
end;
if c is TCheckBox then
begin
TCheckBox(c).IsChecked := (db.ReadSetting(TCheckBox(c).Name) = 'True');
c := fSettings.Components[I];
if c is TEdit then
TEdit(c).text := db.ReadSetting(TEdit(c).Name)
else if c is TCheckBox then
TCheckBox(c).IsChecked := (db.ReadSetting(TCheckBox(c).Name) = 'True');
end;
db.FChannel := fSettings.edtChannel.text;
end;
db.FChannel := fSettings.edtChannel.text;
db.LoadGridFromTable('sgRandomInt', frCommands1.sgRandomInt);
db.LoadGridFromTable('sgCommands', frCommands1.sgCommands);
db.LoadGridFromTable('sgSAFiles', frCommands1.sgSAFiles);
db.LoadGridFromTable('sgTFiles', frCommands1.sgTFiles);
db.LoadGridFromTable('sgAIGen', frCommands1.sgAIGen);
db.getGroupName(frCommands1.lbRandomGroup.Items);
if FileExists(myConst.cfg1) then
// Çàãðóçêà äàííûõ â ãðèäû êîìàíä
procedure LoadGridsData;
begin
db.LoadGridFromTable('sgRandomInt', frCommands1.sgRandomInt);
db.LoadGridFromTable('sgCommands', frCommands1.sgCommands);
db.LoadGridFromTable('sgSAFiles', frCommands1.sgSAFiles);
db.LoadGridFromTable('sgTFiles', frCommands1.sgTFiles);
db.LoadGridFromTable('sgAIGen', frCommands1.sgAIGen);
end;
// Çàãðóçêà ñïèñêà ãðóïï
procedure LoadGroupNames;
begin
db.getGroupName(frCommands1.lbRandomGroup.Items);
end;
// Çàãðóçêà çàøèôðîâàííîãî êîíôèãà
procedure LoadEncryptedConfig;
var
sl: TStringList;
I: Integer;
begin
if not FileExists(myConst.cfg1) then
Exit;
sl := TStringList.Create;
try
sl.Assign(XorDecryptToStrings(myConst.cfg1, 'fgvasrgEFAXFAFAS'));
for I := 0 to sl.Count - 1 do
@@ -251,205 +263,184 @@ begin
var
Value := Trim(Copy(sl[I], eqPos + 1, MaxInt));
// Ðàñïðåäåëÿåì çíà÷åíèÿ ïî ïåðåìåííûì
if Key = 'k1' then
begin
appconst.TTV_ClientID := Value;
end
appconst.TTV_ClientID := Value
else if Key = 'k2' then
begin
appconst.AI_GigaChat_AC := Value;
end
appconst.AI_GigaChat_AC := Value
else if Key = 'k3' then
begin
appconst.AI_GigaChat_ClientID := Value;
end
appconst.AI_GigaChat_ClientID := Value
else if Key = 'k4' then
begin
appconst.AI_ChatGPT_Token := Value;
end
appconst.AI_ChatGPT_Token := Value
else if Key = 'k5' then
begin
appconst.AI_DeepSeec_Token := Value;
end
appconst.AI_DeepSeec_Token := Value
else if Key = 'k6' then
begin
appconst.DA_ClientID := Value;
end
appconst.DA_ClientID := Value
else if Key = 'k7' then
begin
appconst.DA_Sicret := Value;
end
appconst.DA_Sicret := Value
else if Key = 'k8' then
begin
appconst.DA_URL := Value;
end
end;
end;
if appconst.TTV_ClientID <> '' then
begin
fSettings.btnGetClientID.Visible := True;
end;
if ((appconst.AI_GigaChat_AC <> '') and (appconst.AI_GigaChat_ClientID <>
'')) or (appconst.AI_ChatGPT_Token <> '') or
(appconst.AI_DeepSeec_Token <> '') then
begin
frAI1.btnGetAIDef.Visible := True;
end;
if ((appconst.DA_ClientID <> '') and (appconst.DA_Sicret <> '') and
(appconst.DA_URL <> '')) then
begin
fSettings.btnGetDADef.Visible := True;
end;
fSettings.btnGetClientID.Visible := (appconst.TTV_ClientID <> '');
frAI1.btnGetAIDef.Visible := ((appconst.AI_GigaChat_AC <> '') and
(appconst.AI_GigaChat_ClientID <> '')) or
(appconst.AI_ChatGPT_Token <> '') or (appconst.AI_DeepSeec_Token <> '');
fSettings.btnGetDADef.Visible := (appconst.DA_ClientID <> '') and
(appconst.DA_Sicret <> '') and (appconst.DA_URL <> '');
finally
sl.Free;
end;
end;
for I := 0 to frChatOBS1.ComponentCount - 1 do
// Çàãðóçêà íàñòðîåê óâåäîìëåíèé
procedure LoadNotifySettings;
var
I: Integer;
c: TComponent;
begin
c := frChatOBS1.components[I];
if c is TComboBox then
for I := 0 to frNotify1.ComponentCount - 1 do
begin
TComboBox(c).ItemIndex :=
strtoint(db.ReadSetting(TComboBox(c).Name, '0'));
end;
if c is TColorComboBox then
begin
TColorComboBox(c).ItemIndex :=
strtoint(db.ReadSetting(TComboBox(c).Name, '147'));
end;
if c is TSpinBox then
begin
if TSpinBox(c).Name = 'sbWebServerPort' then
TSpinBox(c).text := db.ReadSetting(TSpinBox(c).Name, '8080');
TSpinBox(c).text := db.ReadSetting(TSpinBox(c).Name, '1');
end;
if c is TCheckBox then
begin
TCheckBox(c).IsChecked := db.ReadSetting(TCheckBox(c).Name, '0') = '1';
c := frNotify1.Components[I];
if c is TEdit then
TEdit(c).text := db.ReadSetting(TEdit(c).Name)
else if c is TCheckBox then
TCheckBox(c).IsChecked := (db.ReadSetting(TCheckBox(c).Name) = 'True')
else if c is TSwitch then
TSwitch(c).IsChecked := (db.ReadSetting(TSwitch(c).Name) = 'True')
else if c is TTrackBar then
TTrackBar(c).Value :=
strtoint(db.ReadSetting(TTrackBar(c).Name, '100'));
end;
end;
ColorStr := db.ReadSetting('cpStyleBlockColor', 'FF000000');
if TryStrToUInt('$' + ColorStr, Cardinal(SavedColor)) then
frChatOBS1.cpStyleBlockColor.Color := SavedColor
else
frChatOBS1.cpStyleBlockColor.Color := TAlphaColorRec.Black;
if not DirectoryExists(myConst.fontsPath) then
CreateDirectory(PChar(myConst.fontsPath), 0);
var
n := 1;
var
cDir := myConst.fontsPath; // Èñêàòü â ïàïêå ñ ïðîãðàììîé
var
FileName := '*.*'; // Èùåì âñå ôàéëû
ChDir(cDir); // âîéòè â êàòàëîã
var
SearchRec: TSearchRec;
if FindFirst(FileName, faArchive, SearchRec) = 0 then
repeat
if (SearchRec.Attr and faAnyFile) = SearchRec.Attr then
begin
frChatOBS1.cbFontStyleDefault.Items.Add(SearchRec.Name);
Inc(n);
end;
until FindNext(SearchRec) <> 0;
ChDir('..');
for I := 0 to frNotify1.ComponentCount - 1 do
begin
c := frNotify1.components[I];
if c is TEdit then
begin
TEdit(c).text := db.ReadSetting(TEdit(c).Name);
end;
if c is TCheckBox then
begin
TCheckBox(c).IsChecked := (db.ReadSetting(TCheckBox(c).Name) = 'True');
end;
if c is TSwitch then
begin
TSwitch(c).IsChecked := (db.ReadSetting(TSwitch(c).Name) = 'True');
end;
if c is TTrackBar then
begin
TTrackBar(c).Value := strtoint(db.ReadSetting(TTrackBar(c).Name, '100'));
end;
end;
// Çàãðóçêà íàñòðîåê ÈÈ
procedure LoadAISettings;
var
I: Integer;
c: TComponent;
ii: Integer;
for I := 0 to frAI1.ComponentCount - 1 do
// Íàñòðîéêè GigaChat
procedure SetupGigaChatSettings;
begin
c := frAI1.components[I];
if c is TEdit then
begin
TEdit(c).text := db.ReadSetting(TEdit(c).Name);
end;
if c is TCheckBox then
begin
TCheckBox(c).IsChecked := db.ReadSetting(TCheckBox(c).Name) = '1';
end;
end;
ii := strtoint(db.ReadSetting('aiIndex', '0'));
case ii of
0:
begin
frAI1.rbGC.IsChecked := True;
frAI1.Label45.text := 'ClientID';
frAI1.Label47.text := 'Autorization Code';
frAI1.Label1.Visible := false;
frAI1.edtAIP2.Visible := True;
frAI1.edtAIP2.Password := True;
frAI1.edtAIP3.Visible := false;
frAI1.cbOllama.IsChecked := false;
frAI1.cbOllama.Visible := false;
end;
1:
begin
frAI1.rbDS.IsChecked := True;
frAI1.Label45.text := 'API Token';
frAI1.Label47.text := '';
frAI1.Label1.Visible := false;
frAI1.edtAIP2.Visible := false;
frAI1.edtAIP2.Password := false;
frAI1.edtAIP3.Visible := false;
frAI1.cbOllama.IsChecked := false;
frAI1.cbOllama.Visible := false;
end;
2:
begin
frAI1.rbCG.IsChecked := True;
frAI1.Label45.text := 'API Token';
frAI1.Label47.text := '';
frAI1.Label1.Visible := false;
frAI1.edtAIP2.Visible := false;
frAI1.edtAIP2.Password := false;
frAI1.edtAIP3.Visible := false;
frAI1.cbOllama.IsChecked := false;
frAI1.cbOllama.Visible := false;
end;
3:
begin
frAI1.RBCustom.IsChecked := True;
frAI1.Label45.text := 'API Token';
frAI1.Label47.text := 'URL';
frAI1.Label1.Visible := True;
frAI1.edtAIP2.Visible := True;
frAI1.edtAIP2.Password := false;
frAI1.edtAIP3.Visible := True;
frAI1.cbOllama.IsChecked := db.ReadSetting(frAI1.cbOllama.Name) = '1';
frAI1.cbOllama.Visible := True;
end;
frAI1.rbGC.IsChecked := True;
frAI1.Label45.text := 'ClientID';
frAI1.Label47.text := 'Autorization Code';
frAI1.Label1.Visible := False;
frAI1.edtAIP2.Visible := True;
frAI1.edtAIP2.Password := True;
frAI1.edtAIP3.Visible := False;
frAI1.cbOllama.Visible := False;
end;
db.LoadGridFromTable('sgTimers', frAutoActions1.sgTimers);
db.LoadGridFromTable('sgCounter', frAutoActions1.sgCounter);
db.LoadGridFromTable('sgBanWords', frAutoActions1.sgBanWords);
// Íàñòðîéêè DeepSeek
procedure SetupDeepSeekSettings;
begin
frAI1.rbDS.IsChecked := True;
frAI1.Label45.text := 'API Token';
frAI1.Label47.text := '';
frAI1.Label1.Visible := False;
frAI1.edtAIP2.Visible := False;
frAI1.edtAIP3.Visible := False;
frAI1.cbOllama.Visible := False;
end;
// Íàñòðîéêè ChatGPT
procedure SetupChatGPTSettings;
begin
frAI1.rbCG.IsChecked := True;
frAI1.Label45.text := 'API Token';
frAI1.Label47.text := '';
frAI1.Label1.Visible := False;
frAI1.edtAIP2.Visible := False;
frAI1.edtAIP3.Visible := False;
frAI1.cbOllama.Visible := False;
end;
// Íàñòðîéêè êàñòîìíîãî ÈÈ
procedure SetupCustomAISettings;
begin
frAI1.RBCustom.IsChecked := True;
frAI1.Label45.text := 'API Token';
frAI1.Label47.text := 'URL';
frAI1.Label1.Visible := True;
frAI1.edtAIP2.Visible := True;
frAI1.edtAIP2.Password := False;
frAI1.edtAIP3.Visible := True;
frAI1.cbOllama.Visible := True;
frAI1.cbOllama.IsChecked := db.ReadSetting(frAI1.cbOllama.Name) = '1';
end;
begin
for I := 0 to frAI1.ComponentCount - 1 do
begin
c := frAI1.Components[I];
if c is TEdit then
TEdit(c).text := db.ReadSetting(TEdit(c).Name)
else if c is TCheckBox then
TCheckBox(c).IsChecked := db.ReadSetting(TCheckBox(c).Name) = '1';
end;
ii := strtoint(db.ReadSetting('aiIndex', '0'));
case ii of
0:
SetupGigaChatSettings;
1:
SetupDeepSeekSettings;
2:
SetupChatGPTSettings;
3:
SetupCustomAISettings;
end;
end;
// Çàãðóçêà ãðèäîâ àâòîìàòè÷åñêèõ äåéñòâèé
procedure LoadAutoActionsGrids;
begin
db.LoadGridFromTable('sgTimers', frAutoActions1.sgTimers);
db.LoadGridFromTable('sgCounter', frAutoActions1.sgCounter);
db.LoadGridFromTable('sgBanWords', frAutoActions1.sgBanWords);
end;
begin
LoadSettingsComponents;
LoadGridsData;
LoadGroupNames;
LoadEncryptedConfig;
LoadNotifySettings;
LoadAISettings;
LoadAutoActionsGrids;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
ShellExecute(0, 'open', pwidechar('https://www.twitch.tv/incadence'),
nil, nil, 1);
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
// https://www.twitch.tv/kuznecogr
ShellExecute(0, 'open', pwidechar('https://www.twitch.tv/kuznecogr'),
nil, nil, 1);
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
// https://www.flaticon.com/ru/authors/karacis
ShellExecute(0, 'open',
pwidechar('https://www.flaticon.com/ru/authors/karacis'), nil, nil, 1);
end;
end.