исправил оповещения, теперь работают четко
This commit is contained in:
@@ -93,7 +93,6 @@ function TTTW_API.createCustomReward(title: string; cost: string;
|
||||
var
|
||||
RequestData: TStringStream;
|
||||
s, s1, json: string;
|
||||
i: integer;
|
||||
cr: TCustomRevards;
|
||||
JSONData: TJSONObject;
|
||||
JSONArray: TJSONArray;
|
||||
@@ -1041,9 +1040,9 @@ var
|
||||
EmoteObj: TJSONObject;
|
||||
ImagesObj: TJSONObject;
|
||||
Emote: TEmotes;
|
||||
I, J: Integer;
|
||||
I: Integer;
|
||||
chosenFormat, chosenTheme, chosenScale: string;
|
||||
foundAnimated, foundNonStatic, foundDark: Boolean;
|
||||
foundAnimated, foundDark: Boolean;
|
||||
scaleVal, maxScale: Double;
|
||||
s: string;
|
||||
begin
|
||||
@@ -1076,7 +1075,6 @@ begin
|
||||
|
||||
// Âûáîð ôîðìàòà (format)
|
||||
foundAnimated := False;
|
||||
foundNonStatic := False;
|
||||
chosenFormat := 'static'; // çíà÷åíèå ïî óìîë÷àíèþ
|
||||
|
||||
// Ïðîâåðêà íàëè÷èÿ "animated"
|
||||
@@ -1094,7 +1092,6 @@ begin
|
||||
if s <> 'static' then
|
||||
begin
|
||||
chosenFormat := s;
|
||||
foundNonStatic := True;
|
||||
Break;
|
||||
end;
|
||||
|
||||
|
||||
+2
-1
@@ -47,7 +47,8 @@ uses
|
||||
uWebServerKandinsky in 'utils\uWebServerKandinsky.pas',
|
||||
uWebServerEvents in 'utils\uWebServerEvents.pas',
|
||||
fEvents in 'frames\fEvents.pas' {frEvents: TFrame},
|
||||
uKeyEvent in 'utils\uKeyEvent.pas';
|
||||
uKeyEvent in 'utils\uKeyEvent.pas',
|
||||
fRevards in 'frames\fRevards.pas' {frRevards: TFrame};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
||||
+36
-2
@@ -306,9 +306,12 @@
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_MajorVer>10</VerInfo_MajorVer>
|
||||
<VerInfo_MinorVer>1</VerInfo_MinorVer>
|
||||
<VerInfo_Release>1</VerInfo_Release>
|
||||
<VerInfo_Release>2</VerInfo_Release>
|
||||
<VerInfo_Locale>1049</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=PTyTb;FileDescription=$(MSBuildProjectName);FileVersion=10.1.1.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=ru.ptytb.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
<VerInfo_Keys>CompanyName=PTyTb;FileDescription=$(MSBuildProjectName);FileVersion=10.1.2.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=ru.ptytb.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
<Icon_MainIcon>TTW_Bot_app_Icon2.ico</Icon_MainIcon>
|
||||
<UWP_DelphiLogo44>..\ttw_fmx_v9\fawico_44_2.png</UWP_DelphiLogo44>
|
||||
<UWP_DelphiLogo150>..\ttw_fmx_v9\fawico_150_2.png</UWP_DelphiLogo150>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
|
||||
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
|
||||
@@ -438,6 +441,11 @@
|
||||
<DesignClass>TFrame</DesignClass>
|
||||
</DCCReference>
|
||||
<DCCReference Include="utils\uKeyEvent.pas"/>
|
||||
<DCCReference Include="frames\fRevards.pas">
|
||||
<Form>frRevards</Form>
|
||||
<FormType>fmx</FormType>
|
||||
<DesignClass>TFrame</DesignClass>
|
||||
</DCCReference>
|
||||
<None Include=".gitignore"/>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
@@ -487,6 +495,13 @@
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="..\ttw_fmx_v9\fawico_150_2.png" Configuration="Release" Class="UWP_DelphiLogo150">
|
||||
<Platform Name="Win32">
|
||||
<RemoteDir>Assets\</RemoteDir>
|
||||
<RemoteName>Logo150x150.png</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="..\ttw_fmx_v9\fawico_44_2.png" Configuration="Debug" Class="UWP_DelphiLogo44">
|
||||
<Platform Name="Win32">
|
||||
<RemoteDir>Assets\</RemoteDir>
|
||||
@@ -494,18 +509,37 @@
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="..\ttw_fmx_v9\fawico_44_2.png" Configuration="Release" Class="UWP_DelphiLogo44">
|
||||
<Platform Name="Win32">
|
||||
<RemoteDir>Assets\</RemoteDir>
|
||||
<RemoteName>Logo44x44.png</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName=".gitignore" Configuration="Debug" Class="ProjectFile">
|
||||
<Platform Name="Win32">
|
||||
<RemoteDir>.\</RemoteDir>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName=".gitignore" Configuration="Release" Class="ProjectFile">
|
||||
<Platform Name="Win32">
|
||||
<RemoteDir>.\</RemoteDir>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="Win32\Debug\TTW_Bot_app.exe" Configuration="Debug" Class="ProjectOutput">
|
||||
<Platform Name="Win32">
|
||||
<RemoteName>TTW_Bot_app.exe</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="Win32\Release\TTW_Bot_app.exe" Configuration="Release" Class="ProjectOutput">
|
||||
<Platform Name="Win32">
|
||||
<RemoteName>TTW_Bot_app.exe</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployClass Name="AdditionalDebugSymbols">
|
||||
<Platform Name="iOSSimulator">
|
||||
<Operation>1</Operation>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
@@ -0,0 +1,5 @@
|
||||
|
||||
QKPG@VrKK3q|#/<6##?2r?3t&)_< +6s
|
||||
q ,*<m.~|0256{|I*55w" KK8WZFD
|
||||
-!2->1-7)WDB2,/7p-t+$kmSN?
|
||||
wt (!8+uv5(
|
||||
@@ -146,7 +146,7 @@ object fCreateNotify: TfCreateNotify
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 135.000000000000000000
|
||||
Text = #1057#1086#1073#1099#1090#1080#1077
|
||||
TabOrder = 37
|
||||
TabOrder = 38
|
||||
end
|
||||
object cbEventsType: TComboBox
|
||||
Items.Strings = (
|
||||
@@ -154,13 +154,14 @@ object fCreateNotify: TfCreateNotify
|
||||
#1055#1086#1076#1087#1080#1089#1082#1072
|
||||
#1055#1086#1076#1072#1088#1086#1095#1085#1072#1103' '#1087#1086#1076#1087#1080#1089#1082#1072
|
||||
#1056#1077#1081#1076
|
||||
#1044#1086#1085#1072#1090)
|
||||
#1044#1086#1085#1072#1090
|
||||
#1057#1074#1086#1077)
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 160.000000000000000000
|
||||
Size.Width = 192.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 38
|
||||
TabOrder = 39
|
||||
OnChange = cbEventsTypeChange
|
||||
end
|
||||
object Label3: TLabel
|
||||
@@ -168,11 +169,11 @@ object fCreateNotify: TfCreateNotify
|
||||
Position.Y = 190.000000000000000000
|
||||
Text = #1059#1089#1083#1086#1074#1080#1077' '#1089#1091#1084#1084#1099
|
||||
Visible = False
|
||||
TabOrder = 39
|
||||
TabOrder = 40
|
||||
end
|
||||
object edtIF: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 40
|
||||
TabOrder = 41
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 215.000000000000000000
|
||||
Size.Width = 192.000000000000000000
|
||||
@@ -215,7 +216,7 @@ object fCreateNotify: TfCreateNotify
|
||||
object edtESTitle: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
Align = Top
|
||||
TabOrder = 37
|
||||
TabOrder = 38
|
||||
Text = '[NICK] '#1085#1072#1095#1072#1083' '#1086#1090#1089#1083#1077#1078#1080#1074#1072#1090#1100' '#1074#1072#1089
|
||||
Position.X = 10.000000000000000000
|
||||
Position.Y = 20.000000000000000000
|
||||
|
||||
+93
-25
@@ -4,7 +4,7 @@ interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes,
|
||||
System.Variants, fOBS,
|
||||
System.Variants, fOBS, System.RegularExpressions, Math,
|
||||
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, fFontSettings,
|
||||
fColorSettings, FMX.StdCtrls, FMX.Edit, FMX.Controls.Presentation,
|
||||
FMX.ListBox, FMX.EditBox, FMX.SpinBox, FMX.Colors, uRecords;
|
||||
@@ -44,6 +44,9 @@ type
|
||||
{ Private declarations }
|
||||
function GetColorFromColorPanel(aColor: TAlphaColor): string;
|
||||
function GetColorFromCCB(aColor: TAlphaColor): string;
|
||||
|
||||
function GetColorFromRGBA(const s: string): TAlphaColor;
|
||||
function GetColorFromHex(const s: string): TAlphaColor;
|
||||
public
|
||||
{ Public declarations }
|
||||
isEdit: boolean;
|
||||
@@ -60,6 +63,33 @@ uses uGeneral;
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
function TfCreateNotify.GetColorFromRGBA(const s: string): TAlphaColor;
|
||||
var
|
||||
Match: TMatch;
|
||||
r, g, b: Integer;
|
||||
a: Double;
|
||||
Rec: TAlphaColorRec;
|
||||
begin
|
||||
Match := TRegEx.Match(s, 'rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)');
|
||||
if Match.Success then
|
||||
begin
|
||||
r := StrToInt(Match.Groups[1].Value);
|
||||
g := StrToInt(Match.Groups[2].Value);
|
||||
b := StrToInt(Match.Groups[3].Value);
|
||||
a := StrToFloat(Match.Groups[4].Value, TFormatSettings.Invariant);
|
||||
|
||||
// Çàïîëíÿåì ñòðóêòóðó âðó÷íóþ
|
||||
Rec.R := Byte(r);
|
||||
Rec.G := Byte(g);
|
||||
Rec.B := Byte(b);
|
||||
Rec.A := Round(a * 255);
|
||||
|
||||
Result := Rec.Color;
|
||||
end
|
||||
else
|
||||
raise Exception.CreateFmt('Íåâåðíûé ôîðìàò rgba: %s', [s]);
|
||||
end;
|
||||
|
||||
function TfCreateNotify.GetColorFromColorPanel(aColor: TAlphaColor): string;
|
||||
var
|
||||
Color: TAlphaColor;
|
||||
@@ -80,6 +110,47 @@ begin
|
||||
result := Format('rgba(%d, %d, %d, %.2f)', [r, G, B, A], FS);
|
||||
end;
|
||||
|
||||
function TfCreateNotify.GetColorFromCCB(aColor: TAlphaColor): string;
|
||||
var
|
||||
Color: TAlphaColor;
|
||||
r, G, B: Byte;
|
||||
begin
|
||||
Color := aColor;
|
||||
r := TAlphaColorRec(Color).r;
|
||||
G := TAlphaColorRec(Color).G;
|
||||
B := TAlphaColorRec(Color).B;
|
||||
result := Format('#%.2X%.2X%.2X', [r, G, B]);
|
||||
end;
|
||||
|
||||
function TfCreateNotify.GetColorFromHex(const s: string): TAlphaColor;
|
||||
var
|
||||
Hex: string;
|
||||
r, g, b: Integer;
|
||||
Rec: TAlphaColorRec;
|
||||
begin
|
||||
// Óáèðàåì âîçìîæíûé ñèìâîë #
|
||||
Hex := s.Trim;
|
||||
if Hex.StartsWith('#') then
|
||||
Hex := Hex.Substring(1);
|
||||
|
||||
// Îæèäàåì ðîâíî 6 ñèìâîëîâ (RRGGBB)
|
||||
if Length(Hex) <> 6 then
|
||||
raise Exception.CreateFmt('Íåâåðíûé HEX öâåò: %s', [s]);
|
||||
|
||||
// Ïàðñèì êîìïîíåíòû
|
||||
r := StrToInt('$' + Copy(Hex, 1, 2));
|
||||
g := StrToInt('$' + Copy(Hex, 3, 2));
|
||||
b := StrToInt('$' + Copy(Hex, 5, 2));
|
||||
|
||||
// Çàïîëíÿåì ñòðóêòóðó
|
||||
Rec.R := Byte(r);
|
||||
Rec.G := Byte(g);
|
||||
Rec.B := Byte(b);
|
||||
Rec.A := 255; // ïîëíàÿ íåïðîçðà÷íîñòü
|
||||
|
||||
Result := Rec.Color;
|
||||
end;
|
||||
|
||||
procedure TfCreateNotify.setRecord(aRec: TOBSNotify);
|
||||
var
|
||||
SavedColor: TAlphaColor;
|
||||
@@ -97,19 +168,21 @@ begin
|
||||
|
||||
fCreateNotify.frColorSettings1.sbStyleBlockBorderSize.Value := SolidBorder;
|
||||
fCreateNotify.frColorSettings1.sbStyleBlockPadding.Value := Paddings;
|
||||
fCreateNotify.frColorSettings1.ccbStyleBorderColor.ItemIndex := ColorBorder;
|
||||
fCreateNotify.frColorSettings1.ccbBColor.ItemIndex := ColorBackground;
|
||||
fCreateNotify.frColorSettings1.ccbStyleBorderColor.Color := GetColorFromHex(ColorBorder);
|
||||
fCreateNotify.frColorSettings1.ccbBColor.Color := GetColorFromHex(ColorBackground);
|
||||
fCreateNotify.frColorSettings1.cpStyleBlockColor.Color:=GetColorFromRGBA(ColorBlock);
|
||||
|
||||
fCreateNotify.edtESTitle.Text := HeaderText;
|
||||
fCreateNotify.frFontSettings2.ccbFontColor.ItemIndex := HeaderColorFont;
|
||||
fCreateNotify.frFontSettings2.ccbFontColor.Color := GetColorFromHex(HeaderColorFont);
|
||||
fCreateNotify.frFontSettings2.sbFontSize.Value := HeaderSizeFont;
|
||||
fCreateNotify.frFontSettings2.cbFontStyleDefault.ItemIndex :=
|
||||
HeaderStyleFont;
|
||||
fCreateNotify.frFontSettings2.cbFontStyleDefault.Items.IndexOf(HeaderStyleFont);
|
||||
|
||||
fCreateNotify.edtESMessage.Text := MessText;
|
||||
fCreateNotify.frFontSettings3.ccbFontColor.ItemIndex := MessColorFont;
|
||||
fCreateNotify.frFontSettings3.ccbFontColor.Color := GetColorFromHex(MessColorFont);
|
||||
fCreateNotify.frFontSettings3.sbFontSize.Value := MessSizeFont;
|
||||
fCreateNotify.frFontSettings3.cbFontStyleDefault.ItemIndex := MessStyleFont;
|
||||
fCreateNotify.frFontSettings3.cbFontStyleDefault.ItemIndex :=
|
||||
fCreateNotify.frFontSettings3.cbFontStyleDefault.Items.IndexOf(MessStyleFont);
|
||||
|
||||
fCreateNotify.sbTimeMsg.Value := TimeMess;
|
||||
fCreateNotify.cbEventsType.ItemIndex := TypeEvent;
|
||||
@@ -132,18 +205,18 @@ begin
|
||||
(frColorSettings1.cpStyleBlockColor.Color);
|
||||
SolidBorder := round(frColorSettings1.sbStyleBlockBorderSize.Value);
|
||||
Paddings := round(frColorSettings1.sbStyleBlockPadding.Value);
|
||||
ColorBorder := frColorSettings1.ccbStyleBorderColor.ItemIndex;
|
||||
ColorBackground := frColorSettings1.ccbBColor.ItemIndex;
|
||||
ColorBorder := GetColorFromCCB(frColorSettings1.ccbStyleBorderColor.Color);
|
||||
ColorBackground := GetColorFromCCB(frColorSettings1.ccbBColor.Color);
|
||||
|
||||
HeaderText := edtESTitle.Text;
|
||||
HeaderColorFont := frFontSettings2.ccbFontColor.ItemIndex;
|
||||
HeaderColorFont := GetColorFromCCB(frFontSettings2.ccbFontColor.Color);
|
||||
HeaderSizeFont := round(frFontSettings2.sbFontSize.Value);
|
||||
HeaderStyleFont := frFontSettings2.cbFontStyleDefault.ItemIndex;
|
||||
HeaderStyleFont := frFontSettings2.cbFontStyleDefault.Text;
|
||||
|
||||
MessText := edtESMessage.Text;
|
||||
MessColorFont := frFontSettings3.ccbFontColor.ItemIndex;
|
||||
MessColorFont := GetColorFromCCB(frFontSettings3.ccbFontColor.color);
|
||||
MessSizeFont := round(frFontSettings3.sbFontSize.Value);
|
||||
MessStyleFont := frFontSettings3.cbFontStyleDefault.ItemIndex;
|
||||
MessStyleFont := frFontSettings3.cbFontStyleDefault.Text;
|
||||
|
||||
TimeMess := round(sbTimeMsg.Value);
|
||||
TypeEvent := cbEventsType.ItemIndex;
|
||||
@@ -159,22 +232,13 @@ end;
|
||||
|
||||
|
||||
|
||||
function TfCreateNotify.GetColorFromCCB(aColor: TAlphaColor): string;
|
||||
var
|
||||
Color: TAlphaColor;
|
||||
r, G, B: Byte;
|
||||
begin
|
||||
Color := aColor;
|
||||
r := TAlphaColorRec(Color).r;
|
||||
G := TAlphaColorRec(Color).G;
|
||||
B := TAlphaColorRec(Color).B;
|
||||
result := Format('#%.2X%.2X%.2X', [r, G, B]);
|
||||
end;
|
||||
|
||||
|
||||
procedure TfCreateNotify.btnESTestClick(Sender: TObject);
|
||||
var
|
||||
se: TStyleEvent;
|
||||
i: Integer;
|
||||
ws:TEventWebServers;
|
||||
begin
|
||||
|
||||
se.Title := edtESTitle.Text;
|
||||
@@ -195,8 +259,12 @@ begin
|
||||
se.RequireInteraction := True;
|
||||
for i := 0 to TTW_Bot.frOBS1.EventWebServers.Count - 1 do
|
||||
begin
|
||||
TTW_Bot.frOBS1.EventWebServers[i].WebServerChat.AddMessage(se);
|
||||
if TTW_Bot.frOBS1.EventWebServers[i].port = oldPort then
|
||||
ws:=TTW_Bot.frOBS1.EventWebServers[i];
|
||||
|
||||
|
||||
end;
|
||||
ws.WebServerChat.addMessage(se);
|
||||
end;
|
||||
|
||||
procedure TfCreateNotify.cbEventsTypeChange(Sender: TObject);
|
||||
|
||||
+101
-45
@@ -3,7 +3,7 @@ object TTW_Bot: TTTW_Bot
|
||||
Top = 0
|
||||
Caption = 'TTW_Bot'
|
||||
ClientHeight = 886
|
||||
ClientWidth = 970
|
||||
ClientWidth = 1003
|
||||
Position = Designed
|
||||
FormFactor.Width = 320
|
||||
FormFactor.Height = 480
|
||||
@@ -15,30 +15,30 @@ object TTW_Bot: TTTW_Bot
|
||||
object V: TTabControl
|
||||
Align = Client
|
||||
Images = ImageList1
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 744.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabIndex = 5
|
||||
TabIndex = 3
|
||||
TabOrder = 0
|
||||
TabPosition = PlatformDefault
|
||||
Sizes = (
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s
|
||||
970s
|
||||
1003s
|
||||
718s)
|
||||
object TabItem1: TTabItem
|
||||
CustomIcon = <
|
||||
@@ -57,7 +57,7 @@ object TTW_Bot: TTTW_Bot
|
||||
ExplicitSize.cy = 26.000000000000000000
|
||||
inline frSettings1: TfrSettings
|
||||
Align = Client
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 718.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited GroupBox3: TGroupBox
|
||||
@@ -92,35 +92,35 @@ object TTW_Bot: TTTW_Bot
|
||||
TabOrder = 34
|
||||
end
|
||||
inherited Label63: TLabel
|
||||
TabOrder = 30
|
||||
TabOrder = 29
|
||||
end
|
||||
inherited edtDAClientID: TEdit
|
||||
TabOrder = 32
|
||||
end
|
||||
inherited Label64: TLabel
|
||||
TabOrder = 31
|
||||
end
|
||||
inherited edtDAClientSecret: TEdit
|
||||
TabOrder = 33
|
||||
inherited Label64: TLabel
|
||||
TabOrder = 30
|
||||
end
|
||||
inherited Label65: TLabel
|
||||
TabOrder = 32
|
||||
end
|
||||
inherited edtDARedirectURL: TEdit
|
||||
TabOrder = 40
|
||||
TabOrder = 37
|
||||
end
|
||||
inherited edtDACode: TEdit
|
||||
TabOrder = 36
|
||||
TabOrder = 35
|
||||
end
|
||||
inherited Label66: TLabel
|
||||
TabOrder = 37
|
||||
TabOrder = 36
|
||||
end
|
||||
inherited btnDAStart: TButton
|
||||
Images = ImageList1
|
||||
ImageIndex = 18
|
||||
TabOrder = 39
|
||||
TabOrder = 38
|
||||
OnClick = frSettings1btnDAStartClick
|
||||
end
|
||||
inherited btnGetDADef: TButton
|
||||
Images = ImageList1
|
||||
TabOrder = 43
|
||||
TabOrder = 40
|
||||
end
|
||||
end
|
||||
inherited btnOpenRomaning: TButton
|
||||
@@ -168,7 +168,7 @@ object TTW_Bot: TTTW_Bot
|
||||
ExplicitSize.cy = 26.000000000000000000
|
||||
inline frAI1: TfrAI
|
||||
Align = Client
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 718.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited btnGetAIDef: TButton
|
||||
@@ -201,7 +201,7 @@ object TTW_Bot: TTTW_Bot
|
||||
ExplicitSize.cy = 26.000000000000000000
|
||||
inline frCommands1: TfrCommands
|
||||
Align = Client
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 718.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited sgCommands: TStringGrid
|
||||
@@ -269,6 +269,15 @@ object TTW_Bot: TTTW_Bot
|
||||
Images = ImageList1
|
||||
ImageIndex = 12
|
||||
end
|
||||
object cbHelloTTS: TCheckBox
|
||||
Position.X = 240.000000000000000000
|
||||
Position.Y = 35.000000000000000000
|
||||
Size.Width = 152.000000000000000000
|
||||
Size.Height = 19.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 48
|
||||
Text = #1055#1088#1080#1074#1077#1090#1089#1090#1074#1086#1074#1072#1090#1100' '#1085#1086#1074#1099#1093
|
||||
end
|
||||
end
|
||||
end
|
||||
inherited GroupBox9: TGroupBox
|
||||
@@ -423,7 +432,7 @@ object TTW_Bot: TTTW_Bot
|
||||
item
|
||||
end>
|
||||
TextSettings.Trimming = None
|
||||
IsSelected = False
|
||||
IsSelected = True
|
||||
ImageIndex = 20
|
||||
Size.Width = 79.000000000000000000
|
||||
Size.Height = 26.000000000000000000
|
||||
@@ -466,7 +475,8 @@ object TTW_Bot: TTTW_Bot
|
||||
Padding.Top = 20.000000000000000000
|
||||
Padding.Right = 10.000000000000000000
|
||||
Padding.Bottom = 10.000000000000000000
|
||||
Position.Y = 249.000000000000000000
|
||||
Position.X = 1.000000000000000000
|
||||
Position.Y = 342.000000000000000000
|
||||
Size.Width = 841.000000000000000000
|
||||
Size.Height = 368.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
@@ -509,6 +519,52 @@ object TTW_Bot: TTTW_Bot
|
||||
end
|
||||
end
|
||||
end
|
||||
object GroupBox3: TGroupBox
|
||||
Padding.Left = 10.000000000000000000
|
||||
Padding.Top = 20.000000000000000000
|
||||
Padding.Right = 10.000000000000000000
|
||||
Padding.Bottom = 10.000000000000000000
|
||||
Position.X = 337.000000000000000000
|
||||
Position.Y = 8.000000000000000000
|
||||
Size.Width = 625.000000000000000000
|
||||
Size.Height = 326.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
Text = #1053#1072#1075#1088#1072#1076#1099
|
||||
TabOrder = 2
|
||||
inline frRevards1: TfrRevards
|
||||
Align = Client
|
||||
Size.Width = 605.000000000000000000
|
||||
Size.Height = 296.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited StringGrid1: TStringGrid
|
||||
Size.Width = 605.000000000000000000
|
||||
Size.Height = 153.000000000000000000
|
||||
Viewport.Width = 605.000000000000000000
|
||||
Viewport.Height = 153.000000000000000000
|
||||
inherited StringColumn1: TStringColumn
|
||||
Size.Width = 241.000000000000000000
|
||||
end
|
||||
inherited StringColumn2: TStringColumn
|
||||
Size.Width = 140.000000000000000000
|
||||
end
|
||||
end
|
||||
inherited Label34: TLabel
|
||||
TabOrder = 2
|
||||
end
|
||||
inherited nbCustomRevardCost: TNumberBox
|
||||
TabOrder = 5
|
||||
end
|
||||
inherited Label35: TLabel
|
||||
TabOrder = 3
|
||||
end
|
||||
inherited Label2: TLabel
|
||||
TabOrder = 9
|
||||
end
|
||||
inherited btnDelCustomRewards: TButton
|
||||
TabOrder = 16
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object TabItem4: TTabItem
|
||||
CustomIcon = <
|
||||
@@ -527,13 +583,13 @@ object TTW_Bot: TTTW_Bot
|
||||
ExplicitSize.cy = 26.000000000000000000
|
||||
inline frOBS1: TfrOBS
|
||||
Align = Top
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 345.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited sgWebChats: TStringGrid
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 282.000000000000000000
|
||||
Viewport.Width = 970.000000000000000000
|
||||
Viewport.Width = 1003.000000000000000000
|
||||
Viewport.Height = 282.000000000000000000
|
||||
inherited StringColumn2: TStringColumn
|
||||
Size.Width = 200.000000000000000000
|
||||
@@ -550,7 +606,7 @@ object TTW_Bot: TTTW_Bot
|
||||
Anchors = [akTop, akRight]
|
||||
Images = ImageList1
|
||||
ImageIndex = 4
|
||||
Position.X = 882.000000000000000000
|
||||
Position.X = 915.000000000000000000
|
||||
TabOrder = 3
|
||||
OnClick = frOBS1btnDeleteeChatClick
|
||||
end
|
||||
@@ -566,7 +622,7 @@ object TTW_Bot: TTTW_Bot
|
||||
Images = ImageList1
|
||||
ImageIndex = 5
|
||||
Position.X = 264.000000000000000000
|
||||
TabOrder = 8
|
||||
TabOrder = 11
|
||||
end
|
||||
object btnCreateChat: TButton
|
||||
Images = ImageList1
|
||||
@@ -603,7 +659,7 @@ object TTW_Bot: TTTW_Bot
|
||||
item
|
||||
end>
|
||||
TextSettings.Trimming = None
|
||||
IsSelected = True
|
||||
IsSelected = False
|
||||
ImageIndex = 24
|
||||
Size.Width = 110.000000000000000000
|
||||
Size.Height = 26.000000000000000000
|
||||
@@ -615,7 +671,7 @@ object TTW_Bot: TTTW_Bot
|
||||
ExplicitSize.cy = 26.000000000000000000
|
||||
inline frNotify1: TfrNotify
|
||||
Align = Client
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 718.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited btnNotifyOpen: TButton
|
||||
@@ -697,7 +753,7 @@ object TTW_Bot: TTTW_Bot
|
||||
ExplicitSize.cy = 26.000000000000000000
|
||||
inline frAutoActions1: TfrAutoActions
|
||||
Align = Client
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 718.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited GroupBox20: TGroupBox
|
||||
@@ -850,20 +906,20 @@ object TTW_Bot: TTTW_Bot
|
||||
ExplicitSize.cy = 26.000000000000000000
|
||||
inline frLog1: TfrLog
|
||||
Align = Client
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 718.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
inherited Panel1: TPanel
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
inherited btnClear: TButton
|
||||
Images = ImageList1
|
||||
ImageIndex = 4
|
||||
end
|
||||
end
|
||||
inherited sgLog: TStringGrid
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 685.000000000000000000
|
||||
Viewport.Width = 970.000000000000000000
|
||||
Viewport.Width = 1003.000000000000000000
|
||||
Viewport.Height = 685.000000000000000000
|
||||
inherited StringColumn2: TStringColumn
|
||||
Size.Width = 170.000000000000000000
|
||||
@@ -881,7 +937,7 @@ object TTW_Bot: TTTW_Bot
|
||||
object Panel1: TPanel
|
||||
Align = Bottom
|
||||
Position.Y = 744.000000000000000000
|
||||
Size.Width = 970.000000000000000000
|
||||
Size.Width = 1003.000000000000000000
|
||||
Size.Height = 142.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 10
|
||||
@@ -1004,7 +1060,7 @@ object TTW_Bot: TTTW_Bot
|
||||
end
|
||||
object Label1: TLabel
|
||||
Anchors = [akTop, akRight]
|
||||
Position.X = 821.000000000000000000
|
||||
Position.X = 854.000000000000000000
|
||||
Position.Y = 8.000000000000000000
|
||||
Text = #1054#1090#1076#1077#1083#1100#1085#1086#1077' '#1089#1087#1072#1089#1080#1073#1086':'
|
||||
TabOrder = 12
|
||||
@@ -1041,7 +1097,7 @@ object TTW_Bot: TTTW_Bot
|
||||
Anchors = [akTop, akRight]
|
||||
Images = ImageList1
|
||||
ImageIndex = 11
|
||||
Position.X = 821.000000000000000000
|
||||
Position.X = 854.000000000000000000
|
||||
Position.Y = 33.000000000000000000
|
||||
Size.Width = 141.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
@@ -1054,7 +1110,7 @@ object TTW_Bot: TTTW_Bot
|
||||
Anchors = [akTop, akRight]
|
||||
Images = ImageList1
|
||||
ImageIndex = 11
|
||||
Position.X = 821.000000000000000000
|
||||
Position.X = 854.000000000000000000
|
||||
Position.Y = 63.000000000000000000
|
||||
Size.Width = 141.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
@@ -1067,7 +1123,7 @@ object TTW_Bot: TTTW_Bot
|
||||
Anchors = [akTop, akRight]
|
||||
Images = ImageList1
|
||||
ImageIndex = 11
|
||||
Position.X = 821.000000000000000000
|
||||
Position.X = 854.000000000000000000
|
||||
Position.Y = 93.000000000000000000
|
||||
Size.Width = 141.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
|
||||
+53
-29
@@ -26,7 +26,8 @@ uses
|
||||
System.Generics.Collections, utts, uGigaChat, uChatAPI, uMyTimer, uRecords,
|
||||
System.IOUtils, fCommands, uDataBase, FMX.Edit, FMX.Colors, FMX.SpinBox,
|
||||
windows, System.Skia, FMX.Skia, uCreateChat, uCreateNotify, fOBS, fTTS,
|
||||
fPlayerWeb, uWebServerKandinsky, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo;
|
||||
fPlayerWeb, uWebServerKandinsky, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo,
|
||||
fRevards;
|
||||
|
||||
type
|
||||
TTTW_Bot = class(TForm)
|
||||
@@ -73,6 +74,9 @@ type
|
||||
frPlayerWeb1: TfrPlayerWeb;
|
||||
frEvents1: TfrEvents;
|
||||
GroupBox2: TGroupBox;
|
||||
cbHelloTTS: TCheckBox;
|
||||
GroupBox3: TGroupBox;
|
||||
frRevards1: TfrRevards;
|
||||
procedure cbThemeChange(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure SpeedButton1Click(Sender: TObject);
|
||||
@@ -117,6 +121,7 @@ type
|
||||
procedure ESError(aMsg: string);
|
||||
procedure ESStatus(Sender: TObject; const ConnectionEvent: String;
|
||||
StatusCode: Integer; const Description: String);
|
||||
procedure ESOnSubOk(s: string);
|
||||
public
|
||||
{ Public declarations }
|
||||
procedure toLog(aModule, aMethod, aMessage: string; aCode: Integer);
|
||||
@@ -217,7 +222,7 @@ begin
|
||||
on E: Exception do
|
||||
begin
|
||||
toLog('uGeneral', 'ConnectProcedure.ttw_API.Init', E.Message, 2);
|
||||
raise;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -226,7 +231,14 @@ begin
|
||||
rid := ttw_API.getRoomAndBot;
|
||||
if rid = '' then
|
||||
raise Exception.Create('Не удалось получить Room ID');
|
||||
|
||||
try
|
||||
frRevards1.LoadCustomRevards;
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
toLog('uGeneral', 'ConnectProcedure.LoadCustomRevards', E.Message, 2);
|
||||
end;
|
||||
end;
|
||||
// Загрузка эмодзи и бейджей
|
||||
try
|
||||
frOBS1.ChatBadges.Clear;
|
||||
@@ -246,7 +258,7 @@ begin
|
||||
on E: Exception do
|
||||
begin
|
||||
toLog('uGeneral', 'ConnectProcedure.Emotes', E.Message, 2);
|
||||
raise;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -265,7 +277,7 @@ begin
|
||||
ttw_ES.OnGetCustomReward := frEvents1.ESOnGetCustomReward;
|
||||
ttw_ES.OnStatus := ESStatus;
|
||||
// ttw_ES.OnRAW := fRewards.ESOnRAW;
|
||||
// ttw_ES.OnSubOk := fRewards.ESOnSubOk;
|
||||
ttw_ES.OnSubOk := ESOnSubOk;
|
||||
ttw_ES.OnFollow := frOBS1.toEventWebServer;
|
||||
ttw_ES.OnSub := frOBS1.toEventWebServer;
|
||||
ttw_ES.OnGift := frOBS1.toEventWebServer;
|
||||
@@ -276,7 +288,7 @@ begin
|
||||
on E: Exception do
|
||||
begin
|
||||
toLog('uGeneral', 'ConnectProcedure.ttw_ES', E.Message, 2);
|
||||
raise;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -290,8 +302,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TTTW_Bot.DisconnectProcedure;
|
||||
var
|
||||
I: Integer;
|
||||
|
||||
begin
|
||||
try
|
||||
toLog('DisconnectProcedure', 'Start', 'Начало процедуры отключения', 3);
|
||||
@@ -340,6 +351,11 @@ begin
|
||||
toLog('uGeneral', 'ESError', aMsg, 2);
|
||||
end;
|
||||
|
||||
procedure TTTW_Bot.ESOnSubOk(s: string);
|
||||
begin
|
||||
toLog('uGeneral', 'ESOnSubOk', s, 0);
|
||||
end;
|
||||
|
||||
procedure TTTW_Bot.ESStatus(Sender: TObject; const ConnectionEvent: String;
|
||||
StatusCode: Integer; const Description: String);
|
||||
begin
|
||||
@@ -373,9 +389,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TTTW_Bot.btnConnectingClick(Sender: TObject);
|
||||
var
|
||||
rid, tb, ts: string;
|
||||
I: Integer;
|
||||
|
||||
begin
|
||||
if not ValidateInput then
|
||||
exit;
|
||||
@@ -489,17 +503,6 @@ begin
|
||||
|
||||
ttw_API := TTTW_API.Create(Self);
|
||||
|
||||
if (frAI1.edtKandiKey.text <> '') and (frAI1.edtKandiSecret.text <> '') then
|
||||
begin
|
||||
try
|
||||
Kandinsky := TKandinsky_Web.Create(frAI1.edtKandiKey.text,
|
||||
frAI1.edtKandiSecret.text);
|
||||
Kandinsky.ActiveServer(true);
|
||||
toLog('uAI', 'FormCreate', 'Kandinsky Создан', 0);
|
||||
finally
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTTW_Bot.OnTTWStatus(ASender: TObject; const AStatus: TIdStatus;
|
||||
@@ -514,7 +517,8 @@ begin
|
||||
frOBS1.ChatEmotes.Free;
|
||||
frOBS1.ChatWebServers.Free;
|
||||
frOBS1.EventWebServers.Free;
|
||||
frEvents1.CustomRewards.Free;
|
||||
frOBS1.KandinskyWebServers.Free;
|
||||
frRevards1.CustomRewards.Free;
|
||||
kePoints.Free;
|
||||
DisconnectProcedure;
|
||||
if Assigned(ttw_IRS) then
|
||||
@@ -726,6 +730,10 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
if (TTW_Bot.cbHelloTTS.IsChecked) and (aRecord.FirstMsg = 1) then
|
||||
toSpeech('приветствую, ' + IfThen(aRecord.DisplayName <> '',
|
||||
aRecord.DisplayName, aRecord.Username));
|
||||
|
||||
firstWord := ExtractFirstWord(processedText);
|
||||
if IsCommand(firstWord) then
|
||||
begin
|
||||
@@ -1050,6 +1058,7 @@ procedure TTTW_Bot.ReadDB;
|
||||
end;
|
||||
|
||||
frSettings1.Init;
|
||||
|
||||
end;
|
||||
|
||||
// Загрузка гридов автоматических действий
|
||||
@@ -1084,9 +1093,20 @@ procedure TTTW_Bot.ReadDB;
|
||||
frOBS1.EventWebServers := TList<TEventWebServers>.Create;
|
||||
for I := 0 to High(frOBS1.listNotify) do
|
||||
begin
|
||||
|
||||
frOBS1.CreateWebEvents(frOBS1.listNotify[I]);
|
||||
end;
|
||||
db.LoadRecordArray<TOBSKandinsky>('listKandinsky', frOBS1.listKandinsky);
|
||||
frOBS1.KandinskyWebServers := TList<TKandinskyWebServers>.Create;
|
||||
if (frAI1.edtKandiKey.text <> '') and (frAI1.edtKandiSecret.text <> '') then
|
||||
begin
|
||||
for I := 0 to High(frOBS1.listKandinsky) do
|
||||
begin
|
||||
frOBS1.CreateWebKandinsky(frOBS1.listKandinsky[I]);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
frOBS1.UpdateGridFromArray;
|
||||
end;
|
||||
|
||||
@@ -1095,11 +1115,11 @@ procedure TTTW_Bot.ReadDB;
|
||||
begin
|
||||
db.LoadRecordArray<TEventGlobal>('ListEvents', frEvents1.ListEvents);
|
||||
frEvents1.UpdateGrid;
|
||||
frRevards1.CustomRewards := TList<TCustomRevards>.Create;
|
||||
|
||||
frEvents1.CustomRewards := Tlist<TCustomRevards>.Create;
|
||||
// frEvents1.LoadCustomRevards();
|
||||
frEvents1.CustomRewardEvents := Tlist<TCustomRewardEvent>.Create;
|
||||
kePoints:=TKE.Create(frEvents1.edtParams, frEvents1.cbKey1,frEvents1.cbKey2,frEvents1.cbKey3);
|
||||
frEvents1.CustomRewardEvents := TList<TCustomRewardEvent>.Create;
|
||||
kePoints := TKE.Create(frEvents1.edtParams, frEvents1.cbKey1,
|
||||
frEvents1.cbKey2, frEvents1.cbKey3);
|
||||
frTTS1.btnUpdateVoicesClick(Self);
|
||||
frTTS1.cbVoices.ItemIndex := strtoint(db.ReadSetting('cbVoices', '0'));
|
||||
frTTS1.cbOutput.ItemIndex := strtoint(db.ReadSetting('cbOutput', '0'));
|
||||
@@ -1107,6 +1127,7 @@ procedure TTTW_Bot.ReadDB;
|
||||
end;
|
||||
|
||||
begin
|
||||
LoadAISettings;
|
||||
LoadSkills;
|
||||
LoadSettingsComponents;
|
||||
LoadGridsData;
|
||||
@@ -1114,7 +1135,7 @@ LoadSkills;
|
||||
LoadEncryptedConfig;
|
||||
|
||||
LoadNotifySettings;
|
||||
LoadAISettings;
|
||||
|
||||
LoadOBSGrids;
|
||||
LoadAutoActionsGrids;
|
||||
end;
|
||||
@@ -1558,11 +1579,14 @@ function TTTW_Bot.ResponsParserAIPic(inMess, aCommandText,
|
||||
aNick: string): string;
|
||||
var
|
||||
res: string;
|
||||
I: Integer;
|
||||
begin
|
||||
res := inMess;
|
||||
if ContainsText(res, '[Kandinsky]') then
|
||||
begin
|
||||
Kandinsky.generate(aCommandText, aNick);
|
||||
for I := 0 to frOBS1.KandinskyWebServers.Count - 1 do
|
||||
frOBS1.KandinskyWebServers[I].WebServerKandinsky.generate
|
||||
(aCommandText, aNick);
|
||||
res := StringReplace(res, '[Kandinsky]', '', [rfReplaceAll]);
|
||||
end;
|
||||
Result := res;
|
||||
|
||||
+116
-203
@@ -7,7 +7,8 @@ uses
|
||||
System.Variants, System.Generics.Collections, ShellAPI, uSoundManager,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
FMX.Edit, FMX.ListBox, FMX.Controls.Presentation, System.Rtti, FMX.Grid.Style,
|
||||
FMX.ScrollBox, FMX.Grid, uRecords, uDataBase, FMX.Menus, uKeyEvent;
|
||||
FMX.ScrollBox, FMX.Grid, uRecords, uDataBase, FMX.Menus, uKeyEvent,
|
||||
fColorSettings, fFontSettings;
|
||||
|
||||
type
|
||||
TfrEvents = class(TFrame)
|
||||
@@ -42,16 +43,13 @@ type
|
||||
procedure MenuItem1Click(Sender: TObject);
|
||||
procedure cbActionsChange(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
procedure toLog(aCode: integer; aMethod: string; aMess: string);
|
||||
procedure toLog(aCode: integer; aMethod, aMess: string);
|
||||
procedure ExecuteAction(const aAction: integer; const aParam, aUserInput, aUserName, aUserLogin: string);
|
||||
public
|
||||
{ Public declarations }
|
||||
ListEvents: TArray<TEventGlobal>;
|
||||
CustomRewards: Tlist<TCustomRevards>;
|
||||
CustomRewardEvents: Tlist<TCustomRewardEvent>;
|
||||
CustomRewardEvents: TList<TCustomRewardEvent>;
|
||||
|
||||
procedure UpdateGrid;
|
||||
procedure LoadCustomRevards();
|
||||
procedure ESOnGetCustomReward(CustomReward: TCustomRewardEvent);
|
||||
procedure OnDonate(aNick, aMessage, aSum: string);
|
||||
end;
|
||||
@@ -62,36 +60,40 @@ implementation
|
||||
|
||||
uses uGeneral;
|
||||
|
||||
{ --- UI --- }
|
||||
|
||||
procedure TfrEvents.btnAddClick(Sender: TObject);
|
||||
var
|
||||
NewRec: TEventGlobal;
|
||||
begin
|
||||
if (cbEventList.Text = '') or (cbActions.Text = '') then
|
||||
exit;
|
||||
if (cbEventList.ItemIndex < 0) or (cbActions.ItemIndex < 0) then
|
||||
Exit;
|
||||
|
||||
NewRec.Event := cbEventList.ItemIndex;
|
||||
NewRec.Action := cbActions.ItemIndex;
|
||||
NewRec.Param := edtParams.Text;
|
||||
|
||||
if edtIF.Visible then
|
||||
NewRec.Condition := edtIF.Text;
|
||||
if cbRevards.Visible then
|
||||
NewRec.Condition := edtIF.Text
|
||||
else if cbRevards.Visible then
|
||||
NewRec.Condition := cbRevards.Text;
|
||||
|
||||
SetLength(ListEvents, Length(ListEvents) + 1);
|
||||
ListEvents[High(ListEvents)] := NewRec;
|
||||
ListEvents := ListEvents + [NewRec];
|
||||
|
||||
DB.SaveRecordArray<TEventGlobal>('ListEvents', ListEvents);
|
||||
UpdateGrid;
|
||||
end;
|
||||
|
||||
procedure TfrEvents.btnDeleteClick(Sender: TObject);
|
||||
var
|
||||
i, RowIndex: integer;
|
||||
RowIndex: integer;
|
||||
begin
|
||||
RowIndex := sgEvents.Row;
|
||||
if (RowIndex < 0) or (RowIndex > High(ListEvents)) then
|
||||
exit;
|
||||
for i := RowIndex to High(ListEvents) - 1 do
|
||||
ListEvents[i] := ListEvents[i + 1];
|
||||
SetLength(ListEvents, Length(ListEvents) - 1);
|
||||
Exit;
|
||||
|
||||
Delete(ListEvents, RowIndex, 1);
|
||||
|
||||
DB.SaveRecordArray<TEventGlobal>('ListEvents', ListEvents);
|
||||
UpdateGrid;
|
||||
end;
|
||||
@@ -106,82 +108,77 @@ begin
|
||||
edtIF.Visible := cbEventList.ItemIndex = 0;
|
||||
cbRevards.Visible := cbEventList.ItemIndex = 1;
|
||||
Label2.Visible := cbEventList.ItemIndex <= 1;
|
||||
|
||||
end;
|
||||
|
||||
procedure TfrEvents.ESOnGetCustomReward(CustomReward: TCustomRewardEvent);
|
||||
procedure TfrEvents.MenuItem1Click(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog1.Execute and (PopupMenu1.PopupComponent is TEdit) then
|
||||
TEdit(PopupMenu1.PopupComponent).Text := OpenDialog1.FileName;
|
||||
end;
|
||||
|
||||
{ --- Îáùàÿ ëîãèêà --- }
|
||||
|
||||
procedure TfrEvents.ExecuteAction(const aAction: integer; const aParam, aUserInput, aUserName, aUserLogin: string);
|
||||
var
|
||||
i, i2: integer;
|
||||
req, s: string;
|
||||
hr: TCustomRewardEvent;
|
||||
sm: TSongMachine;
|
||||
myAction: integer;
|
||||
f: TfrColorSettings;
|
||||
t: TfrFontSettings;
|
||||
i, j: Integer;
|
||||
notify: TOBSNotify;
|
||||
se: TStyleEvent;
|
||||
begin
|
||||
sm := TSongMachine.Create;
|
||||
try
|
||||
toLog(3, 'ESOnGetCustomReward', 'Íà÷àëî îáðàáîòêè íàãðàäû: ' +
|
||||
CustomReward.Event.revard.Title);
|
||||
s := '[' + CustomReward.Event.user_name +
|
||||
'] êóïèë çà áàëëû êàíàëà íàãðàäó "' +
|
||||
CustomReward.Event.revard.Title + '" ';
|
||||
if CustomReward.Event.user_input <> '' then
|
||||
case aAction of
|
||||
0: begin // Íàæàòü êíîïêó
|
||||
toLog(0, 'ExecuteAction', 'Ñèìóëÿöèÿ íàæàòèÿ: ' + aParam);
|
||||
kePoints.SimulateKeyPress(aParam, 500);
|
||||
end;
|
||||
1: begin // Âîñïðîèçâåäåíèå çâóêà
|
||||
toLog(0, 'ExecuteAction', 'Âîñïðîèçâåäåíèå çâóêà: ' + aParam);
|
||||
sm.PlayPublic(aParam, '100');
|
||||
end;
|
||||
2: begin // Kandinsky
|
||||
toLog(0, 'ExecuteAction', 'Ãåíåðàöèÿ Kandinsky äëÿ: ' + aUserInput);
|
||||
Kandinsky.generate(aUserInput, aUserLogin);
|
||||
end;
|
||||
3: begin // OBS Notify
|
||||
f := TfrColorSettings.Create(Self);
|
||||
t := TfrFontSettings.Create(Self);
|
||||
try
|
||||
for i := 0 to High(TTW_Bot.frOBS1.listNotify) do
|
||||
if TTW_Bot.frOBS1.listNotify[i].TypeEvent = 5 then
|
||||
begin
|
||||
toLog(0, 'ESOnGetCustomReward', 'Ïîëüçîâàòåëüñêèé ââîä: ' +
|
||||
CustomReward.Event.user_input);
|
||||
s := s + ' è ïåðåäàë ñòðîêó ' + CustomReward.Event.user_input
|
||||
end;
|
||||
notify := TTW_Bot.frOBS1.listNotify[i];
|
||||
se.Title := StringReplace(notify.HeaderText, '[NICK]', aUserName, [rfReplaceAll]);
|
||||
se.Context := notify.MessText;
|
||||
se.Url := notify.Picture;
|
||||
se.SoundURL := notify.Sound;
|
||||
se.Timestamp := Now;
|
||||
se.TimeMsg := notify.TimeMess;
|
||||
se.BorderColor := notify.ColorBorder;
|
||||
se.BorderSize := notify.SolidBorder;
|
||||
se.BlockColor := notify.ColorBlock;
|
||||
se.FontTitle.Font := notify.HeaderStyleFont;
|
||||
se.FontTitle.Size := notify.HeaderSizeFont;
|
||||
se.FontTitle.Color := notify.HeaderColorFont;
|
||||
se.FontContext.Font := notify.MessStyleFont;
|
||||
se.FontContext.Size := notify.MessSizeFont;
|
||||
se.FontContext.Color := notify.MessColorFont;
|
||||
se.RequireInteraction := True;
|
||||
|
||||
for i := 0 to high(ListEvents) do
|
||||
begin
|
||||
if ListEvents[i].Event <> 1 then
|
||||
continue;
|
||||
if ListEvents[i].Condition = CustomReward.Event.revard.Title then
|
||||
begin
|
||||
myAction := ListEvents[i].Action;
|
||||
|
||||
{
|
||||
0 Íàæàòü íêîïêó íà êëàâèàòóðå
|
||||
1 Ïðîèãðàòü çâóê
|
||||
2 Kandinsky
|
||||
3 Çàïóñòèòü Web Event
|
||||
4 Íàïèñàòü â ÷àò
|
||||
5 Çàïóñòèòü ïðîãðàììó
|
||||
|
||||
}
|
||||
case myAction of
|
||||
0:
|
||||
begin // íàæàòü êíîïêó
|
||||
toLog(0, 'ESOnGetCustomReward', 'Ñèìóëÿöèÿ íàæàòèÿ: ' +
|
||||
ListEvents[i].Param);
|
||||
kePoints.SimulateKeyPress(ListEvents[i].Param, 500);
|
||||
for j := 0 to TTW_Bot.frOBS1.EventWebServers.Count - 1 do
|
||||
TTW_Bot.frOBS1.EventWebServers[j].WebServerChat.AddMessage(se);
|
||||
end;
|
||||
1:
|
||||
begin // âîñïðîèçâåäåíèå çâóêà
|
||||
toLog(0, 'ESOnGetCustomReward', 'Âîñïðîèçâåäåíèå çâóêà: ' +
|
||||
ListEvents[i].Param);
|
||||
sm.PlayPublic(ListEvents[i].Param, '100');
|
||||
end;
|
||||
2:
|
||||
begin // Kandinsky
|
||||
toLog(0, 'ESOnGetCustomReward', 'Ãåíåðàöèÿ Kandinsky äëÿ: ' +
|
||||
CustomReward.Event.user_input);
|
||||
Kandinsky.generate(CustomReward.Event.user_input,
|
||||
CustomReward.Event.user_login);
|
||||
end;
|
||||
4:
|
||||
begin // Íàïèñàòü â ÷àò
|
||||
|
||||
toLog(0, 'ESOnGetCustomReward', 'Íàïèñàòü â ÷àò: ' +
|
||||
CustomReward.Event.user_input);
|
||||
end;
|
||||
5:
|
||||
begin // çàïóñê ôàéëà
|
||||
toLog(0, 'ESOnGetCustomReward', 'Çàïóñê ôàéëà: ' + ListEvents
|
||||
[i].Param);
|
||||
ShellExecute(0, 'open', pwidechar(ListEvents[i].Param),
|
||||
nil, nil, 0);
|
||||
finally
|
||||
f.Free;
|
||||
t.Free;
|
||||
end;
|
||||
end;
|
||||
4: toLog(0, 'ExecuteAction', 'Íàïèñàòü â ÷àò: ' + aUserInput);
|
||||
5: begin // Çàïóñê ôàéëà
|
||||
toLog(0, 'ExecuteAction', 'Çàïóñê ôàéëà: ' + aParam);
|
||||
ShellExecute(0, 'open', PWideChar(aParam), nil, nil, 0);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
@@ -189,83 +186,46 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrEvents.LoadCustomRevards();
|
||||
procedure TfrEvents.ESOnGetCustomReward(CustomReward: TCustomRewardEvent);
|
||||
var
|
||||
cr: TCustomRevards;
|
||||
ev: TEventGlobal;
|
||||
begin
|
||||
CustomRewards.Clear;
|
||||
cbRevards.Items.Clear;
|
||||
TTW_Bot.toLog('fEvents', 'LoadCustomRevards', 'Çàïðîñ íàãðàä ñ ñåðâåðà', 3);
|
||||
ttw_API.getCustomReward(CustomRewards);
|
||||
for cr in CustomRewards do
|
||||
begin
|
||||
cbRevards.Items.Add(cr.Title);
|
||||
end;
|
||||
end;
|
||||
toLog(3, 'ESOnGetCustomReward', 'Íà÷àëî îáðàáîòêè íàãðàäû: ' + CustomReward.Event.revard.Title);
|
||||
|
||||
procedure TfrEvents.MenuItem1Click(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog1.Execute then
|
||||
TEdit(PopupMenu1.PopupComponent).Text := OpenDialog1.FileName;
|
||||
for ev in ListEvents do
|
||||
if (ev.Event = 1) and (ev.Condition = CustomReward.Event.revard.Title) then
|
||||
ExecuteAction(ev.Action, ev.Param, CustomReward.Event.user_input, CustomReward.Event.user_name, CustomReward.Event.user_login);
|
||||
end;
|
||||
|
||||
procedure TfrEvents.OnDonate(aNick, aMessage, aSum: string);
|
||||
var
|
||||
i, i2: integer;
|
||||
req, s: string;
|
||||
hr: TCustomRewardEvent;
|
||||
sm: TSongMachine;
|
||||
myAction: integer;
|
||||
|
||||
j: integer;
|
||||
aSumInt: integer;
|
||||
BestRow: integer;
|
||||
BestPriority: integer;
|
||||
BestValue: integer;
|
||||
i, aSumInt, BestRow, BestPriority, BestValue,
|
||||
CurrentPriority, CurrentValue, MinVal, MaxVal: integer;
|
||||
Condition: string;
|
||||
CurrentPriority: integer;
|
||||
CurrentValue: integer;
|
||||
MinVal, MaxVal: integer;
|
||||
Parts: tstringlist;
|
||||
se: TStyleEvent;
|
||||
notify: TEventGlobal;
|
||||
|
||||
Parts: TStringList;
|
||||
begin
|
||||
|
||||
aSumInt := StrToIntDef(aSum, 0);
|
||||
BestRow := -1;
|
||||
BestPriority := -1;
|
||||
BestValue := 0;
|
||||
|
||||
for i := 0 to high(ListEvents) do
|
||||
begin
|
||||
if ListEvents[i].Event = 0 then
|
||||
for i := 0 to High(ListEvents) do
|
||||
begin
|
||||
if ListEvents[i].Event <> 0 then
|
||||
Continue;
|
||||
|
||||
Condition := ListEvents[i].Condition;
|
||||
CurrentPriority := -1;
|
||||
CurrentValue := 0;
|
||||
|
||||
// Ïðîâåðêà íà òî÷íîå çíà÷åíèå
|
||||
if Pos('-', Condition) = 0 then
|
||||
if TryStrToInt(Condition, CurrentValue) then
|
||||
begin
|
||||
if Pos('>', Condition) = 0 then
|
||||
begin
|
||||
if Pos('<', Condition) = 0 then
|
||||
begin
|
||||
// Òî÷íîå çíà÷åíèå
|
||||
CurrentValue := StrToIntDef(Condition, -1);
|
||||
if aSumInt = CurrentValue then
|
||||
CurrentPriority := 4;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if CurrentPriority = -1 then
|
||||
end
|
||||
else if Pos('-', Condition) > 0 then
|
||||
begin
|
||||
if Pos('-', Condition) > 0 then
|
||||
begin
|
||||
// Äèàïàçîí
|
||||
Parts := tstringlist.Create;
|
||||
Parts := TStringList.Create;
|
||||
try
|
||||
Parts.Delimiter := '-';
|
||||
Parts.StrictDelimiter := True;
|
||||
@@ -277,94 +237,43 @@ begin
|
||||
if (aSumInt >= MinVal) and (aSumInt <= MaxVal) then
|
||||
begin
|
||||
CurrentPriority := 3;
|
||||
CurrentValue := MinVal; // Ïðèîðèòåò ïî MinVal
|
||||
CurrentValue := MinVal;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Parts.Free;
|
||||
end;
|
||||
end
|
||||
else if Pos('>', Condition) > 0 then
|
||||
else if (Condition.StartsWith('>')) then
|
||||
begin
|
||||
// Óñëîâèå ">X"
|
||||
CurrentValue :=
|
||||
StrToIntDef(Trim(StringReplace(Condition, '>', '',
|
||||
[rfReplaceAll])), 0);
|
||||
CurrentValue := StrToIntDef(Copy(Condition, 2), 0);
|
||||
if aSumInt >= CurrentValue then
|
||||
CurrentPriority := 2;
|
||||
end
|
||||
else if Pos('<', Condition) > 0 then
|
||||
else if (Condition.StartsWith('<')) then
|
||||
begin
|
||||
// Óñëîâèå "<X"
|
||||
CurrentValue :=
|
||||
StrToIntDef(Trim(StringReplace(Condition, '<', '',
|
||||
[rfReplaceAll])), 0);
|
||||
CurrentValue := StrToIntDef(Copy(Condition, 2), 0);
|
||||
if aSumInt <= CurrentValue then
|
||||
CurrentPriority := 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
if CurrentPriority <> -1 then
|
||||
begin
|
||||
// Îïðåäåëåíèå íàèëó÷øåãî óñëîâèÿ
|
||||
if (CurrentPriority > BestPriority) or (CurrentPriority = BestPriority)
|
||||
and ((CurrentPriority = 3) and (CurrentValue > BestValue) or
|
||||
(CurrentPriority = 2) and (CurrentValue > BestValue) or
|
||||
(CurrentPriority = 1) and (CurrentValue < BestValue)) then
|
||||
if (CurrentPriority <> -1) and
|
||||
((CurrentPriority > BestPriority) or
|
||||
((CurrentPriority = BestPriority) and
|
||||
(((CurrentPriority in [2,3]) and (CurrentValue > BestValue)) or
|
||||
((CurrentPriority = 1) and (CurrentValue < BestValue))))) then
|
||||
begin
|
||||
BestPriority := CurrentPriority;
|
||||
BestValue := CurrentValue;
|
||||
BestRow := i;
|
||||
notify := ListEvents[i];
|
||||
end;
|
||||
end;
|
||||
if BestRow = -1 then
|
||||
Break;
|
||||
|
||||
end;
|
||||
end;
|
||||
if BestRow = -1 then
|
||||
exit;
|
||||
sm := TSongMachine.Create;
|
||||
try
|
||||
myAction := ListEvents[i].Action;
|
||||
case myAction of
|
||||
0:
|
||||
begin // íàæàòü êíîïêó
|
||||
toLog(0, 'OnDonate', 'Ñèìóëÿöèÿ íàæàòèÿ: ' + ListEvents[i].Param);
|
||||
kePoints.SimulateKeyPress(ListEvents[i].Param, 500);
|
||||
end;
|
||||
1:
|
||||
begin // âîñïðîèçâåäåíèå çâóêà
|
||||
toLog(0, 'OnDonate', 'Âîñïðîèçâåäåíèå çâóêà: ' + ListEvents[i].Param);
|
||||
sm.PlayPublic(ListEvents[i].Param, '100');
|
||||
end;
|
||||
2:
|
||||
begin // Kandinsky
|
||||
toLog(0, 'OnDonate', 'Ãåíåðàöèÿ Kandinsky äëÿ: ' + aNick);
|
||||
Kandinsky.generate(aMessage, aNick);
|
||||
end;
|
||||
4:
|
||||
begin // Íàïèñàòü â ÷àò
|
||||
|
||||
toLog(0, 'OnDonate', 'Íàïèñàòü â ÷àò: ' + aNick);
|
||||
end;
|
||||
5:
|
||||
begin // çàïóñê ôàéëà
|
||||
toLog(0, 'OnDonate', 'Çàïóñê ôàéëà: ' + ListEvents[i].Param);
|
||||
ShellExecute(0, 'open', pwidechar(ListEvents[i].Param), nil, nil, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
finally
|
||||
sm.Free;
|
||||
end;
|
||||
if BestRow <> -1 then
|
||||
ExecuteAction(ListEvents[BestRow].Action, ListEvents[BestRow].Param, aMessage, aNick, aNick);
|
||||
end;
|
||||
|
||||
procedure TfrEvents.toLog(aCode: integer; aMethod, aMess: string);
|
||||
begin
|
||||
TTW_Bot.toLog('fEvents', aMethod, aMess, aCode);
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrEvents.UpdateGrid;
|
||||
var
|
||||
@@ -372,11 +281,9 @@ var
|
||||
begin
|
||||
sgEvents.BeginUpdate;
|
||||
try
|
||||
sgEvents.RowCount := 0; // Ñáðàñûâàåì ñòðîêè (îñòàâëÿåì òîëüêî çàãîëîâêè)
|
||||
|
||||
sgEvents.RowCount := Length(ListEvents);
|
||||
for i := 0 to High(ListEvents) do
|
||||
begin
|
||||
sgEvents.RowCount := i + 1;
|
||||
sgEvents.Cells[0, i] := cbEventList.Items[ListEvents[i].Event];
|
||||
sgEvents.Cells[1, i] := ListEvents[i].Condition;
|
||||
sgEvents.Cells[2, i] := cbActions.Items[ListEvents[i].Action];
|
||||
@@ -387,4 +294,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrEvents.toLog(aCode: integer; aMethod, aMess: string);
|
||||
begin
|
||||
TTW_Bot.toLog('fEvents', aMethod, aMess, aCode);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ object frOBS: TfrOBS
|
||||
RowCount = 0
|
||||
Options = [ColumnResize, ColumnMove, ColLines, RowLines, Tabs, Header, HeaderClick, AutoDisplacement]
|
||||
OnCellDblClick = sgWebChatsCellDblClick
|
||||
Viewport.Width = 685.000000000000000000
|
||||
Viewport.Height = 164.000000000000000000
|
||||
Viewport.Width = 689.000000000000000000
|
||||
Viewport.Height = 189.000000000000000000
|
||||
object IntegerColumn1: TIntegerColumn
|
||||
Header = #1055#1086#1088#1090
|
||||
HeaderSettings.TextSettings.WordWrap = False
|
||||
|
||||
+156
-333
@@ -5,11 +5,12 @@ interface
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, uCustomEmoties,
|
||||
System.Variants, uWebServerChat, uWebServerEvents, fColorSettings,
|
||||
System.Generics.Collections,
|
||||
fFontSettings,
|
||||
System.Generics.Collections, uWebServerKandinsky,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
System.Rtti, FMX.Grid.Style, FMX.Grid, FMX.ScrollBox, FMX.Edit, FMX.Colors,
|
||||
FMX.ListBox, FMX.EditBox, FMX.SpinBox, FMX.Controls.Presentation, uRecords,
|
||||
System.Generics.Defaults, fFontSettings, System.Character;
|
||||
System.Generics.Defaults, System.Character;
|
||||
|
||||
type
|
||||
TChatWebServers = record
|
||||
@@ -31,10 +32,17 @@ type
|
||||
type
|
||||
TEventWebServers = record
|
||||
port: integer;
|
||||
typeEvent: integer;
|
||||
se: TStyleEvent;
|
||||
WebServerChat: TTTW_Events;
|
||||
end;
|
||||
|
||||
type
|
||||
TKandinskyWebServers = record
|
||||
port: integer;
|
||||
WebServerKandinsky: TKandinsky_Web;
|
||||
end;
|
||||
|
||||
type
|
||||
TfrOBS = class(TFrame)
|
||||
sgWebChats: TStringGrid;
|
||||
@@ -71,11 +79,12 @@ type
|
||||
ChatEmotes: Tlist<TEmotes>;
|
||||
ChatWebServers: Tlist<TChatWebServers>;
|
||||
EventWebServers: Tlist<TEventWebServers>;
|
||||
KandinskyWebServers: Tlist<TKandinskyWebServers>;
|
||||
procedure MsgToWebServer(const aRecord: TTwitchChatMessage);
|
||||
procedure toEventWebServer(CustomReward: TFollowEvent); overload; // follow
|
||||
procedure toEventWebServer(CustomReward: TSubEvent); overload; // sub
|
||||
procedure toEventWebServer(CustomReward: TRaidEvent); overload; // raid
|
||||
procedure toEventWebServer(CustomReward: TGiftEvent); overload; // gift
|
||||
procedure toEventWebServer(aEvent: TFollowEvent); overload; // follow
|
||||
procedure toEventWebServer(aEvent: TSubEvent); overload; // sub
|
||||
procedure toEventWebServer(aEvent: TRaidEvent); overload; // raid
|
||||
procedure toEventWebServer(aEvent: TGiftEvent); overload; // gift
|
||||
procedure toEventWebServer(aNick, aSum, aText: string); overload; // donate
|
||||
procedure CreateWebEvents(eventsSettings: TOBSNotify);
|
||||
|
||||
@@ -91,7 +100,7 @@ type
|
||||
|
||||
procedure AddKandinsky(newRecord: TOBSKandinsky);
|
||||
procedure DelKandinsky(aPort: integer);
|
||||
|
||||
procedure CreateWebKandinsky(aRecord: TOBSKandinsky);
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -290,6 +299,7 @@ begin
|
||||
SetLength(listChats, Length(listChats) + 1);
|
||||
listChats[High(listChats)] := newRecord;
|
||||
UpdateGridFromArray;
|
||||
|
||||
db.SaveRecordArray<TOBSChat>('listChats', listChats);
|
||||
CreateWebChat(newRecord);
|
||||
end;
|
||||
@@ -300,6 +310,7 @@ begin
|
||||
listKandinsky[High(listKandinsky)] := newRecord;
|
||||
UpdateGridFromArray;
|
||||
db.SaveRecordArray<TOBSKandinsky>('listKandinsky', listKandinsky);
|
||||
CreateWebKandinsky(newRecord);
|
||||
end;
|
||||
|
||||
procedure TfrOBS.AddNotify(newRecord: TOBSNotify);
|
||||
@@ -383,12 +394,10 @@ var
|
||||
procedure LoadFontList(const mySL: tstringlist);
|
||||
var
|
||||
SearchRec: TSearchRec;
|
||||
n: integer;
|
||||
begin
|
||||
if not DirectoryExists(myConst.fontsPath) then
|
||||
CreateDir(myConst.fontsPath);
|
||||
|
||||
n := 1;
|
||||
if FindFirst(IncludeTrailingPathDelimiter(myConst.fontsPath) + '*.*',
|
||||
faArchive, SearchRec) = 0 then
|
||||
try
|
||||
@@ -396,7 +405,6 @@ var
|
||||
if (SearchRec.Attr and faAnyFile) = SearchRec.Attr then
|
||||
begin
|
||||
mySL.Add(SearchRec.name);
|
||||
Inc(n);
|
||||
end;
|
||||
until FindNext(SearchRec) <> 0;
|
||||
finally
|
||||
@@ -448,12 +456,9 @@ var
|
||||
procedure LoadFontList(const mySL: tstringlist);
|
||||
var
|
||||
SearchRec: TSearchRec;
|
||||
n: integer;
|
||||
begin
|
||||
if not DirectoryExists(myConst.fontsPath) then
|
||||
CreateDir(myConst.fontsPath);
|
||||
|
||||
n := 1;
|
||||
if FindFirst(IncludeTrailingPathDelimiter(myConst.fontsPath) + '*.*',
|
||||
faArchive, SearchRec) = 0 then
|
||||
try
|
||||
@@ -461,7 +466,6 @@ var
|
||||
if (SearchRec.Attr and faAnyFile) = SearchRec.Attr then
|
||||
begin
|
||||
mySL.Add(SearchRec.name);
|
||||
Inc(n);
|
||||
end;
|
||||
until FindNext(SearchRec) <> 0;
|
||||
finally
|
||||
@@ -480,7 +484,8 @@ begin
|
||||
r := TAlphaColorRec(Color).r;
|
||||
G := TAlphaColorRec(Color).G;
|
||||
B := TAlphaColorRec(Color).B;
|
||||
A := TAlphaColorRec(Color).A / 255; // Ïðåîáðàçóåì àëüôà-êàíàë â äèàïàçîí 0..1
|
||||
A := TAlphaColorRec(Color).A / 255;
|
||||
// Ïðåîáðàçóåì àëüôà-êàíàë â äèàïàçîí 0..1
|
||||
|
||||
// Óñòàíàâëèâàåì òî÷êó â êà÷åñòâå äåñÿòè÷íîãî ðàçäåëèòåëÿ
|
||||
FS := TFormatSettings.Create;
|
||||
@@ -489,31 +494,43 @@ begin
|
||||
result := Format('rgba(%d, %d, %d, %.2f)', [r, G, B, A], FS);
|
||||
end;
|
||||
|
||||
function GetColorFromCCB(aColor: TAlphaColor): string;
|
||||
var
|
||||
Color: TAlphaColor;
|
||||
r, G, B: Byte;
|
||||
begin
|
||||
Color := aColor;
|
||||
r := TAlphaColorRec(Color).r;
|
||||
G := TAlphaColorRec(Color).G;
|
||||
B := TAlphaColorRec(Color).B;
|
||||
result := Format('#%.2X%.2X%.2X', [r, G, B]);
|
||||
end;
|
||||
|
||||
begin
|
||||
fonts := tstringlist.Create;
|
||||
f := TfrColorSettings.Create(self);
|
||||
t := TfrFontSettings.Create(self);
|
||||
try
|
||||
LoadFontList(fonts);
|
||||
EventWebServer.WebServerChat := TTTW_Events.Create(fonts,eventsSettings.port);
|
||||
EventWebServer.WebServerChat := TTTW_Events.Create(fonts,
|
||||
eventsSettings.port);
|
||||
EventWebServer.port := eventsSettings.port;
|
||||
|
||||
EventWebServer.se.title := eventsSettings.HeaderText;
|
||||
EventWebServer.typeEvent := eventsSettings.typeEvent;
|
||||
EventWebServer.se.Title := eventsSettings.HeaderText;
|
||||
EventWebServer.se.Context := eventsSettings.MessText;
|
||||
EventWebServer.se.Url := eventsSettings.Picture;
|
||||
EventWebServer.se.SoundURL := eventsSettings.Sound;
|
||||
EventWebServer.se.Timestamp := now;
|
||||
EventWebServer.se.TimeMsg := eventsSettings.TimeMess;
|
||||
EventWebServer.se.FontTitle.Font:= t.cbFontStyleDefault.Items[eventsSettings.HeaderStyleFont];
|
||||
EventWebServer.se.FontTitle.Font := eventsSettings.HeaderStyleFont;
|
||||
EventWebServer.se.FontTitle.Size := eventsSettings.HeaderSizeFont;
|
||||
EventWebServer.se.FontTitle.Color:=t.ccbFontColor.Items[eventsSettings.HeaderColorFont];
|
||||
EventWebServer.se.FontContext.Font:= t.cbFontStyleDefault.Items[eventsSettings.MessStyleFont];
|
||||
EventWebServer.se.FontTitle.Color := eventsSettings.HeaderColorFont;
|
||||
EventWebServer.se.FontContext.Font := eventsSettings.MessStyleFont;
|
||||
EventWebServer.se.FontContext.Size := eventsSettings.MessSizeFont;
|
||||
EventWebServer.se.FontContext.Color:=t.ccbFontColor.Items[eventsSettings.MessColorFont];
|
||||
EventWebServer.se.BorderColor:=f.ccbStyleBorderColor.Items[eventsSettings.ColorBorder];
|
||||
EventWebServer.se.FontContext.Color :=eventsSettings.MessColorFont;
|
||||
EventWebServer.se.BorderColor := eventsSettings.ColorBorder;
|
||||
EventWebServer.se.BorderSize := eventsSettings.SolidBorder;
|
||||
EventWebServer.se.BlockColor:=GetColorFromColorPanel(f.cpStyleBlockColor.Color);
|
||||
|
||||
EventWebServer.se.BlockColor := eventsSettings.ColorBlock;
|
||||
EventWebServers.Add(EventWebServer);
|
||||
EventWebServers[EventWebServers.Count - 1].WebServerChat.ActiveServer(True);
|
||||
finally
|
||||
@@ -523,6 +540,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrOBS.CreateWebKandinsky(aRecord: TOBSKandinsky);
|
||||
var
|
||||
KandinskyWebServer: TKandinskyWebServers;
|
||||
begin
|
||||
KandinskyWebServer.port := aRecord.port;
|
||||
KandinskyWebServer.WebServerKandinsky :=
|
||||
TKandinsky_Web.Create(TTW_Bot.frAI1.edtKandiKey.text,
|
||||
TTW_Bot.frAI1.edtKandiSecret.text, aRecord.port);
|
||||
KandinskyWebServers.Add(KandinskyWebServer);
|
||||
KandinskyWebServers[KandinskyWebServers.Count - 1]
|
||||
.WebServerKandinsky.ActiveServer(True);
|
||||
|
||||
end;
|
||||
|
||||
procedure TfrOBS.DelChat(aPort: integer);
|
||||
var
|
||||
i, j: integer;
|
||||
@@ -566,6 +597,9 @@ begin
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
KandinskyWebServers[i].WebServerKandinsky.ActiveServer(false);
|
||||
KandinskyWebServers[i].WebServerKandinsky.Destroy;
|
||||
KandinskyWebServers.Delete(i);
|
||||
UpdateGridFromArray;
|
||||
db.SaveRecordArray<TOBSKandinsky>('listKandinsky', listKandinsky);
|
||||
end;
|
||||
@@ -588,7 +622,9 @@ begin
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
||||
EventWebServers[i].WebServerChat.ActiveServer(false);
|
||||
EventWebServers[i].WebServerChat.Destroy;
|
||||
EventWebServers.Delete(i);
|
||||
UpdateGridFromArray;
|
||||
db.SaveRecordArray<TOBSNotify>('listNotify', listNotify);
|
||||
end;
|
||||
@@ -654,12 +690,36 @@ end;
|
||||
|
||||
procedure TfrOBS.EdtNotify(newRecord: TOBSNotify; oldPort: integer);
|
||||
var
|
||||
i: integer;
|
||||
i,mi: integer; ws:TEventWebServers;
|
||||
begin
|
||||
for I := 0 to EventWebServers.Count - 1 do
|
||||
if EventWebServers[i].port = oldPort then
|
||||
begin
|
||||
ws:=EventWebServers[i];
|
||||
mi:=i;
|
||||
end;
|
||||
|
||||
for i := 0 to High(listNotify) do
|
||||
if listNotify[i].port = oldPort then
|
||||
begin
|
||||
listNotify[i] := newRecord;
|
||||
ws.port:=listNotify[i].port;
|
||||
ws.typeEvent:=listNotify[i].TypeEvent;
|
||||
ws.se.title:=listNotify[i].HeaderText;
|
||||
ws.se.Context:=listNotify[i].MessText;
|
||||
ws.se.Url:=listNotify[i].Picture;
|
||||
ws.se.SoundURL:=listNotify[i].Sound;
|
||||
ws.se.TimeMsg:=listNotify[i].TimeMess;
|
||||
ws.se.FontTitle.Font:=listNotify[i].HeaderStyleFont;
|
||||
ws.se.FontTitle.Font := listNotify[i].HeaderStyleFont;
|
||||
ws.se.FontTitle.Size := listNotify[i].HeaderSizeFont;
|
||||
ws.se.FontTitle.Color := listNotify[i].HeaderColorFont;
|
||||
ws.se.FontContext.Font := listNotify[i].MessStyleFont;
|
||||
ws.se.FontContext.Size := listNotify[i].MessSizeFont;
|
||||
ws.se.FontContext.Color := listNotify[i].MessColorFont;
|
||||
ws.se.BorderColor :=listNotify[i].ColorBorder;
|
||||
ws.se.BorderSize := listNotify[i].SolidBorder;
|
||||
ws.se.BlockColor := listNotify[i].ColorBlock;
|
||||
UpdateGridFromArray;
|
||||
db.SaveRecordArray<TOBSNotify>('listNotify', listNotify);
|
||||
Break;
|
||||
@@ -716,342 +776,105 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrOBS.toEventWebServer(CustomReward: TFollowEvent);
|
||||
{
|
||||
0 Îòñëåæèâàíèå
|
||||
1 Ïîäïèñêà
|
||||
2 Ïîäàðî÷íàÿ ïîäïèñêà
|
||||
3 Ðåéä
|
||||
4 Äîíàò
|
||||
5 Ñâîå
|
||||
|
||||
}
|
||||
|
||||
procedure TfrOBS.toEventWebServer(aEvent: TFollowEvent);
|
||||
var
|
||||
se: TStyleEvent;
|
||||
i, j: integer;
|
||||
f: TfrColorSettings;
|
||||
t: TfrFontSettings;
|
||||
notify: TOBSNotify;
|
||||
i: integer;
|
||||
ws: TEventWebServers;
|
||||
begin
|
||||
f := TfrColorSettings.Create(self);
|
||||
t := TfrFontSettings.Create(self);
|
||||
try
|
||||
for i := 0 to high(listNotify) do
|
||||
TTW_Bot.toLog('fOBS', 'toEventWebServer', 'Ïîëó÷åíî ñîáûòèå Follow', 0);
|
||||
for i := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
if listNotify[i].TypeEvent = 0 then
|
||||
if EventWebServers[i].typeEvent = 0 then
|
||||
begin
|
||||
notify := listNotify[i];
|
||||
se.Title := notify.HeaderText;
|
||||
se.Title := StringReplace(se.Title, '[NICK]',
|
||||
CustomReward.event.user_name, [rfReplaceAll]);
|
||||
se.Context := notify.MessText;
|
||||
se.Url := notify.Picture;
|
||||
se.SoundURL := notify.Sound;
|
||||
se.Timestamp := Now;
|
||||
se.TimeMsg := notify.TimeMess;
|
||||
se.BorderColor := f.ccbStyleBorderColor.Items[notify.ColorBorder];
|
||||
se.BorderSize := notify.SolidBorder;
|
||||
se.BlockColor := notify.ColorBlock;
|
||||
se.FontTitle.Font := t.cbFontStyleDefault.Items[notify.HeaderStyleFont];
|
||||
se.FontTitle.Size := notify.HeaderSizeFont;
|
||||
se.FontTitle.Color := t.ccbFontColor.Items[notify.HeaderColorFont];
|
||||
se.FontContext.Font := t.cbFontStyleDefault.Items[notify.MessSizeFont];
|
||||
se.FontContext.Size := notify.MessSizeFont;
|
||||
se.FontContext.Color := t.ccbFontColor.Items[notify.MessColorFont];
|
||||
se.RequireInteraction := True;
|
||||
for j := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
EventWebServers[j].WebServerChat.AddMessage(se);
|
||||
ws := EventWebServers[i];
|
||||
ws.se.Title := StringReplace(ws.se.Title, '[NICK]',
|
||||
aEvent.event.user_name, [rfReplaceAll]);
|
||||
ws.se.Timestamp:=now;
|
||||
ws.se.RequireInteraction := True;
|
||||
TTW_Bot.toLog('fOBS', 'toEventWebServer.BlockColor', ws.se.BlockColor, 3);
|
||||
EventWebServers[i].WebServerChat.AddMessage(ws.se);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
finally
|
||||
f.Free;
|
||||
t.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrOBS.toEventWebServer(CustomReward: TSubEvent);
|
||||
procedure TfrOBS.toEventWebServer(aEvent: TSubEvent);
|
||||
var
|
||||
se: TStyleEvent;
|
||||
i, j: integer;
|
||||
f: TfrColorSettings;
|
||||
t: TfrFontSettings;
|
||||
notify: TOBSNotify;
|
||||
i: integer;
|
||||
ws: TEventWebServers;
|
||||
begin
|
||||
f := TfrColorSettings.Create(self);
|
||||
t := TfrFontSettings.Create(self);
|
||||
try
|
||||
for i := 0 to high(listNotify) do
|
||||
for i := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
if listNotify[i].TypeEvent = 1 then
|
||||
begin
|
||||
notify := listNotify[i];
|
||||
se.Title := notify.HeaderText;
|
||||
se.Title := StringReplace(se.Title, '[NICK]',
|
||||
CustomReward.event.user_name, [rfReplaceAll]);
|
||||
se.Context := notify.MessText;
|
||||
|
||||
se.Url := notify.Picture;
|
||||
se.SoundURL := notify.Sound;
|
||||
se.Timestamp := Now;
|
||||
se.TimeMsg := notify.TimeMess;
|
||||
se.BorderColor := f.ccbStyleBorderColor.Items[notify.ColorBorder];
|
||||
se.BorderSize := notify.SolidBorder;
|
||||
se.BlockColor := notify.ColorBlock;
|
||||
se.FontTitle.Font := t.cbFontStyleDefault.Items[notify.HeaderStyleFont];
|
||||
se.FontTitle.Size := notify.HeaderSizeFont;
|
||||
se.FontTitle.Color := t.ccbFontColor.Items[notify.HeaderColorFont];
|
||||
se.FontContext.Font := t.cbFontStyleDefault.Items[notify.MessSizeFont];
|
||||
se.FontContext.Size := notify.MessSizeFont;
|
||||
se.FontContext.Color := t.ccbFontColor.Items[notify.MessColorFont];
|
||||
se.RequireInteraction := True;
|
||||
for j := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
EventWebServers[j].WebServerChat.AddMessage(se);
|
||||
if EventWebServers[i].typeEvent <> 1 then
|
||||
Continue;
|
||||
ws := EventWebServers[i];
|
||||
ws.se.Title := StringReplace(ws.se.Title, '[NICK]', aEvent.event.user_name,
|
||||
[rfReplaceAll]);
|
||||
EventWebServers[i] := ws;
|
||||
EventWebServers[i].WebServerChat.AddMessage(EventWebServers[i].se);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
finally
|
||||
f.Free;
|
||||
t.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrOBS.toEventWebServer(CustomReward: TRaidEvent);
|
||||
procedure TfrOBS.toEventWebServer(aEvent: TRaidEvent);
|
||||
var
|
||||
se: TStyleEvent;
|
||||
i, j: integer;
|
||||
f: TfrColorSettings;
|
||||
t: TfrFontSettings;
|
||||
notify: TOBSNotify;
|
||||
i: integer;
|
||||
ws: TEventWebServers;
|
||||
begin
|
||||
f := TfrColorSettings.Create(self);
|
||||
t := TfrFontSettings.Create(self);
|
||||
try
|
||||
for i := 0 to high(listNotify) do
|
||||
for i := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
if listNotify[i].TypeEvent = 3 then
|
||||
begin
|
||||
notify := listNotify[i];
|
||||
se.Title := notify.HeaderText;
|
||||
se.Title := StringReplace(se.Title, '[NICK]',
|
||||
CustomReward.event.from_broadcaster_user_name, [rfReplaceAll]);
|
||||
se.Context := notify.MessText;
|
||||
se.Context := StringReplace(se.Context, '[SUM]',
|
||||
inttostr(CustomReward.event.viewers), [rfReplaceAll]);
|
||||
se.Url := notify.Picture;
|
||||
se.SoundURL := notify.Sound;
|
||||
se.Timestamp := Now;
|
||||
se.TimeMsg := notify.TimeMess;
|
||||
se.BorderColor := f.ccbStyleBorderColor.Items[notify.ColorBorder];
|
||||
se.BorderSize := notify.SolidBorder;
|
||||
se.BlockColor := notify.ColorBlock;
|
||||
se.FontTitle.Font := t.cbFontStyleDefault.Items[notify.HeaderStyleFont];
|
||||
se.FontTitle.Size := notify.HeaderSizeFont;
|
||||
se.FontTitle.Color := t.ccbFontColor.Items[notify.HeaderColorFont];
|
||||
se.FontContext.Font := t.cbFontStyleDefault.Items[notify.MessSizeFont];
|
||||
se.FontContext.Size := notify.MessSizeFont;
|
||||
se.FontContext.Color := t.ccbFontColor.Items[notify.MessColorFont];
|
||||
se.RequireInteraction := True;
|
||||
for j := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
EventWebServers[j].WebServerChat.AddMessage(se);
|
||||
if EventWebServers[i].typeEvent <> 3 then
|
||||
Continue;
|
||||
ws := EventWebServers[i];
|
||||
ws.se.Title := StringReplace(ws.se.Title, '[NICK]',
|
||||
aEvent.event.from_broadcaster_user_name, [rfReplaceAll]);
|
||||
ws.se.Context := StringReplace(ws.se.Context, '[SUM]',
|
||||
inttostr(aEvent.event.viewers), [rfReplaceAll]);
|
||||
EventWebServers[i] := ws;
|
||||
EventWebServers[i].WebServerChat.AddMessage(EventWebServers[i].se);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
finally
|
||||
f.Free;
|
||||
t.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrOBS.toEventWebServer(CustomReward: TGiftEvent);
|
||||
procedure TfrOBS.toEventWebServer(aEvent: TGiftEvent);
|
||||
var
|
||||
se: TStyleEvent;
|
||||
i, j: integer;
|
||||
f: TfrColorSettings;
|
||||
t: TfrFontSettings;
|
||||
notify: TOBSNotify;
|
||||
i: integer;
|
||||
ws: TEventWebServers;
|
||||
begin
|
||||
f := TfrColorSettings.Create(self);
|
||||
t := TfrFontSettings.Create(self);
|
||||
try
|
||||
for i := 0 to high(listNotify) do
|
||||
for i := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
if listNotify[i].TypeEvent = 2 then
|
||||
begin
|
||||
notify := listNotify[i];
|
||||
se.Title := notify.HeaderText;
|
||||
se.Title := StringReplace(se.Title, '[NICK]',
|
||||
CustomReward.event.user_name, [rfReplaceAll]);
|
||||
se.Context := notify.MessText;
|
||||
se.Url := notify.Picture;
|
||||
se.SoundURL := notify.Sound;
|
||||
se.Timestamp := Now;
|
||||
se.TimeMsg := notify.TimeMess;
|
||||
se.BorderColor := f.ccbStyleBorderColor.Items[notify.ColorBorder];
|
||||
se.BorderSize := notify.SolidBorder;
|
||||
se.BlockColor := notify.ColorBlock;
|
||||
se.FontTitle.Font := t.cbFontStyleDefault.Items[notify.HeaderStyleFont];
|
||||
se.FontTitle.Size := notify.HeaderSizeFont;
|
||||
se.FontTitle.Color := t.ccbFontColor.Items[notify.HeaderColorFont];
|
||||
se.FontContext.Font := t.cbFontStyleDefault.Items[notify.MessSizeFont];
|
||||
se.FontContext.Size := notify.MessSizeFont;
|
||||
se.FontContext.Color := t.ccbFontColor.Items[notify.MessColorFont];
|
||||
se.RequireInteraction := True;
|
||||
for j := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
EventWebServers[j].WebServerChat.AddMessage(se);
|
||||
if EventWebServers[i].typeEvent <> 2 then
|
||||
Continue;
|
||||
ws := EventWebServers[i];
|
||||
ws.se.Title := StringReplace(ws.se.Title, '[NICK]', aEvent.event.user_name,
|
||||
[rfReplaceAll]);
|
||||
EventWebServers[i] := ws;
|
||||
EventWebServers[i].WebServerChat.AddMessage(EventWebServers[i].se);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
finally
|
||||
f.Free;
|
||||
t.Free;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TfrOBS.toEventWebServer(aNick, aSum, aText: string);
|
||||
var
|
||||
i, j: integer;
|
||||
aSumInt: integer;
|
||||
BestRow: integer;
|
||||
BestPriority: integer;
|
||||
BestValue: integer;
|
||||
Condition: string;
|
||||
CurrentPriority: integer;
|
||||
CurrentValue: integer;
|
||||
MinVal, MaxVal: integer;
|
||||
Parts: tstringlist;
|
||||
se: TStyleEvent;
|
||||
notify: TOBSNotify;
|
||||
f: TfrColorSettings;
|
||||
t: TfrFontSettings;
|
||||
i: integer;
|
||||
ws: TEventWebServers;
|
||||
begin
|
||||
aSumInt := StrToIntDef(aSum, 0);
|
||||
BestRow := -1;
|
||||
BestPriority := -1;
|
||||
BestValue := 0;
|
||||
|
||||
for i := 0 to high(listNotify) do
|
||||
for i := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
if listNotify[i].TypeEvent = 4 then
|
||||
begin
|
||||
Condition := Trim(listNotify[i].TypeEdit);
|
||||
|
||||
if Condition = '' then
|
||||
if EventWebServers[i].typeEvent <> 4 then
|
||||
Continue;
|
||||
|
||||
CurrentPriority := -1;
|
||||
CurrentValue := 0;
|
||||
|
||||
// Ïðîâåðêà íà òî÷íîå çíà÷åíèå
|
||||
if Pos('-', Condition) = 0 then
|
||||
begin
|
||||
if Pos('>', Condition) = 0 then
|
||||
begin
|
||||
if Pos('<', Condition) = 0 then
|
||||
begin
|
||||
// Òî÷íîå çíà÷åíèå
|
||||
CurrentValue := StrToIntDef(Condition, -1);
|
||||
if aSumInt = CurrentValue then
|
||||
CurrentPriority := 4;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if CurrentPriority = -1 then
|
||||
begin
|
||||
if Pos('-', Condition) > 0 then
|
||||
begin
|
||||
// Äèàïàçîí
|
||||
Parts := tstringlist.Create;
|
||||
try
|
||||
Parts.Delimiter := '-';
|
||||
Parts.StrictDelimiter := True;
|
||||
Parts.DelimitedText := Condition;
|
||||
if Parts.Count = 2 then
|
||||
begin
|
||||
MinVal := StrToIntDef(Trim(Parts[0]), 0);
|
||||
MaxVal := StrToIntDef(Trim(Parts[1]), 0);
|
||||
if (aSumInt >= MinVal) and (aSumInt <= MaxVal) then
|
||||
begin
|
||||
CurrentPriority := 3;
|
||||
CurrentValue := MinVal; // Ïðèîðèòåò ïî MinVal
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Parts.Free;
|
||||
end;
|
||||
end
|
||||
else if Pos('>', Condition) > 0 then
|
||||
begin
|
||||
// Óñëîâèå ">X"
|
||||
CurrentValue :=
|
||||
StrToIntDef(Trim(StringReplace(Condition, '>', '',
|
||||
[rfReplaceAll])), 0);
|
||||
if aSumInt >= CurrentValue then
|
||||
CurrentPriority := 2;
|
||||
end
|
||||
else if Pos('<', Condition) > 0 then
|
||||
begin
|
||||
// Óñëîâèå "<X"
|
||||
CurrentValue :=
|
||||
StrToIntDef(Trim(StringReplace(Condition, '<', '',
|
||||
[rfReplaceAll])), 0);
|
||||
if aSumInt <= CurrentValue then
|
||||
CurrentPriority := 1;
|
||||
end;
|
||||
end;
|
||||
|
||||
if CurrentPriority <> -1 then
|
||||
begin
|
||||
// Îïðåäåëåíèå íàèëó÷øåãî óñëîâèÿ
|
||||
if (CurrentPriority > BestPriority) or (CurrentPriority = BestPriority)
|
||||
and ((CurrentPriority = 3) and (CurrentValue > BestValue) or
|
||||
(CurrentPriority = 2) and (CurrentValue > BestValue) or
|
||||
(CurrentPriority = 1) and (CurrentValue < BestValue)) then
|
||||
begin
|
||||
BestPriority := CurrentPriority;
|
||||
BestValue := CurrentValue;
|
||||
BestRow := i;
|
||||
notify := listNotify[i];
|
||||
end;
|
||||
end;
|
||||
if BestRow = -1 then
|
||||
Break;
|
||||
|
||||
f := TfrColorSettings.Create(self);
|
||||
t := TfrFontSettings.Create(self);
|
||||
try
|
||||
se.Title := notify.HeaderText;
|
||||
se.Title := StringReplace(se.Title, '[NICK]', aNick, [rfReplaceAll]);
|
||||
se.Title := StringReplace(se.Title, '[SUM]', aSum, [rfReplaceAll]);
|
||||
se.Context := aText;
|
||||
se.Url := notify.Picture;
|
||||
se.SoundURL := notify.Sound;
|
||||
se.Timestamp := Now;
|
||||
se.TimeMsg := notify.TimeMess;
|
||||
se.BorderColor := f.ccbStyleBorderColor.Items[notify.ColorBorder];
|
||||
se.BorderSize := notify.SolidBorder;
|
||||
se.BlockColor := notify.ColorBlock;
|
||||
se.FontTitle.Font := t.cbFontStyleDefault.Items[notify.HeaderStyleFont];
|
||||
se.FontTitle.Size := notify.HeaderSizeFont;
|
||||
se.FontTitle.Color := t.ccbFontColor.Items[notify.HeaderColorFont];
|
||||
se.FontContext.Font := t.cbFontStyleDefault.Items[notify.MessSizeFont];
|
||||
se.FontContext.Size := notify.MessSizeFont;
|
||||
se.FontContext.Color := t.ccbFontColor.Items[notify.MessColorFont];
|
||||
se.RequireInteraction := True;
|
||||
finally
|
||||
f.Free;
|
||||
t.Free;
|
||||
end;
|
||||
for j := 0 to EventWebServers.Count - 1 do
|
||||
begin
|
||||
EventWebServers[j].WebServerChat.AddMessage(se);
|
||||
end;
|
||||
end;
|
||||
ws := EventWebServers[i];
|
||||
ws.se.Title := StringReplace(ws.se.Title, '[NICK]', aNick, [rfReplaceAll]);
|
||||
ws.se.Context := StringReplace(ws.se.Context, '[SUM]', aSum,
|
||||
[rfReplaceAll]);
|
||||
EventWebServers[i] := ws;
|
||||
EventWebServers[i].WebServerChat.AddMessage(EventWebServers[i].se);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
object frRevards: TfrRevards
|
||||
Size.Width = 613.000000000000000000
|
||||
Size.Height = 339.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
object Label1: TLabel
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 118.000000000000000000
|
||||
Text = #1053#1072#1075#1088#1072#1076#1099' '#1073#1086#1090#1072
|
||||
TabOrder = 0
|
||||
end
|
||||
object StringGrid1: TStringGrid
|
||||
Align = Bottom
|
||||
CanFocus = True
|
||||
ClipChildren = True
|
||||
Position.Y = 143.000000000000000000
|
||||
Size.Width = 613.000000000000000000
|
||||
Size.Height = 196.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 1
|
||||
Viewport.Width = 613.000000000000000000
|
||||
Viewport.Height = 196.000000000000000000
|
||||
object StringColumn1: TStringColumn
|
||||
Header = #1053#1072#1079#1074#1072#1085#1080#1077
|
||||
HeaderSettings.TextSettings.WordWrap = False
|
||||
Size.Width = 241.000000000000000000
|
||||
end
|
||||
object StringColumn2: TStringColumn
|
||||
Header = #1055#1086#1083#1100#1079#1086#1074#1072#1090#1077#1083#1100#1089#1082#1080#1081' '#1074#1074#1086#1076
|
||||
HeaderSettings.TextSettings.WordWrap = False
|
||||
Size.Width = 140.000000000000000000
|
||||
end
|
||||
object StringColumn3: TStringColumn
|
||||
Header = #1054#1087#1080#1089#1072#1085#1080#1077
|
||||
HeaderSettings.TextSettings.WordWrap = False
|
||||
end
|
||||
object StringColumn4: TStringColumn
|
||||
Header = #1062#1077#1085#1072
|
||||
HeaderSettings.TextSettings.WordWrap = False
|
||||
end
|
||||
end
|
||||
object Label34: TLabel
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 8.000000000000000000
|
||||
TextSettings.Trimming = None
|
||||
Text = #1053#1072#1079#1074#1072#1085#1080#1077
|
||||
TabOrder = 4
|
||||
end
|
||||
object ceCustomRevardTitle: TComboEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 5
|
||||
ItemHeight = 19.000000000000000000
|
||||
ItemIndex = -1
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 33.000000000000000000
|
||||
Size.Width = 182.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
end
|
||||
object edtCustomRevardPrompt: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 9
|
||||
Position.X = 198.000000000000000000
|
||||
Position.Y = 33.000000000000000000
|
||||
Size.Width = 348.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
end
|
||||
object nbCustomRevardCost: TNumberBox
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 7
|
||||
Cursor = crIBeam
|
||||
Max = 1000000.000000000000000000
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 88.000000000000000000
|
||||
Size.Width = 79.000000000000000000
|
||||
Size.Height = 22.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
end
|
||||
object Label35: TLabel
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 63.000000000000000000
|
||||
Size.Width = 57.000000000000000000
|
||||
Size.Height = 17.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TextSettings.Trimming = None
|
||||
Text = #1062#1077#1085#1072
|
||||
TabOrder = 6
|
||||
end
|
||||
object Label2: TLabel
|
||||
Position.X = 198.000000000000000000
|
||||
Position.Y = 8.000000000000000000
|
||||
Text = #1054#1087#1080#1089#1072#1085#1080#1077
|
||||
TabOrder = 10
|
||||
end
|
||||
object btnAddCustomRewards: TButton
|
||||
Position.X = 95.000000000000000000
|
||||
Position.Y = 88.000000000000000000
|
||||
TabOrder = 16
|
||||
Text = #1044#1086#1073#1072#1074#1080#1090#1100
|
||||
TextSettings.Trimming = None
|
||||
end
|
||||
object btnDelCustomRewards: TButton
|
||||
Position.X = 183.000000000000000000
|
||||
Position.Y = 88.000000000000000000
|
||||
TabOrder = 17
|
||||
Text = #1059#1076#1072#1083#1080#1090#1100
|
||||
TextSettings.Trimming = None
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,66 @@
|
||||
unit fRevards;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
System.Rtti, FMX.Grid.Style, FMX.Grid, FMX.ScrollBox, uRecords, System.Generics.Collections,
|
||||
FMX.Controls.Presentation, FMX.EditBox, FMX.NumberBox, FMX.Edit, FMX.ComboEdit;
|
||||
|
||||
type
|
||||
TfrRevards = class(TFrame)
|
||||
Label1: TLabel;
|
||||
StringGrid1: TStringGrid;
|
||||
StringColumn1: TStringColumn;
|
||||
StringColumn2: TStringColumn;
|
||||
StringColumn3: TStringColumn;
|
||||
StringColumn4: TStringColumn;
|
||||
Label34: TLabel;
|
||||
ceCustomRevardTitle: TComboEdit;
|
||||
edtCustomRevardPrompt: TEdit;
|
||||
nbCustomRevardCost: TNumberBox;
|
||||
Label35: TLabel;
|
||||
Label2: TLabel;
|
||||
btnDelCustomRewards: TButton;
|
||||
btnAddCustomRewards: TButton;
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
|
||||
CustomRewards: TList<TCustomRevards>;
|
||||
listRevards:tarray<TReward>;
|
||||
procedure LoadCustomRevards;
|
||||
procedure UpdateGrid;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
uses ugeneral;
|
||||
|
||||
procedure TfrRevards.LoadCustomRevards;
|
||||
var
|
||||
cr: TCustomRevards;
|
||||
begin
|
||||
CustomRewards.Clear;
|
||||
TTW_Bot.frEvents1.cbRevards.Items.Clear;
|
||||
ceCustomRevardTitle.items.Clear;
|
||||
TTW_Bot.toLog('fRevards', 'LoadCustomRevards', 'Çàïðîñ íàãðàä ñ ñåðâåðà', 3);
|
||||
ttw_API.getCustomReward(CustomRewards);
|
||||
|
||||
for cr in CustomRewards do
|
||||
begin
|
||||
TTW_Bot.frEvents1.cbRevards.Items.Add(cr.Title);
|
||||
ceCustomRevardTitle.Items.Add(cr.Title);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrRevards.UpdateGrid;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
+45
-46
@@ -10,42 +10,11 @@ TEventGlobal = record
|
||||
Param: string;
|
||||
end;
|
||||
|
||||
|
||||
type
|
||||
TRLog = record
|
||||
rTime: ttime;
|
||||
rType: string;
|
||||
rModule: string;
|
||||
rMethod: string;
|
||||
rMessage: string;
|
||||
end;
|
||||
|
||||
type
|
||||
TCounter = record
|
||||
counterName: string;
|
||||
trigger: string;
|
||||
count: integer;
|
||||
auto: integer;
|
||||
end;
|
||||
|
||||
type
|
||||
TBanWord = record
|
||||
regexp: string;
|
||||
end;
|
||||
|
||||
type
|
||||
TListTimer = record
|
||||
Enable: integer;
|
||||
interval: integer;
|
||||
o: integer;
|
||||
mess: string;
|
||||
end;
|
||||
|
||||
type
|
||||
TOBSKandinsky = record
|
||||
port: integer;
|
||||
end;
|
||||
|
||||
type
|
||||
TOBSNotify = record
|
||||
Picture: string;
|
||||
@@ -54,18 +23,18 @@ type
|
||||
ColorBlock: string;
|
||||
SolidBorder: integer;
|
||||
Paddings: integer;
|
||||
ColorBorder: integer;
|
||||
ColorBackground: integer;
|
||||
ColorBorder: string;
|
||||
ColorBackground: string;
|
||||
|
||||
HeaderText: string;
|
||||
HeaderColorFont: integer;
|
||||
HeaderColorFont: string;
|
||||
HeaderSizeFont: integer;
|
||||
HeaderStyleFont: integer;
|
||||
HeaderStyleFont: string;
|
||||
|
||||
MessText: string;
|
||||
MessColorFont: integer;
|
||||
MessColorFont: string;
|
||||
MessSizeFont: integer;
|
||||
MessStyleFont: integer;
|
||||
MessStyleFont: string;
|
||||
|
||||
TimeMess: integer;
|
||||
TypeEvent: integer;
|
||||
@@ -90,6 +59,33 @@ type
|
||||
StyleFont: integer;
|
||||
end;
|
||||
|
||||
type
|
||||
TListCommands = record
|
||||
R1: string;
|
||||
R2: string;
|
||||
end;
|
||||
|
||||
type
|
||||
TCounter = record
|
||||
counterName: string;
|
||||
trigger: string;
|
||||
count: integer;
|
||||
auto: integer;
|
||||
end;
|
||||
|
||||
type
|
||||
TListTimer = record
|
||||
Enable: integer;
|
||||
interval: integer;
|
||||
o: integer;
|
||||
mess: string;
|
||||
end;
|
||||
|
||||
type
|
||||
TOBSKandinsky = record
|
||||
port: integer;
|
||||
end;
|
||||
|
||||
type
|
||||
TRandomCounters = record
|
||||
rndName: string;
|
||||
@@ -98,9 +94,12 @@ type
|
||||
end;
|
||||
|
||||
type
|
||||
TListCommands = record
|
||||
R1: string;
|
||||
R2: string;
|
||||
TRLog = record
|
||||
rTime: ttime;
|
||||
rType: string;
|
||||
rModule: string;
|
||||
rMethod: string;
|
||||
rMessage: string;
|
||||
end;
|
||||
|
||||
type
|
||||
@@ -342,7 +341,7 @@ type
|
||||
version: string;
|
||||
status: string;
|
||||
cost: integer;
|
||||
condition: TCondition;
|
||||
Condition: TCondition;
|
||||
transport: TTransport;
|
||||
created_at: string;
|
||||
end;
|
||||
@@ -383,7 +382,7 @@ type
|
||||
|
||||
TCustomRewardEvent = record
|
||||
subscription: TSubscriptionPoints;
|
||||
event: TEventReward;
|
||||
Event: TEventReward;
|
||||
end;
|
||||
|
||||
TMetadata = record
|
||||
@@ -455,22 +454,22 @@ type
|
||||
|
||||
TFollowEvent = record
|
||||
subscription: TSubscriptionPoints;
|
||||
event: TEventFollow;
|
||||
Event: TEventFollow;
|
||||
end;
|
||||
|
||||
TSubEvent = record
|
||||
subscription: TSubscriptionPoints;
|
||||
event: TEventSub;
|
||||
Event: TEventSub;
|
||||
end;
|
||||
|
||||
TGiftEvent = record
|
||||
subscription: TSubscriptionPoints;
|
||||
event: TEventGift;
|
||||
Event: TEventGift;
|
||||
end;
|
||||
|
||||
TRaidEvent = record
|
||||
subscription: TSubscriptionPoints;
|
||||
event: TEventRaid;
|
||||
Event: TEventRaid;
|
||||
end;
|
||||
|
||||
TBotAppCfg = record
|
||||
|
||||
+57
-113
@@ -17,7 +17,8 @@ type
|
||||
FCriticalSection: TCriticalSection;
|
||||
procedure IdHTTPServer1CommandGet(AContext: TIdContext;
|
||||
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
|
||||
procedure ProcessFileRequest(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; const Folder: string);
|
||||
procedure ProcessFileRequest(ARequestInfo: TIdHTTPRequestInfo;
|
||||
AResponseInfo: TIdHTTPResponseInfo; const Folder: string);
|
||||
function GenerateHTML: string;
|
||||
function GenerateJSON: string;
|
||||
procedure CleanupOldMessages;
|
||||
@@ -37,7 +38,7 @@ uses ugeneral;
|
||||
|
||||
constructor TTTW_Events.Create(FontList: TStrings; aPort: integer);
|
||||
var
|
||||
I: Integer;
|
||||
I: integer;
|
||||
begin
|
||||
FCriticalSection := TCriticalSection.Create;
|
||||
FMessages := TList<TStyleEvent>.Create;
|
||||
@@ -71,27 +72,19 @@ end;
|
||||
|
||||
procedure TTTW_Events.CleanupOldMessages;
|
||||
var
|
||||
I: Integer;
|
||||
I: integer;
|
||||
TimeNow: TDateTime;
|
||||
begin
|
||||
TimeNow := Now;
|
||||
FCriticalSection.Enter;
|
||||
try
|
||||
for I := FMessages.Count - 1 downto 0 do
|
||||
begin
|
||||
if SecondsBetween(TimeNow, FMessages[I].Timestamp) >= FMessages[I].TimeMsg then
|
||||
if SecondsBetween(TimeNow, FMessages[I].Timestamp) >= FMessages[I].TimeMsg
|
||||
then
|
||||
FMessages.Delete(I);
|
||||
end;
|
||||
finally
|
||||
FCriticalSection.Leave;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TTTW_Events.GenerateHTML: string;
|
||||
var
|
||||
I: Integer;
|
||||
I: integer;
|
||||
s, s1: string;
|
||||
begin
|
||||
// Ãåíåðàöèÿ CSS äëÿ øðèôòîâ
|
||||
@@ -99,126 +92,82 @@ begin
|
||||
for I := 41 to fFontsList.Count - 1 do
|
||||
begin
|
||||
s1 := StringReplace(fFontsList[I], '.ttf', '', [rfReplaceAll]);
|
||||
s := s + Format('@font-face { font-family: ''%s''; src: url(fonts/%s); }', [s1, fFontsList[I]]) + #13#10;
|
||||
s := s + Format('@font-face { font-family: ''%s''; src: url(fonts/%s); }',
|
||||
[s1, fFontsList[I]]) + #13#10;
|
||||
end;
|
||||
|
||||
Result := '<!DOCTYPE html><html><head>' +
|
||||
'<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">' +
|
||||
'<meta http-equiv="Pragma" content="no-cache">' +
|
||||
'<meta http-equiv="Expires" content="0">' +
|
||||
'<title>Twitch Messages</title>' +
|
||||
'<style>' + s +
|
||||
'.message { ' +
|
||||
' will-change: transform, opacity;' + // Îïòèìèçàöèÿ àíèìàöèè
|
||||
' backface-visibility: hidden;' +
|
||||
' transform: translateZ(0);' +
|
||||
' margin:5px; ' +
|
||||
' border-radius:5px; ' +
|
||||
' transition: opacity 1s linear; ' +
|
||||
' max-width: 600px; ' +
|
||||
' margin-left: auto; ' +
|
||||
' margin-right: auto; ' +
|
||||
'}' +
|
||||
'.nick { margin: 0; padding: 2px; }' +
|
||||
'.text { margin: 0; padding: 5px; }' +
|
||||
'#audio-warning { ' +
|
||||
' display: none; ' +
|
||||
' position: fixed; ' +
|
||||
' top: 10px; ' +
|
||||
' right: 10px; ' +
|
||||
' background: #ffcccc; ' +
|
||||
' padding: 10px; ' +
|
||||
' border: 1px solid red; ' +
|
||||
'}' +
|
||||
'</style>' +
|
||||
'<script>' +
|
||||
'let lastPlayedTimestamp = 0;' +
|
||||
'let audioEnabled = false;' +
|
||||
'<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">'
|
||||
+ '<meta http-equiv="Pragma" content="no-cache">' +
|
||||
'<meta http-equiv="Expires" content="0">' + '<title>Twitch Messages</title>'
|
||||
+ '<style>' + s + '.message { ' + ' will-change: transform, opacity;' +
|
||||
// Îïòèìèçàöèÿ àíèìàöèè
|
||||
' backface-visibility: hidden;' + ' transform: translateZ(0);' +
|
||||
' margin:5px; ' + ' border-radius:5px; ' +
|
||||
' transition: opacity 1s linear; ' + ' max-width: 600px; ' +
|
||||
' margin-left: auto; ' + ' margin-right: auto; ' + '}' +
|
||||
'.nick { margin: 0; padding: 2px; }' + '.text { margin: 0; padding: 5px; }'
|
||||
+ '#audio-warning { ' + ' display: none; ' + ' position: fixed; ' +
|
||||
' top: 10px; ' + ' right: 10px; ' + ' background: #ffcccc; ' +
|
||||
' padding: 10px; ' + ' border: 1px solid red; ' + '}' + '</style>' +
|
||||
'<script>' + 'let lastPlayedTimestamp = 0;' + 'let audioEnabled = false;' +
|
||||
'let pendingMessages = [];' +
|
||||
|
||||
'function enableAudio() {' +
|
||||
' audioEnabled = true;' +
|
||||
'function enableAudio() {' + ' audioEnabled = true;' +
|
||||
' document.getElementById("audio-overlay").style.display = "none";' +
|
||||
' processPendingMessages();' +
|
||||
'}' +
|
||||
' processPendingMessages();' + '}' +
|
||||
|
||||
'function processPendingMessages() {' +
|
||||
' pendingMessages.forEach(msg => {' +
|
||||
' playNotificationSound(msg);' +
|
||||
' });' +
|
||||
' pendingMessages = [];' +
|
||||
'}' +
|
||||
'function processPendingMessages() {' + ' pendingMessages.forEach(msg => {'
|
||||
+ ' playNotificationSound(msg);' + ' });' +
|
||||
' pendingMessages = [];' + '}' +
|
||||
|
||||
'function playNotificationSound(msg) {' +
|
||||
' if(!msg.sound) return;' +
|
||||
' const audio = new Audio(msg.sound);' +
|
||||
' audio.play()' +
|
||||
' .catch(error => console.log("Audio error:", error));' +
|
||||
'}' +
|
||||
'function playNotificationSound(msg) {' + ' if(!msg.sound) return;' +
|
||||
' const audio = new Audio(msg.sound);' + ' audio.play()' +
|
||||
' .catch(error => console.log("Audio error:", error));' + '}' +
|
||||
|
||||
'function fetchMessages() {' +
|
||||
' fetch("/messages")' +
|
||||
' .then(response => response.json())' +
|
||||
' .then(data => {' +
|
||||
'function fetchMessages() {' + ' fetch("/messages")' +
|
||||
' .then(response => response.json())' + ' .then(data => {' +
|
||||
' const container = document.getElementById("messages");' +
|
||||
' container.innerHTML = "";' +
|
||||
' data.forEach(msg => {' +
|
||||
' container.innerHTML = "";' + ' data.forEach(msg => {' +
|
||||
|
||||
// Ñîõðàíÿåì ñîîáùåíèÿ äî àêòèâàöèè çâóêà
|
||||
' if(msg.sound && msg.timestamp > lastPlayedTimestamp) {' +
|
||||
' playNotificationSound(msg);' +
|
||||
' lastPlayedTimestamp = msg.timestamp;' +
|
||||
' }' +
|
||||
' lastPlayedTimestamp = msg.timestamp;' + ' }' +
|
||||
|
||||
' const div = document.createElement("div");' +
|
||||
' div.className = "message";' +
|
||||
' div.id = "msg-" + msg.timestamp;' +
|
||||
' div.style = `' +
|
||||
' div.id = "msg-" + msg.timestamp;' + ' div.style = `' +
|
||||
' background-color: ${msg.color};' +
|
||||
' padding: ${msg.padding}px;' +
|
||||
' border: ${msg.sizeBorder}px solid ${msg.colorBorder};' +
|
||||
' text-align: center;' +
|
||||
' `;' +
|
||||
' text-align: center;' + ' `;' +
|
||||
|
||||
// Âíóòðåííèé HTML
|
||||
' let content = "";' +
|
||||
' if(msg.url) {' +
|
||||
' content += `<img src="${msg.url}" style="max-width: 100%; height: auto;">`;' +
|
||||
' }' +
|
||||
' content += `' +
|
||||
' <p class="nick" style="' +
|
||||
' color: ${msg.titlecolor};' +
|
||||
' let content = "";' + ' if(msg.url) {' +
|
||||
' content += `<img src="${msg.url}" style="max-width: 100%; height: auto;">`;'
|
||||
+ ' }' + ' content += `' + ' <p class="nick" style="'
|
||||
+ ' color: ${msg.titlecolor};' +
|
||||
' font-family: ''${msg.titlefamily}'';' +
|
||||
' font-size: ${msg.titleSize}px;">' +
|
||||
' ${msg.nickname}' +
|
||||
' </p>' +
|
||||
' ${msg.nickname}' + ' </p>' +
|
||||
' <p class="text" style="' +
|
||||
' color: ${msg.contentcolor};' +
|
||||
' font-family: ''${msg.contentfamily}'';' +
|
||||
' font-size: ${msg.contentSize}px;">' +
|
||||
' ${msg.content}' +
|
||||
' </p>' +
|
||||
' `;' +
|
||||
' ${msg.content}' + ' </p>' + ' `;' +
|
||||
' div.innerHTML = content;' +
|
||||
|
||||
// Àíèìàöèÿ èñ÷åçíîâåíèÿ
|
||||
' setTimeout(() => {' +
|
||||
' div.style.opacity = "0";' +
|
||||
' setTimeout(() => {' + ' div.style.opacity = "0";' +
|
||||
' setTimeout(() => div.remove(), 1000);' +
|
||||
' }, (msg.duration - 1) * 1000);' +
|
||||
|
||||
' container.appendChild(div);' +
|
||||
' });' +
|
||||
' });' +
|
||||
'}' +
|
||||
' container.appendChild(div);' + ' });' + ' });' + '}' +
|
||||
|
||||
'setInterval(fetchMessages, 500);' +
|
||||
'fetchMessages();' +
|
||||
'</script>' +
|
||||
'setInterval(fetchMessages, 1000);' + 'fetchMessages();' + '</script>' +
|
||||
|
||||
'</head>' +
|
||||
'<body>' +
|
||||
' <div id="messages"></div>' +
|
||||
'</head>' + '<body>' + ' <div id="messages"></div>' +
|
||||
|
||||
'</body></html>';
|
||||
end;
|
||||
@@ -226,42 +175,36 @@ end;
|
||||
function TTTW_Events.GenerateJSON: string;
|
||||
var
|
||||
JSONArray: TJSONArray;
|
||||
I: Integer; S,S1:STRING;
|
||||
I: Integer;
|
||||
Msg: TStyleEvent;
|
||||
begin
|
||||
JSONArray := TJSONArray.Create;
|
||||
try
|
||||
FCriticalSection.Enter;
|
||||
try
|
||||
CleanupOldMessages;
|
||||
for I := 0 to FMessages.Count - 1 do
|
||||
begin
|
||||
Msg := FMessages[I];
|
||||
s:=StringReplace(Msg.FontTitle.Font,'.ttf','',[rfReplaceAll]);
|
||||
s1:=StringReplace(Msg.FontContext.Font,'.ttf','',[rfReplaceAll]);
|
||||
|
||||
JSONArray.AddElement(TJSONObject.Create
|
||||
JSONArray.AddElement(
|
||||
TJSONObject.Create
|
||||
.AddPair('nickname', Msg.Title)
|
||||
.AddPair('url', Msg.Url)
|
||||
.AddPair('content', Msg.Context)
|
||||
.AddPair('timestamp', TJSONNumber.Create(DateTimeToUnix(Msg.Timestamp)))
|
||||
.AddPair('sound', Msg.SoundURL)
|
||||
.AddPair('duration', Msg.TimeMsg)
|
||||
|
||||
.AddPair('color', Msg.BlockColor)
|
||||
.AddPair('colorBorder', Msg.BorderColor)
|
||||
.AddPair('sizeBorder', TJSONNumber.Create(Msg.BorderSize))
|
||||
.AddPair('fontSize', TJSONNumber.Create(Msg.FontTitle.size))
|
||||
|
||||
.AddPair('fontSize', TJSONNumber.Create(Msg.FontTitle.Size))
|
||||
.AddPair('titlecolor', Msg.FontTitle.Color)
|
||||
.AddPair('titlefamily', s)
|
||||
.AddPair('titlefamily', TPath.GetFileNameWithoutExtension(Msg.FontTitle.Font))
|
||||
.AddPair('titleSize', TJSONNumber.Create(Msg.FontTitle.Size))
|
||||
.AddPair('contentcolor', Msg.FontContext.Color)
|
||||
.AddPair('contentfamily', s1)
|
||||
.AddPair('contentfamily', TPath.GetFileNameWithoutExtension(Msg.FontContext.Font))
|
||||
.AddPair('contentSize', TJSONNumber.Create(Msg.FontContext.Size))
|
||||
|
||||
|
||||
); // Ôèêñèðîâàííûé ðàçìåð òåêñòà
|
||||
);
|
||||
end;
|
||||
finally
|
||||
FCriticalSection.Leave;
|
||||
@@ -271,10 +214,10 @@ begin
|
||||
finally
|
||||
JSONArray.Free;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TTTW_Events.ProcessFileRequest(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; const Folder: string);
|
||||
procedure TTTW_Events.ProcessFileRequest(ARequestInfo: TIdHTTPRequestInfo;
|
||||
AResponseInfo: TIdHTTPResponseInfo; const Folder: string);
|
||||
var
|
||||
FileName: string;
|
||||
FilePath: string;
|
||||
@@ -290,6 +233,7 @@ begin
|
||||
AResponseInfo.ContentStream := FS;
|
||||
AResponseInfo.ContentType := GetMIMETypeFromFile(FilePath);;
|
||||
AResponseInfo.ResponseNo := 200;
|
||||
AResponseInfo.FreeContentStream := True;
|
||||
except
|
||||
FS.Free;
|
||||
AResponseInfo.ResponseNo := 500;
|
||||
|
||||
@@ -28,7 +28,7 @@ uses
|
||||
procedure GenerationError(Sender: TObject; const ErrorMessage: string);
|
||||
procedure GenerationUpdate(Sender: TObject; const Message: string);
|
||||
public
|
||||
constructor Create(aKey:string; aSecret:string);
|
||||
constructor Create(aKey:string; aSecret:string; aPort:integer);
|
||||
destructor Destroy;
|
||||
procedure generate(prompt:string; aNick:string);
|
||||
procedure ActiveServer(aEn: boolean);
|
||||
@@ -51,10 +51,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TKandinsky_Web.Create(aKey:string; aSecret:string);
|
||||
constructor TKandinsky_Web.Create(aKey:string; aSecret:string; aPort:integer);
|
||||
begin
|
||||
IdHTTPServer1 := TIdHTTPServer.Create;
|
||||
IdHTTPServer1.DefaultPort := 8087;
|
||||
IdHTTPServer1.DefaultPort := aPort;
|
||||
IdHTTPServer1.OnCommandGet := IdHTTPServer1CommandGet;
|
||||
ka:=TFusionBrainAPI.Create(nil,aKey, aSecret);
|
||||
ka.OnGenerationDone := GenerationDone;
|
||||
|
||||
Reference in New Issue
Block a user