-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot2.js
181 lines (149 loc) · 5.45 KB
/
bot2.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env node
const TeleBot = require('telebot');
var dateFormat = require('dateformat');
var newSet = require('./config.js');
var randomstring = require('./randomstring.js');
const where = './pics/';
bot = new TeleBot(newSet);
function is_dir(path) {
var fs = require('fs');
try {
console.log(fs.lstatSync(path+'/').isFile());
return true;
} catch (e) {
return false;
}
}
function choosePic(what, chat_id, requester_name, requester_id) {
//var when = new Date(Date.now());
var now = new Date();
var fs = require('fs');
var arr = [
// -1001314628360, // test4
123
];
if (is_dir(where+what)) {
var files = fs.readdirSync(where+what);
var chosenFile = where + what +'/'+ files[Math.floor(Math.random() * files.length)]
}
else {
var chosenFile = where + what;
}
if (arr.includes(chat_id)) {
return '';
} else {
bot.getChat(chat_id).then(function(data) {
if (data.username != undefined) {chat_name = data.username} else {chat_name = data.title;}
console.log(dateFormat(now, "yyyy-mm-dd HH:MM:ss o") +' sent ' + chosenFile +
'\nto \@' + chat_name + ' \['+ chat_id + '\] by request of ' + requester_name + ' \[' + requester_id +'\]');
});
return chosenFile;
};
}
bot.on(/(xaxaxa)/, (msg) => {
let say = new randomstring('./strings1.txt');
msg.reply.text(say.processFile());
})
bot.on(/(update)/, (msg) => {
if (msg.from.id=29884911) {
const execSync = require('child_process').execSync;
var cmd1 = execSync('git pull',
(error, stdout, stderr) => {
state = 'STDOUT: ' + stdout +'\n STDERR:' + stderr + '\n ERR: '+ error;
console.log(state);
console.log('bot updated')
});
return msg.reply.text(cmd1, { asReply: true });
} else { return '';}});
bot.on(/(restart)/, (msg) => {
if (msg.from.id=29884911) {
const execSync = require('child_process').execSync;
var cmd2 = execSync('forever restart bot2.js --no-colors',
(error, stdout, stderr) => {
state = 'STDOUT: ' + stdout +'\nSTDERR:' + stderr + '\nERR: '+ error;
console.log(state);
console.log('bot restarted')
});
return msg.reply.text(cmd2);
} else { return '';}});
bot.on(/(!to)/, (msg) => {
if (msg.from.id=29884911) {
let whereToSend = msg.text.split(';').slice(1,2).join(' ');
let whatToSend = msg.text.split(';').slice(2).join(' ');
return bot.sendMessage(whereToSend,whatToSend);
// return bot.sendMessage(29884911,'where->'+whereToSend+' what->'+whatToSend);
} else { return '';}});
bot.on(/(ниа)/i, (msg) => {
return msg.reply.text('пидарасы!',{ asReply: true });
});
bot.on('newChatMembers', (msg) =>
{
if (msg.new_chat_member.username) {
let say = new randomstring('./hello.txt');
msg.reply.text('@'+msg.new_chat_member.username+' '+say.processFile(),{ asReply: false });
}
else {
let say = new randomstring('./hello.txt');
msg.reply.text(msg.new_chat_member.first_name+', '+say.processFile(),{ asReply: true });
}
}
);
bot.on('leftChatMember', (msg) =>
{
if (msg.left_chat_member.username) {
msg.reply.text('Милорд, у нас побег! @'+msg.left_chat_member.username+' слился!',{ asReply: true });
}
else {
msg.reply.text('Милорд, у нас побег! '+msg.left_chat_member.first_name+' слился!',{ asReply: true });
}
}
);
// bot.on('edit', (msg) => {
// return msg.reply.text('орфографию исправлял?', { asReply: true });
// });
bot.on(/^(exact\soption\?|another_option|да\sили\sнет\?)/, (msg) => {
return msg.reply.photo(choosePic('yesno',msg.chat.id,msg.from.username,msg.from.id), { asReply: true });
});
bot.on(/(арбайт)/i, (msg) => {
return msg.reply.photo(choosePic('arbeit',msg.chat.id,msg.from.username,msg.from.id), { asReply: true });
});
bot.on(/(попа\s|жопа|задница)/i, (msg) => {
return msg.reply.photo(choosePic('popki',msg.chat.id,msg.from.username,msg.from.id), { asReply: true });
});
bot.on(/(сиси|сиськи|тити)/i, (msg) => {
return msg.reply.photo(choosePic('siski',msg.chat.id,msg.from.username,msg.from.id),{ asReply: true });
});
bot.on(/(пизду)/i, (msg) => {
return msg.reply.photo(choosePic('piski',msg.chat.id,msg.from.username,msg.from.id),{ asReply: true });
});
bot.on(/(мальчика)/i, (msg) => {
return msg.reply.photo(choosePic('guys',msg.chat.id,msg.from.username,msg.from.id),{ asReply: true });
});
bot.on(/(девачку)/i, (msg) => {
return msg.reply.photo(choosePic('full',msg.chat.id,msg.from.username,msg.from.id),{ asReply: true });
});
bot.on(/(коробки)/i, (msg) => {
return msg.reply.photo(choosePic('single/korobki.jpg',msg.chat.id,msg.from.username,msg.from.id),{ asReply: true });
});
bot.on(/(сколько\sрейдов|наркоман)/i, (msg) => {
return bot.sendDocument(
msg.chat.id,
choosePic('single/nrkmn.mp4',msg.chat.id,msg.from.username,msg.from.id),
{replyToMessage: msg.message_id}
)
});
bot.on(/(рейдим\sтира|рэйдим\sтира|на\sтира)/i, (msg) => {
return bot.sendDocument(
msg.chat.id,
choosePic('single/tyr.mp4',msg.chat.id,msg.from.username,msg.from.id),
{replyToMessage: msg.message_id}
)
});
bot.on(/(стродать)/i, (msg) => {
return msg.reply.photo(choosePic('strodat',msg.chat.id,msg.from.username,msg.from.id),{ asReply: true });
});
bot.start();
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});