Skip to content

Commit

Permalink
+ getChatAdministrators
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Muhandis committed Oct 7, 2024
1 parent 64d00b2 commit 2d13843
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/testbase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ procedure TTestTelegramClass.SetUp;
FChatID:=Conf.ReadInt64('Chat', 'ID', 0);
if FChatID=0 then
Fail('Please, specify chat ID in testtelegram.ini! See readme.md');
FUserID:=Conf.ReadInteger('User', 'ID', 0);
FUserID:=Conf.ReadInt64('User', 'ID', 0);
end;

procedure TTestTelegramClass.TearDown;
Expand Down
10 changes: 10 additions & 0 deletions test/testtelegram.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ TTestSender= class(TTestTelegramClass)
procedure getMyCommands;
procedure setMyCommands;
procedure editMessageMediaStream;
procedure getChatAdministators;
end;

{ TTestProxySender }
Expand Down Expand Up @@ -559,6 +560,15 @@ procedure TTestSender.editMessageMediaStream;
end;
end;

procedure TTestSender.getChatAdministators;
var
aAdministrators: TJSONArray;
begin
Bot.getChatAdministrators(ChatID, aAdministrators);
SaveJSONData(Bot.JSONResponse, '~responce.json');
aAdministrators.Free;
end;

initialization
RegisterTests([TTestSender, TTestSenderProcedure, TTestProxySender, TTestReceiveLongPolling, TTestPayments]);

Expand Down
22 changes: 22 additions & 0 deletions tgsendertypes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ TTelegramSender = class
It can be useful for simplifying and unifying the sending of content }
function SendContent(aChatID: Int64; aContentType: TContentType; const aText, aMedia: String;
aParseMode: TParseMode =pmDefault; aReplyMarkup: TReplyMarkup = nil): Boolean;
function getChatAdministrators(chat_id: Int64; out aChatMembers: TJSONArray): Boolean;
property APIEndPoint: String read GetAPIEndPoint write SetAPIEndPoint;
property BotUser: TTelegramUserObj read FBotUser;
property JSONResponse: TJSONData read FJSONResponse write SetJSONResponse;
Expand Down Expand Up @@ -933,6 +934,8 @@ implementation
s_ChtMmbr='chat_member';
s_MsgThrdID ='message_thread_id';

s_GetChatAdministrators='getChatAdministrators';

s_BsnsCnctnID='business_connection_id';

ParseModes: array[TParseMode] of PChar = ('', 'Markdown', 'HTML', 'MarkdownV2');
Expand Down Expand Up @@ -4017,5 +4020,24 @@ function TTelegramSender.SendContent(aChatID: Int64; aContentType: TContentType;
end;
end;

function TTelegramSender.getChatAdministrators(chat_id: Int64; out aChatMembers: TJSONArray): Boolean;
var
sendObj: TJSONObject;
begin
Result:=False;
sendObj:=TJSONObject.Create;
with sendObj do
try
Add(s_ChatId, chat_id);
Result:=SendMethod(s_GetChatAdministrators, sendObj);
if Result and Assigned(JSONResponse) then
aChatMembers:=JSONResponse.Clone as TJSONArray
else
aChatMembers:=TJSONArray.Create;
finally
Free;
end;
end;

end.

0 comments on commit 2d13843

Please sign in to comment.