-
Notifications
You must be signed in to change notification settings - Fork 1
/
shiori_events.c
74 lines (71 loc) · 2.23 KB
/
shiori_events.c
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
#include <string.h>
#include <time.h>
#include <stdlib.h>
bool shiori_load(const char* dirpath){
return true;
}
bool shiori_unload(void){
return true;
}
struct cshiori_response_message* shiori_request(struct cshiori_request_message* req, struct cshiori_response_message* res){
static int aitalk_count = 0;
res->version = "3.0";
res->sender = "cshiori";
res->charset = "Shift_JIS";
if(req->method == NOTIFY){
res->status_code = 204;
return res;
}
if(req->id == NULL){
return NULL;
}
if(0 == strcmp(req->id, "version")){
res->status_code = 200;
res->value = "0.0.1";
}else if(0 == strcmp(req->id, "name")){
res->status_code = 200;
res->value = "cshiori";
}else if(0 == strcmp(req->id, "craftman")){
res->status_code = 200;
res->value = "Narazaka";
}else if(0 == strcmp(req->id, "craftmanw")){
res->status_code = 200;
res->value = "奈良阪某";
}else if(0 == strcmp(req->id, "OnFirstBoot")){
res->status_code = 200;
res->value = "\\h\\s[0]初回起動。\\e";
}else if(0 == strcmp(req->id, "OnBoot")){
res->status_code = 200;
res->value = "\\h\\s[0]起動。\\e";
}else if(0 == strcmp(req->id, "OnGhostChanged")){
res->status_code = 200;
res->value = "\\h\\s[0]交代。\\e";
}else if(0 == strcmp(req->id, "OnGhostChanging")){
res->status_code = 200;
res->value = "\\h\\s[0]交代。\\e";
}else if(0 == strcmp(req->id, "OnSecondChange")){
aitalk_count ++;
if(aitalk_count == 90){
static char* const aitalks[] = {
"\\h\\s[0]C言語って、\\w4胸キュン?\\e",
"\\h\\s[5]MiyoJSもよろしく。\\e",
"\\h\\s[0]C++だとconst char*なリテラルをchar*に入れるなっていう警告が出るけど、\\w9\\s[8]まあコンパイルとおるからいいよね?\\e",
"\\h\\s[0]古いVC++ではstdbool.hがなくてコンパイルできないから、\\w9\\s[8]マクロでbool定めてるっていう……。\\e",
"\\h\\s[6]あとの実装はキミしだい。\\e"
};
static const size_t aitalks_length = 5;
aitalk_count = 0;
srand((unsigned)time(NULL));
res->status_code = 200;
res->value = aitalks[rand() % aitalks_length];
}else{
res->status_code = 204;
}
}else if(0 == strcmp(req->id, "OnClose")){
res->status_code = 200;
res->value = "\\h\\s[0]終了。\\w9\\-";
}else{
return NULL;
}
return res;
}