WTelegramClient icon indicating copy to clipboard operation
WTelegramClient copied to clipboard

I‘m using multiple clients to send messages to each other and when replying to keywords, has some problem

Open StevenSKing opened this issue 6 months ago • 0 comments

There are my listening code:

` client.OnUpdates += async updateObj => { try { if (updateObj is UpdatesBase updates) { foreach (var update in updates.UpdateList) { if (update is UpdateNewMessage unm && unm.message is Message message && message.Peer is PeerUser userPeer)//personal msg { if (userPeer.user_id == user.id || message.from_id == null) { continue; }

                 string text = message.message ?? "";
                 string senderName = "unknow";

                 if (message.from_id is PeerUser)
                 {
                     var users = await client.Users_GetUsers(new InputUser(userPeer.user_id, 0));
                     senderName = users.FirstOrDefault()?.MainUsername ?? "NoBody:" + userPeer.user_id;
                 }

                 var check = CheckDll.ExtractCode(text.ToLower()); // check And get keywork logic

                 if (check.check)
                 {
                     _logger.LogInformation($"receive: from [{senderName}] msg: {text}");
                     var inputPeer = await GetInputPeerUser(message.Peer, client, chatinfos._users);
                     
                     await Task.Delay(1800);
                     await client.SendMessageAsync(inputPeer, check.match);
                     _logger.LogInformation("Auto Replay:" + client.User.MainUsername + check.match);
                 }
             }
         }
     }
 }

`

If two clients send messages to each other at the same time, I got this result:

A:reply with the number 1111111.

B:reply with the number 222222.

A:1111111 A:222222 B:1111111 B:222222

They can't Know to tell which messages are their own.

This only happens when sending messages at the same time。

If the interval is more than 5 seconds, everything is fine. Like this:

A:reply with the number 1111111. B:1111111

B:reply with the number 222222. A:222222

StevenSKing avatar Jun 17 '25 17:06 StevenSKing