-
Notifications
You must be signed in to change notification settings - Fork 10
/
exampleBot.js
75 lines (70 loc) · 2.34 KB
/
exampleBot.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
const KikClient = require("kik-node-api");
const Kik = new KikClient({
username: "username",
password: "1234",
promptCaptchas: true,
trackUserInfo: true,
trackFriendInfo: true
});
Kik.on("authenticated", () => {
//this is not needed since the client grabs roster automatically once authenticated
/* Kik.getRoster((groups, friends) => {
console.log("We got the roster")
console.log(groups)
console.log(friends)
})*/
});
//alternatively you can use this event for roster
Kik.on("receivedroster", (groups, friends) => {
console.log(groups);
console.log(friends)
});
//alternatively you can use this event for captcha
Kik.on("receivedcaptcha", (captchaUrl) => {
console.log("Please solve captcha" + captchaUrl)
});
Kik.on("receivedjidinfo", (users) => {
console.log("We got peer info:");
console.log(users)
});
/*GROUP EVENTS*/
Kik.on("receivedgroupmsg", (group, sender, msg) => {
console.log(`GROUP:${group.code}: [${sender.displayName}]: ${msg}`)
});
Kik.on("grouptyping", (group, sender, isTyping) => {
if(isTyping){
console.log(`GROUP:${group.code}: ${sender.displayName} is typing...`)
}else{
console.log(`GROUP:${group.code}: ${sender.displayName} stopped typing`)
}
});
Kik.on("userleftgroup", (group, user, kickedBy) => {
console.log(`GROUP:${group.code}: ${user.displayName} left the group`);
//ban anyone once they leave
Kik.setBanned(group.jid, user.jid, true)
});
Kik.on("userjoinedgroup", (group, user, invitedBy) => {
console.log(`GROUP:${group.code}: ${user.displayName} joined the group`);
//kicking anyone once they join
Kik.setGroupMember(group.jid, user.jid, false)
});
/*PRIVATE EVENTS*/
Kik.on("receivedprivatemsg", async (sender, msg) => {
await Kik.sendImage(sender.jid, "path/to/img.png", false, false);
Kik.sendMessage(sender.jid, msg, (delivered, read) => {
if(delivered){
console.log(`PRIVATE: ${sender.jid} PM read`)
}else if(read){
console.log(`PRIVATE: ${sender.jid} PM delivered`)
}
});
console.log(`PRIVATE: [${sender.displayName}]: ${msg}`)
});
Kik.on("privatetyping", (sender, isTyping) => {
if(isTyping){
console.log(`PRIVATE: ${sender.jid} is typing`)
}else{
console.log(`PRIVATE: ${sender.jid} stopped typing`)
}
});
Kik.connect();