-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
86 lines (66 loc) · 2.61 KB
/
app.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
var telegramBot = require('node-telegram-bot-api');
var sentiment = require('sentiment');
var username = require('username');
// pc station-host target.
username().then(username => {
console.log(username);
});
//.
var permission = ['USERadmin001'];
var token ='499098435:AAEdqTCTBAsx6-QqY3msQak-2t5azJYCEUU';
var api = new telegramBot(token, {polling: true});
api.onText(/\/location/, function(msg, match) {
var fromId = msg.from.id;
api.sendLocation(fromId,16.7713834, -3.0167342);
});
api.onText(/\/image/, function(msg, match) {
var fromId = msg.from.id;
api.sendPhoto(fromId,"./images.png");
});
// bot information
api.onText(/\/info/, function(msg, match) {
var fromId = msg.from.id;
api.sendMessage(fromId, "<b>Informazioni Bot</b> \n <i>FactInsideBot</i> \n \n <code>Version 1.5, release data: 01/02/2018, last update data: 21/02/2018</code> \n <a href=\"https://github.com/JuppiJ/TelegramBot-NodeJs\">Github Repo.</a> " ,{parse_mode : "HTML"});
});
// info
// author tool startup
api.onText(/\/author/, function(msg, match) {
var fromId = msg.from.id;
api.sendMessage(fromId, "<b>Informazioni Sviluppatore</b> \n <i>Nicolò Morando</i> \n \n <a href=\"http://www.fuckjupp.com/\">Website.</a> \n <code>Rimani aggiornato per ulteriori versioni.</code>" ,{parse_mode : "HTML"});
});
// author tool end.
// startup bot
api.onText(/\/start/, function(msg, match) {
var fromId = msg.from.id;
api.sendMessage(fromId, "<b>Introduzione</b> \n <i>Fact Inside Bot</i>" +
"\n \n Comandi Disponibili:\n/author\n/vmintelligence\n/info" +
"\nPer rivisualizzare il messaggio:\n/start",{parse_mode : "HTML"});
});
// startup bot end.
var opts = {
reply_markup: JSON.stringify(
{
force_reply: true
}
)};
// intelligence startup
api.onText(/\/vmintelligence/, function(msg, match) {
var fromId = msg.from.id;
api.sendMessage(fromId, "\nScrivimi qualcosa (In inglese) così che io possa darti le mie opinioni.", opts)
.then(function (sended) {
var chatId = sended.chat.id;
var messageId = sended.message_id;
api.onReplyToMessage(chatId, messageId, function (message) {
var sentival = sentiment(message.text)
if (sentival.score < 0) {
api.sendMessage(fromId, "Frase negativa.");
} else if (sentival.score > 0) {
api.sendMessage(fromId, "Frase positiva.");
} else {
api.sendMessage(fromId, "Frase neutrale.");
}
});
});
// intelligence startup end.
});
console.log("bot run. Start conversations in your Telegram.");