This repository has been archived by the owner on Jul 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
158 lines (140 loc) · 5.68 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Account Generator Bot
// Copyright (C) 2021 Sadew451 (@Darkridersslk)
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
package main
import (
"fmt"
"math/rand"
"strings"
"strconv"
"time"
"os"
"github.com/PaulSonOfLars/gotgbot/v2"
"github.com/PaulSonOfLars/gotgbot/v2/ext"
"github.com/PaulSonOfLars/gotgbot/v2/ext/handlers"
)
var MSG string
func main() {
// Put Your Bot Token via ENV Vars
b, err := gotgbot.NewBot(os.Getenv("TOKEN"))
if err != nil {
panic("failed to create new bot: " + err.Error())
}
// Create updater and dispatcher.
updater := ext.NewUpdater(b, nil)
dispatcher := updater.Dispatcher
// Handlers for runnning commands.
dispatcher.AddHandler(handlers.NewCommand("start", start))
dispatcher.AddHandler(handlers.NewCommand("gen", gen))
err = updater.StartPolling(b, &ext.PollingOpts{Clean: true})
if err != nil {
panic("failed to start polling: " + err.Error())
}
fmt.Printf("%s has been started...\nMade with ❇️ by @SDBOTs_inifinity (@SDBOTs_inifinity).\n", b.User.Username)
// Idle, to keep updates coming in, and avoid bot stopping.
updater.Idle()
}
func init() {
rand.Seed(time.Now().UnixNano())
}
func randomFormat() string {
formats := []string{
// Put your accounts here
// "email:pass",
// Following are some demo accounts
"sharan.thatsme@gmail.com:ganesha86",
"kushagra.khare04@gmail.com:9450461810",
"gaurav.apt@gmail.com:cashc0w",
"ananthusatheesh89@gmail.com:50thregenesis",
"ankitraghavec2015@gmail.com:akku_8802",
"jasmeetsingh2027@gmail.com:banaliid",
"ashishgupta0586@gmail.com:welcome",
"uferatanyeem@gmail.com:viewsonic20",
}
return formats[rand.Intn(len(formats))]
}
func start(ctx *ext.Context) error {
// To ensure bot does not reply outside of private chats
if ctx.EffectiveChat.Type != "private" {
return nil
}
// Following string is replied to cmd user on /start
MSG = "*Hi %v,\n" +
"I am an Account Generator Bot\n" +
"-------------------------------------------------\n" +
"I can provide premium accounts of different services\n" +
"--------------------------------------------------\n" +
"Do /gen to generate an account\n" +
"--------------------------------------------------\n" +
"❇️Brought to You By @SDBOTs_inifinity❇️\n*"
user := ctx.EffectiveUser
channel_id, cerror := strconv.Atoi(os.Getenv("CHANNEL_ID"))
if cerror != nil {fmt.Println("Please Provide me a valid Channel ID")}
member, eror := ctx.Bot.GetChatMember(int64(channel_id), user.Id)
if eror != nil {
ctx.Bot.SendMessage(ctx.EffectiveChat.Id, "*Bot not admin in JoinCheck Channel.*", nil)
return nil
}
// For Checking either user joined channel or not
if member.Status == "member" || member.Status == "administrator" || member.Status == "creator" {
_, err := ctx.EffectiveMessage.Reply(ctx.Bot, fmt.Sprintf(MSG, user.FirstName), &gotgbot.SendMessageOpts{
ParseMode: "Markdown",
})
if err != nil {
fmt.Println("failed to send: " + err.Error())
}
} else {
// An Error message replied to command user if he's not member of the JoinCheck Channel
ctx.EffectiveMessage.Reply(ctx.Bot, fmt.Sprintf("*You must join %v To use me.*", os.Getenv("CHANNEL_USERNAME")), &gotgbot.SendMessageOpts{ParseMode: "Markdown"})
}
if strings.ToLower(os.Getenv("LOGS")) != "false"{
logs, log_err := strconv.Atoi(os.Getenv("LOGS"))
if log_err != nil{fmt.Println(log_err.Error())}
// Following message is sent in Logs Group (if set)
ctx.Bot.SendMessage(int64(logs), fmt.Sprintf("#Start\n\nBot Started By %v(%v)", user.FirstName, user.Id), nil)
}
return nil
}
func gen(ctx *ext.Context) error {
// To ensure bot does not reply outside of private chats
if ctx.EffectiveChat.Type != "private" {
return nil
}
Combo := strings.Split(randomFormat(), ":")
// Following string is replied to cmd user on /gen
MSG = "𝙃𝙚𝙧𝙚 𝙄𝙨 𝙔𝙤𝙪𝙧 %v 𝘼𝙘𝙘𝙤𝙪𝙣𝙩" +
"\n\n𝙀𝙢𝙖𝙞𝙡: `%v`" +
"\n𝙋𝙖𝙨𝙨: `%v`" +
"\n𝙂𝙚𝙣𝙚𝙧𝙖𝙩𝙚𝙙 𝘽𝙮: *%v*" +
"\n\n𝙏𝙝𝙖𝙣𝙠 𝙮𝙤𝙪 𝙛𝙤𝙧 𝙪𝙨𝙞𝙣𝙜 𝙢𝙚!\n❇️𝙎𝙝𝙖𝙧𝙚 & 𝙎𝙪𝙥𝙥𝙤𝙧𝙩 *%v*❇️"
user := ctx.EffectiveUser
channel_id, cerror := strconv.Atoi(os.Getenv("CHANNEL_ID"))
if cerror != nil {fmt.Println("Please Provide me a valid Channel ID")}
member, eror := ctx.Bot.GetChatMember(int64(channel_id), user.Id)
if eror != nil {
ctx.Bot.SendMessage(ctx.EffectiveChat.Id, "Bot not admin in JoinCheck Channel", nil)
return nil
}
// For Checking either user joined channel or not
if member.Status == "member" || member.Status == "administrator" || member.Status == "creator" {
_, err := ctx.EffectiveMessage.Reply(ctx.Bot, fmt.Sprintf(MSG, os.Getenv("ACC_NAME"), Combo[0], Combo[1], user.FirstName, os.Getenv("CHANNEL_USERNAME")), &gotgbot.SendMessageOpts{
ParseMode: "Markdown",
})
if err != nil {
fmt.Println("failed to send: " + err.Error())
}
} else {
// An Error message replied to command user if he's not member of the JoinCheck Channel
ctx.EffectiveMessage.Reply(ctx.Bot, fmt.Sprintf("*You must join %v to use me.*", os.Getenv("CHANNEL_USERNAME")), &gotgbot.SendMessageOpts{ParseMode: "Markdown"})
}
if strings.ToLower(os.Getenv("LOGS")) != "false"{
logs, log_err := strconv.Atoi(os.Getenv("LOGS"))
if log_err != nil{fmt.Println(log_err.Error())}
// Following message is sent in Logs Group (if set)
ctx.Bot.SendMessage(int64(logs), fmt.Sprintf("#AccClaimed\n\n%v generated a new account.", user.FirstName), nil)
}
return nil
}