uzi_telegram-parser 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -0
- package/myModule/seriMessage.js +129 -0
- package/package.json +11 -0
- package/readme.md +0 -0
package/index.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
module.exports = (myBot, m) => {
|
|
2
|
+
let fc = {}
|
|
3
|
+
|
|
4
|
+
//for global
|
|
5
|
+
fc.from = m.chat.id //id chat
|
|
6
|
+
|
|
7
|
+
//message
|
|
8
|
+
fc.messageId = m.message_id
|
|
9
|
+
fc.messageType = m.photo ? "photo" :
|
|
10
|
+
m.video ? "video" :
|
|
11
|
+
m.document ? "document" :
|
|
12
|
+
m.location ? "location" :
|
|
13
|
+
m.venue ? "location spesific" :
|
|
14
|
+
m.contact ? "contact" :
|
|
15
|
+
m.audio ? "audio" :
|
|
16
|
+
m.voice ? "voice" :
|
|
17
|
+
m.video_note ? "video note" :
|
|
18
|
+
m.text ? "text" :
|
|
19
|
+
"undefined type"
|
|
20
|
+
fc.messageTime = m.date
|
|
21
|
+
fc.messageText = m.text || m.caption || ""
|
|
22
|
+
|
|
23
|
+
//chat
|
|
24
|
+
fc.chatType = m.chat.type
|
|
25
|
+
|
|
26
|
+
//pribadi pengirim
|
|
27
|
+
fc.userFirstName = m.from.first_name
|
|
28
|
+
fc.userUsername = m.from.username || ""
|
|
29
|
+
fc.userId = m.from.id
|
|
30
|
+
fc.userLang = m.from.language_code
|
|
31
|
+
fc.userIsBot = m.from.is_bot
|
|
32
|
+
|
|
33
|
+
// jika adalah grup
|
|
34
|
+
if(fc.chatType != "private"){
|
|
35
|
+
fc.groupId = m.chat.id
|
|
36
|
+
fc.groupName = m.chat.title
|
|
37
|
+
fc.groupUsername = m.chat.username || ""
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//kalau pesan adalah foto
|
|
41
|
+
if(fc.messageType == "photo"){
|
|
42
|
+
let ses = m.photo[m.photo.length - 1]
|
|
43
|
+
fc.photo_file_id = ses.file_id
|
|
44
|
+
fc.photo_size_byte = ses.file_size
|
|
45
|
+
fc.photo_size_kilobyte = ses.file_size / 1024
|
|
46
|
+
fc.photo_size_megabyte = ses.file_size / 1024 / 1024
|
|
47
|
+
fc.photo_width = ses.width
|
|
48
|
+
fc.photo_height = ses.height
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//kalau pesan adalah video
|
|
52
|
+
if(fc.messageType == "video"){
|
|
53
|
+
fc.video_duration = m.video.duration
|
|
54
|
+
fc.video_height = m.video.height
|
|
55
|
+
fc.video_width = m.video.width
|
|
56
|
+
fc.video_mime_type = m.video.mime_type
|
|
57
|
+
fc.video_file_id = m.video.file_id
|
|
58
|
+
fc.video_size_byte = m.video.file_size
|
|
59
|
+
fc.video_size_kilobyte = m.video.file_size / 1024
|
|
60
|
+
fc.video_size_megabyte = m.video.file_size / 1024 / 1024
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//kalau pesan itu dokumen
|
|
64
|
+
if(fc.messageType == "document"){
|
|
65
|
+
fc.doc_file_name = m.document.file_name
|
|
66
|
+
fc.doc_mime_type = m.document.mime_type
|
|
67
|
+
fc.doc_file_id = m.document.file_id
|
|
68
|
+
fc.doc_size_byte = m.document.file_size
|
|
69
|
+
fc.doc_size_kilobyte = m.document.file_size / 1024
|
|
70
|
+
fc.doc_size_megabyte = m.document.file_size / 1024 / 1024
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//kalau pesan ada locatiom
|
|
74
|
+
if(fc.messageType == "location"){
|
|
75
|
+
fc.loc_latitude = m.location.latitude
|
|
76
|
+
fc.loc_longitude = m.location.longitude
|
|
77
|
+
fc.loc_liveTimes = m.location.live_period
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//kalau lokasi spesifik
|
|
81
|
+
if(fc.messageType == "location spesific"){
|
|
82
|
+
fc.loc_latitude = m.venue.location.latitude
|
|
83
|
+
fc.loc_longitude = m.venue.location.longitude
|
|
84
|
+
fc.loc_title = m.venue.title
|
|
85
|
+
fc.loc_address = m.venue.address
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if(fc.messageType == "contact"){
|
|
89
|
+
fc.contact_number = m.contact.phone_number
|
|
90
|
+
fc.contact_first_name = m.contact.first_name
|
|
91
|
+
fc.contact_vcard = m.contact.vcard
|
|
92
|
+
fc.contact_user_id_telegram = m.contact.user_id
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// kalau file audio/music
|
|
96
|
+
if(fc.messageType == "audio"){
|
|
97
|
+
fc.audio_duration = m.audio.duration
|
|
98
|
+
fc.audio_file_name = m.audio.file_name
|
|
99
|
+
fc.audio_mime_type = m.audio.mime_type
|
|
100
|
+
fc.audio_title = m.audio.title
|
|
101
|
+
fc.audio_performer = m.audio.performer
|
|
102
|
+
fc.audio_file_id = m.audio.file_id
|
|
103
|
+
fc.audio_size_byte = m.audio.file_size
|
|
104
|
+
fc.audio_size_kilobyte = m.audio.file_size / 1024
|
|
105
|
+
fc.audio_size_megabyte = m.audio.file_size / 1024 / 1024
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//kalau voice note
|
|
109
|
+
if(fc.messageType == "voice"){
|
|
110
|
+
fc.voice_duration = m.voice.duration
|
|
111
|
+
fc.voice_mime_type = m.voice.mime_type
|
|
112
|
+
fc.voice_file_id = m.voice.file_id
|
|
113
|
+
fc.voice_size_byte = m.voice.file_size
|
|
114
|
+
fc.voice_size_kilobyte = m.voice.file_size / 1024
|
|
115
|
+
fc.voice_size_megabyte = m.voice.file_size / 1024 / 1024
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//kalau video note
|
|
119
|
+
if(fc.messageType == "video note"){
|
|
120
|
+
fc.vidnot_duration = m.video_note.duration
|
|
121
|
+
fc.vidnot_length = m.video_note.length
|
|
122
|
+
fc.vidnot_file_id = m.video_note.file_id
|
|
123
|
+
fc.vidnot_size_byte = m.video_note.file_size
|
|
124
|
+
fc.vidnot_size_kilobyte = m.video_note.file_size / 1024
|
|
125
|
+
fc.vidnot_size_megabyte = m.video_note.file_size / 1024 / 1024
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return fc
|
|
129
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uzi_telegram-parser",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "This module is for parser message event on module node-telegram-bot-api",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "Pak Uzi",
|
|
10
|
+
"license": "ISC"
|
|
11
|
+
}
|
package/readme.md
ADDED
|
File without changes
|