sochix / TLSharp

Telegram client library implemented in C#
1k stars 380 forks source link

Throw in System.InvalidOperationException: 'INPUT_METHOD_INVALID' during forwarding message. #729

Open VahedCivil opened 6 years ago

VahedCivil commented 6 years ago

Hi I want to forward message from a channel, a group or an user to another a channel, a group or an user but throw in exception: 'INPUT_METHOD_INVALID'. This is my source code `

        var channelName = "Abaqus_Assistance";
        var dialogs = (TLDialogs)await App.Client.GetUserDialogsAsync();
        var chat1 = dialogs.Chats.OfType<TLChannel>().SingleOrDefault(a => a.Title == "Abaqus Assistance Channel");

        var tlAbsMessages =
            await App.Client.GetHistoryAsync(
                new TLInputPeerChannel { ChannelId = chat1.Id, AccessHash = chat1.AccessHash.Value }, 0,
                -1, 5);
        var tlChannelMessages = (TLChannelMessages)tlAbsMessages;

        var message =
            (TLMessage)tlChannelMessages.Messages.FirstOrDefault(m => !string.IsNullOrEmpty(((TLMessage) m).Message));

        var req = new TLRequestForwardMessage()
        {
            //Id = message.Id,
            Peer = new TLInputPeerUser() { UserId = user.Id, AccessHash = (long)user.AccessHash },
            RandomId = Helpers.GenerateRandomLong(),
            MessageId = message.Id
        };

        var r = await App.Client.SendRequestAsync<TLAbsUpdates>(req);

` All variable have values and aren't null and I tested them with sending message. Message "INPUT_METHOD_INVALID"

StackTrace " at TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)\r\n at TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)\r\n at TLSharp.Core.Network.MtProtoSender.d8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at TLSharp.Core.TelegramClient.d11.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at TLSharp.Core.TelegramClient.d__191.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at Vahed_Telegram_Demo.MainWin.d__38.MoveNext() in E:\Vahed Telegram Demo\MainWin.xaml.cs:line 760

knocte commented 6 years ago

Message "INPUT_METHOD_INVALID"

You have pasted the message and stacktrace, but not the exception type. When reporting bugs, please just place the entire string that ex.ToString() gives please.

VahedCivil commented 6 years ago

Thank you for replay. "System.InvalidOperationException: INPUT_METHOD_INVALID\ at TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) at TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request) at TLSharp.Core.Network.MtProtoSender.d8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at TLSharp.Core.TelegramClient.d11.MoveNext() -- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at TLSharp.Core.TelegramClient.d__191.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Vahed_Telegram_Demo.MainWin.d__38.MoveNext() in E:\Vahed Telegram Demo\MainWin.xaml.cs:line 762"

RavenZero commented 6 years ago

I think i got the same problem here.


    var id = targetUser.Id; // targetUser is the TLUser i want to forward to
    var accessHash = targetUser.AccessHash;

    if (accessHash != null)
    {

        TLRequestForwardMessage forwardRequest = new TLRequestForwardMessage
        {
            Id = message.Id, // "message.id" is from a TLMessage
            Peer = new TLInputPeerUser { UserId = id, AccessHash = (long)accessHash},
            RandomId = Helpers.GenerateRandomLong()
        };

        await TcClient.SendRequestAsync<TLState>(forwardRequest) // this fails

When executing the Send Request, i get the error "INPUT_METHOD_INVALID".

21:06:13: System.InvalidOperationException: INPUT_METHOD_INVALID_865483769_245103
   bei TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
   bei TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, TLMethod request)
   bei TLSharp.Core.Network.MtProtoSender.<Receive>d__8.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   bei TLSharp.Core.TelegramClient.<RequestWithDcMigration>d__11.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   bei TLSharp.Core.TelegramClient.<SendRequestAsync>d__19`1.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   bei ClientManager.Client.<ForwardMessage>d__25.MoveNext() in C:\dev\Telegram\ExperimentalBot\ClientManager\Client.cs:Zeile 304.

Any Ideas whats going wrong?