forked from niawjunior/telegram-bot-airdrop.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
112 lines (99 loc) · 4.33 KB
/
index.js
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
const TelegramBot = require('node-telegram-bot-api');
var config = require('./config')
var firebase = require('firebase')
var firebase_config = config.firebase_config;
var token = config.token;
firebase.initializeApp(firebase_config);
const bot = new TelegramBot(token, {polling: true});
const img_url = 'https://cryptoverze-0m5mfism.netdna-ssl.com/wp-content/uploads/2018/04/cryptocurrency-airdrop-2.png'
var t_username = '';
var u_email = '';
var e_wallet = '';
bot.onText(/\/start/, (msg) => {
bot.sendPhoto(msg.chat.id,img_url,{caption : "Welcome to Domeno Airdrop! 😍😍 \nPlease join our community and get 100 token.\n \n "}).then(() => {
var option = {
"reply_markup": {
"keyboard": [["1. Join the Domeno Telegram group", "2. Your Telegram Username"], ["3. E-mail address" , "4. ETH address (No exchange wallet!)"]]
}
};
bot.sendMessage(msg.chat.id,"Airdrop Rules ⚔️⚔️\n 1. Join the Domeno Telegram group \n 2. Your Telegram Username \n 3. E-mail address \n 4. ETH address (No exchange wallet!) \n",option);
})
})
bot.on('message', (msg) => {
var send_text = msg.text;
var step1_text = '1. Join the Domeno Telegram group'
if (send_text.toString().indexOf(step1_text) === 0) {
var text = 'Domeno Telegram Group';
var keyboardStr = JSON.stringify({
inline_keyboard: [
[
{text:'Join the chat',url:'https://t.me/joinchat/FP5H8RIFast0BbjwqiO1_w'}
]
]
});
var keyboard = {reply_markup: JSON.parse(keyboardStr)};
bot.sendMessage(msg.chat.id,text,keyboard);
}
var step2_text = '2. Your Telegram Username';
if (send_text.toString().indexOf(step2_text) === 0) {
bot.sendMessage(msg.chat.id, "Please Enter Your Telegram Username (@username)")
}
if(send_text.toString().charAt(0) === '@') {
t_username = send_text;
bot.sendMessage(msg.chat.id, "Hello "+send_text);
}
var step3_text = '3. E-mail address';
if(send_text.toString().indexOf(step3_text) === 0) {
bot.sendMessage(msg.chat.id, "Enter your email address")
}
var re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm;
if(re.test(send_text)) {
u_email = send_text;
bot.sendMessage(msg.chat.id, "Email address: "+send_text);
}
var step4_text = '4. ETH address (No exchange wallet!)';
if(send_text.toString().indexOf(step4_text) === 0) {
bot.sendMessage(msg.chat.id, "Make sure that you have an erc20 wallet (0x) 🔑")
}
var re_eth = /^0x[a-fA-F0-9]{40}$/g
if(re_eth.test(send_text)) {
e_wallet = send_text;
bot.sendMessage(msg.chat.id, 'Confirm❓', {
reply_markup: {
keyboard: [
[{"text": "Yes ✅"}],
[{"text": "Cancel ❌"}]
],
resize_keyboard: true
}
})
}
var confirm = 'Yes ✅';
if(send_text.toString().indexOf(confirm) === 0) {
var db = firebase.database().ref('Airdrop');
db.child(e_wallet.toLocaleLowerCase()).once('value', snap => {
if(!snap.exists()) {
db.child(e_wallet.toLocaleLowerCase()).update({
telegram_username: t_username,
email: u_email,
wallet: e_wallet.toLocaleLowerCase(),
status: 'pending',
createAt: Date.now()
}).then(() => {
bot.sendMessage(msg.chat.id, "Thank'you 🙏🙏 \n");
bot.sendMessage(msg.chat.id, `Telegram username: ${t_username} \n Email: ${u_email} \n Ethereum wallet: ${e_wallet} \n`).then(() => {
bot.sendMessage(msg.chat.id, "Check your account 👉 "+ 'https://niawjunior.github.io/telegram-bot-airdrop.io/index.html?id='+e_wallet.toLocaleLowerCase())
})
}).catch((err) => {
console.log(err)
})
} else {
bot.sendMessage(msg.chat.id, "This wallet is already in use")
}
})
}
var calcel = 'Cancel ❌';
if(send_text.toString().indexOf(calcel) === 0) {
bot.sendMessage(msg.chat.id, "Good bye ✌️✌️");
}
});