forked from daredoes/storybot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.php
54 lines (51 loc) · 2.43 KB
/
bot.php
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
<?php
define("IN_STORYBOT", 1);
require_once("config/config.php");
$snaps = $snapchat->getSnaps(); //get feed
$snaps = json_decode(json_encode($snaps), true); //turn into php array
$i = 0;
if(!$snaps) {
die("Could not establish a connection to Snapchat, or you have no snaps pending! Send one to the account to test.");
}
foreach((array) $snaps as $item) {
if($item['status'] == 1) { //if unopened
if($item['sender'] != $config['username']) { //if not sent from yourself
if(!is_banned($item['sender'])) {
$snapchat->addFriend($item['sender']); //add sender as friend if not already
if($item['media_type'] == 0) { //if still image
if($config['picturesallowed']) {
$data = $snapchat->getMedia($item['id']); //get received snap
if ($data != "") {
if($config['moderation'] == false) {
postManualImage($data, $item['sender']);
saveImage($data, $item['sender'], $item['id'], 1);
} else {
saveImage($data, $item['sender'], $item['id'], 0);
$snapchat->sendMessage($item['sender'], "Your submission has been received! Please be patient while moderators review it.");
}
}
}
} elseif($item['media_type'] == 1) { //if moving video
if($config['videosallowed']) {
$data = $snapchat->getMedia($item['id']); //get received snap
if ($data != "") {
if($config['moderation'] == false) {
postManualVideo($data, $item['sender']);
saveVideo($data, $item['sender'], $item['id'], 1);
} else {
saveVideo($data, $item['sender'], $item['id'], 0);
$snapchat->sendMessage($item['sender'], "Your submission has been received! Please be patient while moderators review it.");
}
}
}
}
$snapchat->markSnapViewed($item['id']); //mark as viewed
$i++; //keep going
} else {
$snapchat->markSnapViewed($item['id']); //mark as viewed
}
}
}
}
$snapchat->clearFeed(); //clear feed (will become VERY long VERY soon and break program)
?>