исправил оповещения, теперь работают четко

This commit is contained in:
PC1\PTyTb
2025-08-16 22:42:29 +03:00
parent 2386d14b86
commit fd1c6b6bb8
17 changed files with 968 additions and 928 deletions
+7 -6
View File
@@ -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
View File
@@ -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
View File
@@ -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
+66 -42
View File
@@ -1,15 +1,15 @@
{
получение доната
procedure TfrSettings.HandleWSDonate(aNick, aMessage, aSum: string);
получение доната
procedure TfrSettings.HandleWSDonate(aNick, aMessage, aSum: string);
получение сообщения
procedure TTTW_Bot.ttwIRCOnMessageRecord(aRecord: TTwitchChatMessage);
получение сообщения
procedure TTTW_Bot.ttwIRCOnMessageRecord(aRecord: TTwitchChatMessage);
получение событий
ttw_ES.OnFollow := frOBS1.toEventWebServer;
ttw_ES.OnSub := frOBS1.toEventWebServer;
ttw_ES.OnGift := frOBS1.toEventWebServer;
ttw_ES.OnRaid := frOBS1.toEventWebServer;
получение событий
ttw_ES.OnFollow := frOBS1.toEventWebServer;
ttw_ES.OnSub := frOBS1.toEventWebServer;
ttw_ES.OnGift := frOBS1.toEventWebServer;
ttw_ES.OnRaid := frOBS1.toEventWebServer;
}
unit uGeneral;
@@ -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);
@@ -134,7 +139,7 @@ var
ttw_API: TTTW_API;
userlist: TList<TUser>;
Kandinsky: TKandinsky_Web;
kePoints:TKE;
kePoints: TKE;
implementation
@@ -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;
@@ -262,10 +274,10 @@ begin
// Назначение обработчиков событий
// ttw_ES.OnMessage := fRewards.ESOnMessage;
ttw_ES.OnError := ESError;
ttw_ES.OnGetCustomReward := frEvents1.ESOnGetCustomReward;
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,8 +517,9 @@ begin
frOBS1.ChatEmotes.Free;
frOBS1.ChatWebServers.Free;
frOBS1.EventWebServers.Free;
frEvents1.CustomRewards.Free;
kePoints.Free;
frOBS1.KandinskyWebServers.Free;
frRevards1.CustomRewards.Free;
kePoints.Free;
DisconnectProcedure;
if Assigned(ttw_IRS) then
ttw_IRS.Free;
@@ -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,14 +1127,15 @@ procedure TTTW_Bot.ReadDB;
end;
begin
LoadSkills;
LoadAISettings;
LoadSkills;
LoadSettingsComponents;
LoadGridsData;
LoadGroupNames;
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;