Mustaqil ish
Mavzu: Telegram API dan foydalanib bot orqali telegram guruhiga yoki kanalga post qilish,xabarlarni tahrirlash funksiyalariga ega bo`lgan dastur yaratish.
Bu bot go-telegram-bot-api da yaratilgan bo`lib, uning vazifasi guruhdagi foydalanuvchilar ro`yxatini ko`rish foydalanuvchilar haqida ma`lumot olishdir
Botda xozircha 6 ta bo`limimiz bor
Rasm bo`limini bosganimizda guruh rasmini chiqaradi
Botga reklama joylashtirish ham mumkin.Bunda reklama beruvchi bot adminiga murojat qiladi
Bu bo`limimzda Diplomlarimiz haqida ma`lumot joylashtiriladi (biz hali diplom olmadik)
Ro`yxat bo`limida guruhimizning to`liq ro`yhati shakillantirilgan
package main
import (
"log"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)
var numericKeyboard = tgbotapi.NewReplyKeyboard(
tgbotapi.NewKeyboardButtonRow(
tgbotapi.NewKeyboardButton("Biz_haqimizda"),
tgbotapi.NewKeyboardButton("Rasimlar"),
tgbotapi.NewKeyboardButton("Reklama"),
),
tgbotapi.NewKeyboardButtonRow(
tgbotapi.NewKeyboardButton("Pasportlarimiz"),
tgbotapi.NewKeyboardButton("Dilomlarimiz"),
tgbotapi.NewKeyboardButton("Ruyxat"),
),
)
func main() {
bot, err := tgbotapi.NewBotAPI("2024735399:AAGJwIKt181lUx3Tq5h10-kwdfK4qJEVkLc")
if err != nil {
log.Panic(err)
}
bot.Debug = true
log.Printf("Authorized on account %s", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
switch update.Message.Text {
case "/start":
msg.ReplyMarkup = numericKeyboard
case "/close":
msg.ReplyMarkup = tgbotapi.NewRemoveKeyboard(true)
}
if update.Message == nil { // ignore non-Message updates
continue
}
switch update.Message.Text {
case "Biz_haqimizda":
msgg := tgbotapi.NewMessage(update.Message.Chat.ID, "Biz 219 18 guruppamiz ")
bot.Send(msgg)
case "Rasimlar":
file := "./guruppa.jpg"
imsg := tgbotapi.NewPhotoUpload(update.Message.Chat.ID, file)
bot.Send(imsg)
case "Reklama":
tel := tgbotapi.NewMessage(update.Message.Chat.ID, "Bizda reklama pullik")
bot.Send(tel)
case "Pasportlarimiz":
tel := tgbotapi.NewMessage(update.Message.Chat.ID, "Hali passport haqida malumot bera olmaymiz")
bot.Send(tel)
case "Dilomlarimiz":
tel := tgbotapi.NewMessage(update.Message.Chat.ID, "Hali olmadik olsak sizga nusxasini beramiz")
bot.Send(tel)
case "Ruyxat":
file2 := "./jurnal.jpg"
imsg2 := tgbotapi.NewPhotoUpload(update.Message.Chat.ID, file2)
bot.Send(imsg2)
}
}
}
Dostları ilə paylaş: |