WTelegramClientHelperForwardMessageAsync(Client, Message, InputPeer, Channel, Boolean, Int32) 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,
Channel toChannel,
bool includeSender,
int topicId = 0
)
Public Shared Function ForwardMessageAsync (
client As Client,
msg As Message,
fromChat As InputPeer,
toChannel As Channel,
includeSender As Boolean,
Optional topicId As Integer = 0
) As Task(Of UpdatesBase)
Dim client As Client
Dim msg As Message
Dim fromChat As InputPeer
Dim toChannel As Channel
Dim includeSender As Boolean
Dim topicId As Integer
Dim returnValue As Task(Of UpdatesBase)
returnValue = WTelegramClientHelper.ForwardMessageAsync(client,
msg, fromChat, toChannel, includeSender,
topicId)
public:
static Task<UpdatesBase^>^ ForwardMessageAsync(
Client^ client,
Message^ msg,
InputPeer^ fromChat,
Channel^ toChannel,
bool includeSender,
int topicId = 0
)
static member ForwardMessageAsync :
client : Client *
msg : Message *
fromChat : InputPeer *
toChannel : Channel *
includeSender : bool *
?topicId : int
(* Defaults:
let _topicId = defaultArg topicId 0
*)
-> 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.
- toChannel Channel
-
The destination channel where to forward the message to.
- includeSender Boolean
-
If True, includes the "Forwarded" header in the forwarded message.
- topicId Int32 (Optional)
-
Optional. If toChannel is a group,
this value indicate the topic where the forwarded message will be sent.
Default value is zero.
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 toChannel 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, toChannel, includeSender:=False, topicId:=0)
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.