Posted on Leave a comment

Using VB.net to get Telegram Contact from Group

To get Telegram contacts from a group using VB.NET, you can utilize the Telegram.Bot library, which provides a wrapper around the Telegram Bot API. Here’s an example of how you can achieve this:

1. Install the Telegram.Bot package via NuGet in your VB.NET project.

2. Import the necessary namespaces in your code file:

Imports Telegram.Bot
Imports Telegram.Bot.Args
Imports Telegram.Bot.Types
Imports Telegram.Bot.Types.Enums

3. Set up the Telegram Bot client and authenticate with your bot token:

Dim botToken As String = "YOUR_BOT_TOKEN"
Dim botClient As New TelegramBotClient(botToken)

4. Create an event handler for the OnMessage event to receive messages from the group:

AddHandler botClient.OnMessage, AddressOf OnMessageReceived

5. Implement the event handler to process incoming messages:

Private Sub OnMessageReceived(sender As Object, e As MessageEventArgs)
    Dim message As Message = e.Message

    If message.Type = MessageType.Text Then
        ' Process text messages
        Dim chatId As Long = message.Chat.Id
        Dim senderName As String = message.From.Username
        Dim messageText As String = message.Text

        ' Check if the message is from the group
        If message.Chat.Type = ChatType.Group Then
            ' Access the list of group members
            Dim groupChat As Chat = CType(message.Chat, GroupChat)
            Dim members As User() = groupChat.ChatMembers.ToArray()

            ' Process the members' information
            For Each member As User In members
                Dim memberId As Integer = member.Id
                Dim memberUsername As String = member.Username
                Dim memberFirstName As String = member.FirstName
                Dim memberLastName As String = member.LastName

                ' Do something with the member information
                ' For example, add it to a list or store it in a database
            Next
        End If
    End If
End Sub

6. Start the bot client to begin receiving messages:

botClient.StartReceiving()

Remember to replace "YOUR_BOT_TOKEN" with your actual bot token obtained from the BotFather on Telegram. You also need to adapt the code to store or process the retrieved member information as per your requirements.

Please note that the example assumes you already have a bot created on Telegram and added it to the desired group.

Posted on Leave a comment

Hello world! Projects

Welcome to Hello World of codes.

The key word for all kinds of programmers is Hello World. It is a word for achieving their future goals as a computer programmer. It has energy, it is enormous because it shows that everyone can do it. It was also a word of encouragement when his first task was accomplished, such as showing the word Hello Wolrd on the screen for the first time when he started coding.

HTML

<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>Hello World Projects</p>
</body>
</html>

PHP

<?php

echo "Hello World Projects";

?>

VB.net

messageBox.show ("Hello World") //or
console.writeLine ("Hello World")

What is your Hello World?

In real life, the word Hello World is definitely the most important turning point in everyone’s life, right?