Telegram Web K with changes to work inside I2P https://web.telegram.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

55 lines
1.1 KiB

/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
String.prototype.toUserId = function() {
return (+this).toUserId();
};
String.prototype.toChatId = function() {
return (+this).toChatId();
};
String.prototype.toPeerId = function(isChat?: boolean) {
return (+this).toPeerId(isChat);
};
String.prototype.isPeerId = function() {
return /^[\d-]/.test(this.toString());
};
Number.prototype.toUserId = function() {
return this as any;
};
Number.prototype.toChatId = function() {
return Math.abs(this as any);
};
Number.prototype.toPeerId = function(isChat?: boolean) {
return isChat === undefined ? this as number : (isChat ? -Math.abs(this as number) : this as number);
};
Number.prototype.isPeerId = function() {
return true;
};
declare global {
interface String {
toUserId(): UserId;
toChatId(): ChatId;
toPeerId(isChat?: boolean): PeerId;
isPeerId(): this is string;
}
interface Number {
toUserId(): UserId;
toChatId(): ChatId;
toPeerId(isChat?: boolean): PeerId;
isPeerId(): this is PeerId;
}
}
export {};