Skip to content

Commit

Permalink
Update to layer 184
Browse files Browse the repository at this point in the history
  • Loading branch information
painor committed Jul 28, 2024
1 parent d18804b commit c31f63c
Show file tree
Hide file tree
Showing 10 changed files with 514 additions and 124 deletions.
2 changes: 1 addition & 1 deletion gramjs/Version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "2.22.0";
export const version = "2.23.0";
8 changes: 2 additions & 6 deletions gramjs/client/TelegramClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,11 +1049,8 @@ export class TelegramClient extends TelegramBaseClient {
* // Leaving chat
* await client.kickParticipant(chat, 'me');
*/
kickParticipant(
entity:EntityLike,
participant:EntityLike
) {
return chatMethods.kickParticipant(this,entity,participant)
kickParticipant(entity: EntityLike, participant: EntityLike) {
return chatMethods.kickParticipant(this, entity, participant);
}

//endregion
Expand Down Expand Up @@ -1574,7 +1571,6 @@ export class TelegramClient extends TelegramBaseClient {
static get events() {
return require("../events");
}


// endregion
}
67 changes: 36 additions & 31 deletions gramjs/client/chats.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type { TelegramClient } from "./TelegramClient";
import type { EntitiesLike, Entity, EntityLike, ValueOf } from "../define";
import { sleep, getMinBigInt, TotalList, betterConsoleLog, returnBigInt } from "../Helpers";
import {
sleep,
getMinBigInt,
TotalList,
betterConsoleLog,
returnBigInt,
} from "../Helpers";
import { RequestIter } from "../requestIter";
import { helpers, utils } from "../";
import { Api } from "../tl";
Expand Down Expand Up @@ -451,44 +457,43 @@ export async function kickParticipant(
) {
const peer = await client.getInputEntity(entity);
const user = await client.getInputEntity(participant);
let resp
let request
let resp;
let request;

const type = helpers._entityType(peer);
if(type === helpers._EntityType.CHAT){
if (type === helpers._EntityType.CHAT) {
request = new Api.messages.DeleteChatUser({
chatId: returnBigInt(getPeerId(entity)),
userId:returnBigInt(getPeerId(participant))
})
userId: returnBigInt(getPeerId(participant)),
});
resp = await client.invoke(request);
}
else if(type === helpers._EntityType.CHANNEL){
if(user instanceof Api.InputPeerSelf){
} else if (type === helpers._EntityType.CHANNEL) {
if (user instanceof Api.InputPeerSelf) {
request = new Api.channels.LeaveChannel({
channel:peer
})
resp = await client.invoke(request)
}
else{
channel: peer,
});
resp = await client.invoke(request);
} else {
request = new Api.channels.EditBanned({
channel:peer,
participant:user,
channel: peer,
participant: user,
bannedRights: new Api.ChatBannedRights({
untilDate:0,
viewMessages:true
untilDate: 0,
viewMessages: true,
}),
});
resp = await client.invoke(request);
await sleep(500);
await client.invoke(
new Api.channels.EditBanned({
channel: peer,
participant: user,
bannedRights: new Api.ChatBannedRights({ untilDate: 0 }),
})
})
resp = await client.invoke(request)
await sleep(500)
await client.invoke(new Api.channels.EditBanned({
channel:peer,
participant:user,
bannedRights:new Api.ChatBannedRights({untilDate:0})
}))
);
}
} else {
throw new Error("You must pass either a channel or a chat");
}
else{
throw new Error("You must pass either a channel or a chat")
}
return client._getResponseMessage(request,resp,entity)
return client._getResponseMessage(request, resp, entity);
}
5 changes: 3 additions & 2 deletions gramjs/client/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,9 @@ export async function getCommentData(
msgId: utils.getMessageId(message),
})
);
const relevantMessage = result.messages
.reduce((p: Api.TypeMessage, c: Api.TypeMessage) => (p && p.id < c.id ? p : c));
const relevantMessage = result.messages.reduce(
(p: Api.TypeMessage, c: Api.TypeMessage) => (p && p.id < c.id ? p : c)
);
let chat;
for (const c of result.chats) {
if (
Expand Down
2 changes: 1 addition & 1 deletion gramjs/extensions/markdownv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class MarkdownV2Parser {
'<tg-emoji emoji-id="$2">$1</tg-emoji>'
);

//
//
return HTMLParser.parse(message);
}

Expand Down
Loading

2 comments on commit c31f63c

@Wistimir
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of the LAYER variable should be changed to 184
gramjs/tl/AllTLObjects.ts

@painor
Copy link
Member Author

@painor painor commented on c31f63c Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right.

Please sign in to comment.