WTelegramClientHelperForwardMessageAsync(Client, Message, InputPeer, InputPeer, Boolean) Method
Namespace: DevCase.ThirdParty.WTelegramClientAssembly: DevCase.net48.ThirdParty.WTelegramClient (in DevCase.net48.ThirdParty.WTelegramClient.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static Task<UpdatesBase> ForwardMessageAsync(
Client client,
Message msg,
InputPeer fromChat,
InputPeer toChat,
bool includeSender
)
Public Shared Function ForwardMessageAsync (
client As Client,
msg As Message,
fromChat As InputPeer,
toChat As InputPeer,
includeSender As Boolean
) As Task(Of UpdatesBase)
Dim client As Client
Dim msg As Message
Dim fromChat As InputPeer
Dim toChat As InputPeer
Dim includeSender As Boolean
Dim returnValue As Task(Of UpdatesBase)
returnValue = WTelegramClientHelper.ForwardMessageAsync(client,
msg, fromChat, toChat, includeSender)
public:
static Task<UpdatesBase^>^ ForwardMessageAsync(
Client^ client,
Message^ msg,
InputPeer^ fromChat,
InputPeer^ toChat,
bool includeSender
)
static member ForwardMessageAsync :
client : Client *
msg : Message *
fromChat : InputPeer *
toChat : InputPeer *
includeSender : bool -> Task<UpdatesBase>
No code example is currently available or this language may not be supported.
- client Client
-
The source Client object.
- msg Message
-
The source message to be forwarded.
- fromChat InputPeer
-
The source chat where to forward the message from.
- toChat InputPeer
-
The destination chat where to forward the message to.
- includeSender Boolean
-
If True, includes the "Forwarded" header in the forwarded message.
TaskUpdatesBase
An asynchronous operation that returns a
UpdatesBase.
This is a code example.
No code example is currently available or this language may not be supported.
Private Async Sub Test()
Dim clientConfig As New TelegramClientConfig With {
.ApiId = "###",
.ApiHash = "###",
.FirstName = "###",
.LastName = "###",
.Password = "###",
.PhoneNumber = "+34###",
.VerificationCode = "###"
}
Dim client As WTelegram.Client = CreateClient(clientConfig)
Dim myUser As TL.User = Await client.LoginUserIfNeeded()
Dim myUserId As Long = DirectCast(myUser, UserBase).ID
Debug.WriteLine($"We are logged-in as user: {myUser.MainUsername}, id: {myUserId}")
Dim fromChat As TL.ChatBase =
(Await GetChannelsByTitleAsync(client, "From Channel Title", StringComparison.OrdinalIgnoreCase)
).Single()
Dim toChat As TL.ChatBase =
(Await GetChannelsByTitleAsync(client, "To Channel Title", StringComparison.OrdinalIgnoreCase)
).Single()
Dim fromChatMessages As List(Of MessageData) =
Await GetChannelMessages(client, fromChat,
fromTopicId:=0, fromUserId:=0,
onlyMediaMessages:=False,
ascendingMessageOrder:=True)
Dim totalMsgCount As Integer = fromChatMessages.Count
Dim currentMsgCount As Integer
For Each msgData As MessageData In fromChatMessages
Dim flags As TL.Message.Flags = MessageExtensions.GetFlags(msgData.Message)
Dim hasUsername As Boolean = flags.HasFlag(flags.has_post_author)
Dim username As String = If(hasUsername, msgData.PeerInfo.MainUsername, "null")
Dim sb As New StringBuilder()
sb.AppendLine("Forwarding message...")
sb.AppendLine($"Message Count: #{Interlocked.Increment(currentMsgCount)} of #{totalMsgCount}")
sb.AppendLine($"Message Date.: {DirectCast(msgData.Message, MessageBase).Date:dd/MMMM/yyyy, HH:mm:ss}")
sb.AppendLine($"User Name/Id.: {username}/{msgData.PeerInfo.ID}")
sb.AppendLine($"Message......: {msgData.Message.message}")
Debug.WriteLine(sb.ToString())
Try
Await ForwardMessageAsync(client, msgData.Message, fromChat, toChat, includeSender:=False)
Catch ex As RpcException
If ex.Message.Equals("CHAT_FORWARDS_RESTRICTED", StringComparison.OrdinalIgnoreCase) Then
' Ignore?
ElseIf ex.Message.Equals("FILE_REFERENCE_EXPIRED", StringComparison.OrdinalIgnoreCase) Then
' Ignore?
ElseIf ex.Message.Equals("WEBPAGE_NOT_FOUND", StringComparison.OrdinalIgnoreCase) Then
' Ignore?
ElseIf ex.Message.Equals("FLOOD_WAIT_X", StringComparison.OrdinalIgnoreCase) Then
Debug.WriteLine("ERROR: FLOOD_WAIT_X")
Debug.WriteLine($"Waiting {ex.X} seconds to continue with the operation...")
Thread.Sleep(ex.X * 1000)
Else
Throw
End If
Catch ex As Exception
Throw
Finally
' 3 seconds delay between each request to avoid flooding detection (error "FLOOD_WAIT_X").
Thread.Sleep(3000)
End Try
Next
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.