-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathImageBot.php
More file actions
158 lines (146 loc) · 4.93 KB
/
ImageBot.php
File metadata and controls
158 lines (146 loc) · 4.93 KB
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
<?php
require_once 'TelegramBot.php';
/*
https://www.94cb.com/Telegram-Simple-Image-Bot/webhook.php
{
"message": {
"chat": {
"id": 12450
},
"text": "/pic @canbin_bot"
}
}
*/
class ImageBot extends TelegramBot {
public function init() {
parent::init();
}
}
class ImageBotChat extends TelegramBotChat {
private $responseTable = array(
'碎叫' => array('text'=>'晚安'),
'睡觉' => array('text'=>'晚安'),
'睡了' => array('text'=>'晚安'),
//'买' => array('photo'=>'buy'),
'好污' => array(
'photo'=>'images',
'text'=>'
👌👉🏿👌👌👌👌👌👌👌👌👌👌
👌👌👉🏿👌👌👉🏿👉🏿👉🏿👉🏿👉🏿👉🏿👌
👌👌👌👌👌👌👌👌👌👌👌👌
👉🏿👌👌👌👌👌👌👌👌👌👌👌
👌👉🏿👌👌👉🏿👉🏿👉🏿👉🏿👉🏿👉🏿👉🏿👉🏿
👌👌👌👌👌👌👉🏿👌👌👌👌👌
👌👌👉🏿👌👌👌👉🏿👌👌👌👌👌
👌👉🏿👌👌👌👉🏿👉🏿👉🏿👉🏿👉🏿👉🏿👌
👉🏿👉🏿👌👌👌👌👌👌👌👌👉🏿👌
👌👉🏿👌👌👌👌👌👌👌👌👉🏿👌
👌👉🏿👌👌👌👌👉🏿👌👌👉🏿👌👌
👌👉🏿👌👌👌👌👌👉🏿👉🏿👌👌👌
'),
'噫!' => array('text'=>'
🌚🌚🌚🌚🌚🌚🌚🌚🌚🌚🌝🌚🌚🌚🌚🌚
🌚🌚🌚🌚🌚🌚🌚🌚🌚🌚🌚🌝🌚🌚🌝🌚
🌚🌝🌝🌝🌝🌚🌝🌝🌝🌝🌝🌝🌝🌝🌝🌝
🌚🌝🌚🌚🌝🌚🌚🌚🌝🌚🌚🌚🌚🌝🌚🌚
🌚🌝🌚🌚🌝🌚🌚🌚🌚🌝🌚🌚🌝🌚🌚🌚
🌚🌝🌚🌚🌝🌚🌝🌝🌝🌝🌝🌝🌝🌝🌝🌝
🌚🌝🌚🌚🌝🌚🌚🌚🌚🌚🌚🌚🌚🌚🌚🌚
🌚🌝🌚🌚🌝🌚🌚🌝🌝🌝🌝🌝🌝🌝🌝🌚
🌚🌝🌚🌚🌝🌚🌚🌝🌚🌚🌚🌚🌚🌚🌝🌚
🌚🌝🌝🌝🌝🌚🌚🌝🌝🌝🌝🌝🌝🌝🌝🌚
🌚🌝🌚🌚🌝🌚🌚🌝🌚🌚🌚🌚🌚🌚🌝🌚
🌚🌝🌚🌚🌚🌚🌚🌝🌝🌝🌝🌝🌝🌝🌝🌚
🌚🌚🌚🌚🌚🌚🌝🌚🌝🌚🌝🌚🌚🌚🌚🌝
🌚🌚🌚🌚🌚🌚🌝🌚🌝🌚🌚🌝🌚🌝🌚🌚
🌚🌚🌚🌚🌚🌝🌚🌚🌝🌚🌚🌚🌚🌝🌚🌚
🌚🌚🌚🌚🌚🌚🌚🌚🌚🌝🌝🌝🌝🌝🌚🌚'),
/*
'噫'=> array('text'=>'
🌚🌚🌚🌚🌚🌚🌚🌝🌚🌚🌚🌚
🌝🌝🌝🌚🌝🌝🌝🌝🌝🌝🌝🌚
🌝🌚🌝🌚🌚🌝🌚🌚🌝🌚🌚🌚
🌝🌚🌝🌝🌝🌝🌝🌝🌝🌝🌝🌝
🌝🌚🌝🌚🌝🌚🌚🌚🌚🌝🌚🌚
🌝🌚🌝🌚🌝🌝🌝🌝🌝🌝🌚🌚
🌝🌚🌝🌚🌝🌚🌚🌚🌚🌝🌚🌚
🌝🌝🌝🌚🌝🌝🌝🌝🌝🌝🌚🌚
🌝🌚🌝🌚🌚🌝🌚🌝🌚🌚🌚🌚
🌚🌚🌚🌚🌝🌝🌚🌚🌝🌚🌝🌚
🌚🌚🌚🌝🌚🌝🌚🌚🌚🌝🌚🌝
🌚🌚🌚🌚🌚🌚🌝🌝🌝🌝🌚🌚
'),
*/
'😂😂😂' => array('text'=>'😂😂😂')
);
public function __construct($core, $chat_id) {
parent::__construct($core, $chat_id);
}
public function init() {
}
public function some_command($command, $params, $message) {
switch ($command) {
case 'start':
case 'help':
$this->apiSendMessage("我是一个脱离了高级趣味的Bot. /pic or /hentai ");
break;
case 'about':
$this->apiSendMessage("https://github.com/lincanbin");
break;
case 'yi':
$this->apiSendMessage($this->responseTable['噫!']['text']);
break;
case 'pic':
$this->returnPicture($this->getRandomPictureObject("images"));
break;
case 'hentai':
case 'cg':
$this->returnPicture($this->getRandomPictureObject("cg"));
break;
default:
//$this->returnPicture($this->getRandomPictureObject("images"));
break;
}
return;
}
public function message($text, $message) {
/*
$reply_string = file_get_contents('./reply.txt', FILE_USE_INCLUDE_PATH);
if($reply_string){
$this->apiSendMessage($reply_string);
file_put_contents('./reply.txt', "");
}
*/
foreach ($this->responseTable as $key => $value) {
if(strpos($text, $key) !== false){
if(isset($value['photo'])){
$this->returnPicture($this->getRandomPictureObject($value['photo']));
sleep(5);
}
if(isset($value['text'])){
$this->apiSendMessage($value['text']);
}
break;
}
}
return;
}
private function getRandomPictureObject($dir_name){
$image_list = scandir(__DIR__ . "/". $dir_name);
$image_path = realpath($dir_name . "/" . $image_list[mt_rand(2, (count($image_list)-1))]);
$image_object = new CURLFile($image_path);
error_log($image_path . "\n\n", 3, __DIR__ . "/my-errors.log");
return $image_object;
}
private function returnPicture($image_object){
$this->core->request('sendPhoto',
array(
'chat_id' => $this->chatId,
'photo' => $image_object
),
array(
'http_method' => 'POST'
)
);
}
}