Sub SDK_onResult(tlo As Object, methodname As String)
Log($"SDK_onResult(${methodname})"$)
If methodname = "Error" Then
Dim err As Error = tlo
Log($"Error ${err.Code} -> ${err.message}"$)
End If
If tlo Is AuthorizationState Then
Dim state As AuthorizationState = tlo
Dim name As String = state.toString
'name = name.Replace($"{${CRLF}}"$,"")
name = name.SubString2(0,name.IndexOf("{")).Trim
Log($"${state.Constructor} -> ${name}"$)
'904720988 -> AuthorizationStateWaitTdlibParameters
' -1834871737 -> AuthorizationStateReady
' AuthorizationStateWaitTdlibParameters
' Send the Parameters
If state.Constructor = 904720988 Then
Log("Sending Parameters...")
sdk.sendParameters(params)
End If
If state.Constructor = -1834871737 Then
' AuthorizationStateReady
' Login is now finished.....
End If
else if tlo Is Users Then
Dim users As Users = tlo
Dim usrids As List = users.userIds
Log(usrids)
else if tlo Is Chats Then
Dim chats As Chats = tlo
Dim chatids As List = chats.chatIds
Log(chatids)
else if tlo Is tdMessages Then
Dim msgs As tdMessages = tlo
If msgs.messages.Length > 0 Then
For i = 0 To msgs.messages.Length -1
Dim msg As Message = msgs.Messages(i)
Log($"${msg.chatId} -> ${msg.Id}"$)
Next
End If
else if tlo Is UpdateChatLastMessage Then
Dim UpdChatLastMessage As UpdateChatLastMessage = tlo
Log($"${UpdChatLastMessage.chatId}"$)
Dim UpdateChatLastMessagemsg As Message = UpdChatLastMessage.lastMessage
else if tlo Is UpdateBasicGroup Then
else if tlo Is UpdateBasicGroupFullInfo Then
else if tlo Is UpdateCall Then
else if tlo Is UpdateChatLastMessage Then
else if tlo Is UpdateFile Then
Dim updFile As UpdateFile = tlo
else if tlo Is UpdateChatPhoto Then
else if tlo Is UpdateChatTitle Then
else if tlo Is UpdateMessageContent Then
else if tlo Is UpdateMessageContentOpened Then
else if tlo Is UpdateMessageEdited Then
else if tlo Is UpdateMessageMentionRead Then
else if tlo Is UpdateMessageSendFailed Then
else if tlo Is UpdateMessageSendSucceeded Then
else if tlo Is UpdateMessageViews Then
else if tlo Is UpdateSecretChat Then
else if tlo Is UpdateServiceNotification Then
else if tlo Is UpdateSupergroup Then
else if tlo Is UpdateSupergroupFullInfo Then
else if tlo Is UpdateUnreadMessageCount Then
else if tlo Is UpdateUserFullInfo Then
else if tlo Is UpdateUserStatus Then
else if tlo Is UpdateChatOrder Then
Dim chatorder As UpdateChatOrder = tlo
Log($"UpdateChatOrder(${chatorder.chatId}, ${chatorder.order})"$)
sdk.GetChat(chatorder.chatId)
else if tlo Is UserProfilePhotos Then
else if tlo Is TdUser Then
Dim usr As TdUser = tlo
Log(usr)
else if tlo Is UpdateNewCallbackQuery Then
Dim qry As UpdateNewCallbackQuery = tlo
Log($"CallbackQuery: ${qry.chatId} ${qry.Payload}"$)
Dim payl As CallbackQueryPayloadData = qry.Payload
Log(bc.StringFromBytes(payl.data,"utf8"))
else if tlo Is UpdateNewChat Then
Dim newchat As UpdateNewChat = tlo
Log(newchat.Chat)
'UpdateNotificationSettings
else if tlo Is UpdateNotificationSettings Then
Dim set As UpdateNotificationSettings = tlo
If set.scope Is NotificationSettingsScopeChat Then
'Dim scope As NotificationSettingsScopeChat
'Log("Scope for ChatId: "&scope.chatId)
End If
If set.scope Is NotificationSettingsScopeAllChats Then
Dim scopeall As NotificationSettingsScopeAllChats
'Log("Scope for All Chats")
End If
If set.scope Is NotificationSettingsScopeBasicGroupChats Then
Dim scopebasic As NotificationSettingsScopeBasicGroupChats
'Log("Scope for BasicGroup Chats")
End If
If set.scope Is NotificationSettingsScopePrivateChats Then
Dim scopeprivate As NotificationSettingsScopePrivateChats
'Log("Scope for Private Chats")
End If
Dim setting As NotificationSettings = set.notificationSettings
Log($"Setting: ${setting.toString}"$)
else if tlo Is UpdateOption Then
Dim optval As UpdateOption = tlo
Dim opt As Map = optval.Value
Log(opt)
Log($"${optval.Name} -> ${opt.Get(optval.Name)}"$)
tdOptions.Put(optval.Name,opt.Get(optval.Name))
lvOptions.AddTwoLines2(optval.Name,opt.Get(optval.Name),opt)
else if tlo Is UpdateNewMessage Then
Dim newmsg As UpdateNewMessage = tlo
Dim msg As Message = newmsg.Message
Log(msg)
Log(msg.senderUserId)
Log(msg.Content)
'senderUserId = 561471526
If msg.senderUserId = 561471526 Then
End If
else if tlo Is UpdateUser Then
Dim upduser As UpdateUser = tlo
Dim user As TdUser = upduser.User
Log(user.Username)
else if tlo Is UpdateAuthorizationState Then
Dim state2 As UpdateAuthorizationState = tlo
Dim state As AuthorizationState = state2.AuthorizationState
Dim name As String = state.toString
name = name.SubString2(0,name.IndexOf("{")).Trim
Log($"${state.Constructor} -> ${name}"$)
'612103496 -> AuthorizationStateWaitEncryptionKey
If state.Constructor = 612103496 Then
Log("Request for DB-Encryption-Key")
sdk.sendDatabaseEncryptionKey
End If
'306402531 -> AuthorizationStateWaitPhoneNumber
If state.Constructor = 306402531 Then
Log("Requesting Phonenumber...")
' Send Bottoken to login as a Bot...
'sdk.CheckAuthenticationBotToken("561471526:AAFU63ckJ_IJBWM-ilm7q05ycwPL7kKkr0M")
btnPhone.Enabled = True
edtPhonenumber.RequestFocus
End If
'-483510157 -> AuthorizationStateWaitCode
If state.Constructor = -483510157 Then
Log("Requesting Code...")
btnCode.Enabled = True
edtCode.RequestFocus
End If
End If
End Sub