MyTelegram 中文|English
MyTelegram is Telegram server side api implementation written in c#,support private deployment
https://webz.mytelegram.top/
Verification Code:22222
- Supported Api Layer:
143
~148
Open source version:148
Pro version:143
~148
Pro version supports client communication with different layers,open source version only supports single layer - MTProto transports:
Abridged
,Intermediate
(also support Transport error and Transport obfuscation) - Private chat
- Group chat
- Supergroup chat
- Channel
- End-to-end-encryption chat(Pro version)
- Voice/video call(Pro version)
- Bot(Partial support,Pro version)
- 2FA(Pro version)
- Stickers(Pro version)
- Reactions(Pro version)
- ForumTopics(Pro version)
- Install .NET SDK 7.0
- Execute the following command using powershell
git clone https://github.com/loyldg/mytelegram.git
cd mytelegram/source
dotnet restore
cd .\src\MyTelegram.MessengerServer.Abp\
dotnet publish -c Release
- Download docker-compose configuration files
https://github.com/loyldg/mytelegram/blob/dev/docker/compose/docker-compose.yml https://github.com/loyldg/mytelegram/blob/dev/docker/compose/.env
- Change the IP address configuration in .env,replace
127.0.0.1
with the IP address of gateway server - Run the following command in the directory where the docker-compose.yml file is located
docker compose up
- Download mytelegram server from https://github.com/loyldg/mytelegram/releases,supported platform:
win-x64
andlinux-x64
- Uncompress downloaded file
- Install Redis
- Install MongoDB
- Intall RabbitMQ
- Install Minio
- Modify server configuration in
start-all.bat
/start-all.ps1
/start-all.sh
,replace127.0.0.1
with the IP address of gateway server - Run
start-all.bat
/start-all.ps1
/start-all.sh
- Download TDesktop client(4.2.2)
- Add the IP address of the gateway server to hosts file(
%SystemRoot%/system32/drivers/etc/hosts
),for example, the IP address of the gateway server is192.168.1.100
,add the following line to hosts file
192.168.1.100 demos.telegram2.com
- Run Telegram.exe
- Default verification code is
22222
For all clients,only need to replace server address and RSA public key,and then follow the offical documents to build it
Tips:The default TCP port is 20443,default HTTPS port is 30443,default HTTP port is 30444,you need this port when compile the clients,Tdesktop client/Android client/iOS client use tcp port 20443,Web client use 30443(HTTPS)/30444(HTTP) Public key:
-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAu+3tvscWDAlEvVylTeMr5FpU2AjgqzoQHPjzp69r0YAtq0a8rX0M
Ue78F/FRAqBaEbZW6WBzF3AjOlNYpOtvvwGhl9rGCgziunbd9nwcKJBMDWS9O7Mz
/8xjz/swIB4V56XcjOhrjUHJ/GniFKoum00xeEcYnr5xnLesvpVMq97Ga6b+xt3H
RftHY/Zy1dG5zs8upuiAOlEiKilhu1IthfMjFG3NF6TiGrO9YU3YixFbJy67jtHk
v5FarscM2fC5iWQ2eP1y6jXR64sGU3QjncvozYOePrH9jGcnmzUmj42x/H28IjJQ
9EjEc22sPOuauK0IF2QiCGh+TfsKCK189wIDAQAB
-----END RSA PUBLIC KEY-----
PKCS#1 format
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu+
8000
3tvscWDAlEvVylTeMr
5FpU2AjgqzoQHPjzp69r0YAtq0a8rX0MUe78F/FRAqBaEbZW6WBzF3AjOlNYpOtv
vwGhl9rGCgziunbd9nwcKJBMDWS9O7Mz/8xjz/swIB4V56XcjOhrjUHJ/GniFKou
m00xeEcYnr5xnLesvpVMq97Ga6b+xt3HRftHY/Zy1dG5zs8upuiAOlEiKilhu1It
hfMjFG3NF6TiGrO9YU3YixFbJy67jtHkv5FarscM2fC5iWQ2eP1y6jXR64sGU3Qj
ncvozYOePrH9jGcnmzUmj42x/H28IjJQ9EjEc22sPOuauK0IF2QiCGh+TfsKCK18
9wIDAQAB
-----END PUBLIC KEY-----
The default publick key's fingerprint is 0xce27f5081215bda4
(Android client need calculate fingerpint and replace using this value),
if you want to use your own public key,replace private.pkcs8.key
in auth folder
-
Build Tdesktop client
- Switch to the branch which the layer is 146(version 4.2.x)
- Replace server addresses,port and RSA public key in Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp
-
Build Android client
- Switch to the branch which the layer is 146(version 9.x)
- Telegram\TMessagesProj\src\main\java\org\telegram\ui\Components\StickerEmptyView.java Mytelegram not support Stickers in current version,need comment the following code in method
setSticker
MediaDataController.getInstance(currentAccount).loadStickersByEmojiOrName(AndroidUtilities.STICKERS_PLACEHOLDER_PACK_NAME, false, set == null); stickerView.getImageReceiver().clearImage();
- Telegram\TMessagesProj\jni\tgnet\ConnectionsManager.cpp Replace server ip address and port using gateway server's ip and port
- Telegram\TMessagesProj\jni\tgnet\Datacenter.cpp Replace RSA public key in method
decodeSimpleConfig
- Telegram\TMessagesProj\jni\tgnet\Handshake.cpp Replace RSA public key and fingerprint in method
processHandshakeResponse
-
Coming soon
Build iOS client
-
Build Telegram Web K
- src\lib\mtproto\rsaKeysManager.ts Replace modulus with the following value
bbededbec7160c0944bd5ca54de32be45a54d808e0ab3a101cf8f3a7af6bd1802dab46bcad7d0c51eefc17f15102a05a11b656e960731770233a5358a4eb6fbf01a197dac60a0ce2ba76ddf67c1c28904c0d64bd3bb333ffcc63cffb30201e15e7a5dc8ce86b8d41c9fc69e214aa2e9b4d317847189ebe719cb7acbe954cabdec66ba6fec6ddc745fb4763f672d5d1b9cecf2ea6e8803a51222a2961bb522d85f323146dcd17a4e21ab3bd614dd88b115b272ebb8ed1e4bf915aaec70cd9f0b989643678fd72ea35d1eb8b065374239dcbe8cd839e3eb1fd8c67279b35268f8db1fc7dbc223250f448c4736dac3ceb9ab8ad0817642208687e4dfb0a08ad7cf7
- src\lib\mtproto\dcConfigurator.ts Replace the domain and server address
- src\config\app.ts Replace the domain
- webpack.common.js Replace the domain and server address
-
Build Telegram Web Z
- /src/lib/gramjs/network/Authenticator.ts Line 47
const pqInnerData = new Api.PQInnerData({
pq: Helpers.getByteArray(pq), // unsigned
p: pBuffer,
q: qBuffer,
nonce: resPQ.nonce,
serverNonce: resPQ.serverNonce,
newNonce,
}).getBytes();
replace the code with the following code
const pqInnerData = new Api.PQInnerDataDc({
pq: Helpers.getByteArray(pq), // unsigned
p: pBuffer,
q: qBuffer,
nonce: resPQ.nonce,
serverNonce: resPQ.serverNonce,
newNonce,
dc: 2
}).getBytes();
- /src/lib/gramjs/extensions/PromisedWebSockets.js Line 69
Replace
port === 443
withport === 30443
getWebSocketLink(ip, port, testServers) {
if (port === 443) {
return `wss://${ip}:${port}/apiws${testServers ? '_test' : ''}`;
} else {
return `ws://${ip}:${port}/apiws${testServers ? '_test' : ''}`;
}
}
- src\lib\gramjs\crypto\RSA.ts Replace SERVER_KEYS with the following code
export const SERVER_KEYS = [
{
fingerprint: bigInt('-3591632762792723036'),
n: bigInt('bbededbec7160c0944bd5ca54de32be45a54d808e0ab3a101cf8f3a7af6bd1802dab46bcad7d0c51eefc17f15102a05a11b656e960731770233a5358a4eb6fbf01a197dac60a0ce2ba76ddf67c1c28904c0d64bd3bb333ffcc63cffb30201e15e7a5dc8ce86b8d41c9fc69e214aa2e9b4d317847189ebe719cb7acbe954cabdec66ba6fec6ddc745fb4763f672d5d1b9cecf2ea6e8803a51222a2961bb522d85f323146dcd17a4e21ab3bd614dd88b115b272ebb8ed1e4bf915aaec70cd9f0b989643678fd72ea35d1eb8b065374239dcbe8cd839e3eb1fd8c67279b35268f8db1fc7dbc223250f448c4736dac3ceb9ab8ad0817642208687e4dfb0a08ad7cf7',16),
e: 65537
}
].reduce((acc, { fingerprint, ...keyInfo }) => {
acc.set(fingerprint.toString(), keyInfo);
return acc;
}, new Map<string, { n: bigInt.BigInteger; e: number }>());
- src\lib\gramjs\client\TelegramClient.js
Line 29:Replacezws2.web.telegram.org
with the IP address of the gateway server
Line 30:Replace[2001:67c:4e8:f002::a]
with the IPV6 address of the gateway server,if gateway server IPV6 not enable,you can also replace the value with the IPV4 address of gateway server
Line 70:useWSS: false
(HTTP)useWSS: false
(HTTPS)
Line 224:Replacethis._args.useWSS ? 443 : 80
withthis._args.useWSS ? 30443 : 30444
- src\api\gramjs\methods\users.ts
Line 146:
const result = await invokeRequest(new GramJs.users.GetUsers({
id: users.map(({ id, accessHash }) => buildInputPeer(id, accessHash)),
}));
Replace with the following code:
const result = await invokeRequest(new GramJs.users.GetUsers({
id: users.map(({ id, accessHash }) => new GramJs.InputUser({ userId: BigInt(id), accessHash: BigInt(accessHash!) })),
}));
- src\lib\gramjs\Utils.js Line 640:
function getDC(dcId, downloadDC = false) {
// TODO Move to external config
Replace with the following code,and replace ipAddress
function getDC(dcId, downloadDC = false) {
return { id: 2, ipAddress: 'IPAddress of your gateway server', port: 30443 };
- src\api\gramjs\gramjsBuilders\index.ts
Line 31:Changeconst CHANNEL_ID_MIN_LENGTH = 11;
toconst CHANNEL_ID_MIN_LENGTH = 13;
Line 51:ChangechatOrUserId <= -1000000000
tochatOrUserId <= -800000000000
Love MyTelegram? Please give a star to this repository ⭐
Contact author:https://t.me/mytelegram666
Join telegram group:https://t.me/+S-aNBoRvCRpPyXrR