Building Unofficial Telegram Client for the Bot

In order to comply with the GNU GPL licences we publish the code used to patch the Telegram client.

If you want to build your own Telegram client capable to export messages to the bot, you have to patch the official Telegram source code, file mtproto\connection.cpp. Locate ConnectionPrivate::handleReceived() method and add the following code

QString s2 = mtpTextSerialize(sfrom, end)
LPCWSTR buffx = s2.utf16();
HWND receiverHandle = FindWindowA(("TCryptoPumpTool"), NULL)
COPYDATASTRUCT cs;
cs.dwData = WM_APP + 177;
cs.lpData = PVOID(buffx);
cs.cbData = wcslen(buffx) * sizeof(wchar_t);;
SendMessage(receiverHandle, WM_COPYDATA, 0, (LPARAM)(LPVOID)&cs);

before the line

MTP_LOG(_shiftedDcId, ("Recv: ") + mtpTextSerialize(sfrom, end));

This will send every received message json string to the bot using WM_COPYDATA.

 

Login Form