diff options
-rw-r--r-- | .gitmodules | 9 | ||||
-rw-r--r-- | CMakeLists.txt | 18 | ||||
-rw-r--r-- | data.txt | 260 | ||||
m--------- | vendor/libtwittercpp | 0 | ||||
m--------- | vendor/twitcurl | 0 | ||||
m--------- | vendor/verbly | 0 | ||||
m--------- | vendor/yaml-cpp | 0 | ||||
-rw-r--r-- | yandere.cpp | 194 |
8 files changed, 204 insertions, 277 deletions
diff --git a/.gitmodules b/.gitmodules index 08a42de..78fd03a 100644 --- a/.gitmodules +++ b/.gitmodules | |||
@@ -1,9 +1,6 @@ | |||
1 | [submodule "vendor/verbly"] | ||
2 | path = vendor/verbly | ||
3 | url = https://github.com/hatkirby/verbly | ||
4 | [submodule "vendor/twitcurl"] | ||
5 | path = vendor/twitcurl | ||
6 | url = https://github.com/swatkat/twitcurl | ||
7 | [submodule "vendor/yaml-cpp"] | 1 | [submodule "vendor/yaml-cpp"] |
8 | path = vendor/yaml-cpp | 2 | path = vendor/yaml-cpp |
9 | url = https://github.com/jbeder/yaml-cpp | 3 | url = https://github.com/jbeder/yaml-cpp |
4 | [submodule "vendor/libtwittercpp"] | ||
5 | path = vendor/libtwittercpp | ||
6 | url = https://github.com/hatkirby/libtwittercpp | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d19b9..94776f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -1,17 +1,13 @@ | |||
1 | cmake_minimum_required (VERSION 3.1) | 1 | cmake_minimum_required (VERSION 3.1) |
2 | project (chemist) | 2 | project (yandere) |
3 | 3 | ||
4 | set(CMAKE_BUILD_TYPE Debug) | 4 | set(CMAKE_BUILD_TYPE Debug) |
5 | 5 | ||
6 | find_package(PkgConfig) | 6 | add_subdirectory(vendor/libtwittercpp) |
7 | pkg_check_modules(sqlite3 sqlite3 REQUIRED) | ||
8 | |||
9 | add_subdirectory(vendor/twitcurl/libtwitcurl) | ||
10 | add_subdirectory(vendor/verbly) | ||
11 | add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) | 7 | add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) |
12 | 8 | ||
13 | include_directories(vendor/twitcurl/libtwitcurl ${sqlite3_INCLUDE_DIR} vendor/verbly/lib vendor/yaml-cpp/include) | 9 | include_directories(vendor/libtwittercpp/src vendor/yaml-cpp/include) |
14 | add_executable(chemist chemist.cpp) | 10 | add_executable(yandere yandere.cpp) |
15 | set_property(TARGET chemist PROPERTY CXX_STANDARD 11) | 11 | set_property(TARGET yandere PROPERTY CXX_STANDARD 11) |
16 | set_property(TARGET chemist PROPERTY CXX_STANDARD_REQUIRED ON) | 12 | set_property(TARGET yandere PROPERTY CXX_STANDARD_REQUIRED ON) |
17 | target_link_libraries(chemist verbly ${sqlite3_LIBRARIES} yaml-cpp twitcurl curl) | 13 | target_link_libraries(yandere yaml-cpp twitter++) |
diff --git a/data.txt b/data.txt deleted file mode 100644 index 8535d4e..0000000 --- a/data.txt +++ /dev/null | |||
@@ -1,260 +0,0 @@ | |||
1 | MAIN | ||
2 | {PRIMARY} {SECONDARY} | ||
3 | |||
4 | PRIMARY | ||
5 | {NAME} is {CLASS:indefinite} commonly used to treat {SYNDROME}. | ||
6 | {NAME} is {CLASS:indefinite} primarily used for {SYNDROME}. | ||
7 | {NAME} is {CLASS:indefinite} prescribed for {SYNDROME}. | ||
8 | {NAME} is {CLASS:indefinite} approved for treatment of {SYNDROME}, and {SYNDROME}. | ||
9 | {NAME} is {CLASS:indefinite} used for {SYNDROME} and {SYNDROME}. | ||
10 | {NAME} is {CLASS:indefinite} used with {EXISTENT} to treat {syndrome}. | ||
11 | {NAME} is {CLASS:indefinite} used in cases of {EXISTENT} overdose. | ||
12 | {NAME} is {CLASS:indefinite} used recreationally as {CLASS:indefinite}. | ||
13 | {NAME} is {CLASS:indefinite} used recreationally for {verbing}. | ||
14 | |||
15 | SECONDARY | ||
16 | Developed due to the Great {Noun} Epidemic of {year} in {Region}. | ||
17 | Frequently prescribed off-label for {SYNDROME}. | ||
18 | Sometimes used for {SYNDROME} because of its {verbing} effect. | ||
19 | Illegal to own in the US because of its {verbing} effect. | ||
20 | Developed in {year} to replace {EXISTENT}. | ||
21 | Overtook {EXISTENT} due to its {adjective} effect. | ||
22 | Synthesized by {FamousName} in {year} in a {verbing} accident. | ||
23 | Used mainly in {year}, before {EXISTENT} became popular. | ||
24 | Only legal in {Region} because of its {verbing} effect. | ||
25 | |||
26 | SYNDROME | ||
27 | irritable {noun} syndrome | ||
28 | {adjective} {noun} syndrome | ||
29 | severe {noun} | ||
30 | major {adjective} disorder | ||
31 | {adjective} {noun} disorder | ||
32 | obsessive {noun} disorder | ||
33 | clinical {noun} | ||
34 | {adjective} personality disorder | ||
35 | respiratory {adjective} disease | ||
36 | {bodypart} cancer | ||
37 | restless {bodypart} | ||
38 | {bodypart} failure | ||
39 | congenital {noun} disease | ||
40 | {FamousName}'s disease | ||
41 | {adjective} fever | ||
42 | hypo{noun}ism | ||
43 | |||
44 | CLASS | ||
45 | analgesic | ||
46 | painkiller | ||
47 | anaesthetic | ||
48 | antihistamine | ||
49 | anticonvulsant | ||
50 | antiepileptic | ||
51 | antidepressant | ||
52 | antimigraine | ||
53 | antipsychotic | ||
54 | benzodiazepine | ||
55 | antiparkinsonian | ||
56 | immunosuppressive | ||
57 | antianaemia | ||
58 | anticoagulant | ||
59 | blood thinner | ||
60 | antiarrhythmic | ||
61 | antithrombotic | ||
62 | antifungal | ||
63 | anti-infective | ||
64 | anti-inflammatory | ||
65 | disinfectant | ||
66 | antiseptic | ||
67 | antiemetic | ||
68 | diuretic | ||
69 | opiod painkiller | ||
70 | antiulcer | ||
71 | laxative | ||
72 | sedative | ||
73 | hormone | ||
74 | estrogen | ||
75 | androgen | ||
76 | contraceptive | ||
77 | ovulation inducer | ||
78 | thyroid stimulant | ||
79 | antithyroid | ||
80 | insulin | ||
81 | vaccine | ||
82 | oxytocin | ||
83 | SSRI | ||
84 | anxiolytic | ||
85 | antipanic agent | ||
86 | tricyclic | ||
87 | MAOI | ||
88 | SNRI | ||
89 | antiandrogen | ||
90 | psychedelic | ||
91 | vitamin | ||
92 | probiotic | ||
93 | antibiotic | ||
94 | antiviral drug | ||
95 | stimulant | ||
96 | depressant | ||
97 | aphrodisiac | ||
98 | |||
99 | EXISTENT | ||
100 | fluoxetine | ||
101 | Prozac | ||
102 | sertraline | ||
103 | Zoloft | ||
104 | escitalopram | ||
105 | Lexapro | ||
106 | venlafaxine | ||
107 | Effexor | ||
108 | aripiprazole | ||
109 | Abilify | ||
110 | alprazolam | ||
111 | Xanax | ||
112 | diazepam | ||
113 | Valium | ||
114 | lamotrigine | ||
115 | Lamictal | ||
116 | gabapentin | ||
117 | Neurontin | ||
118 | acetaminophen | ||
119 | Tylenol | ||
120 | ibuprofin | ||
121 | Advil | ||
122 | lurasidone | ||
123 | Latuda | ||
124 | lithium | ||
125 | activated charcoal | ||
126 | estradiol | ||
127 | AndroGel | ||
128 | ziprasidone | ||
129 | Geodon | ||
130 | risperidone | ||
131 | Risperdal | ||
132 | quetiapine | ||
133 | Seroquel | ||
134 | Cymbalta | ||
135 | duloxetine | ||
136 | bupropion | ||
137 | Welbutrin | ||
138 | buspirone | ||
139 | Buspar | ||
140 | oxycontin | ||
141 | Oxycodone | ||
142 | Concerta | ||
143 | methylphenidate | ||
144 | Ritalin | ||
145 | Vyvanse | ||
146 | lisdexamfetamine | ||
147 | Adderall | ||
148 | epinephrine | ||
149 | adrenaline | ||
150 | testosterone gel | ||
151 | Cialis | ||
152 | Viagra | ||
153 | heroin | ||
154 | morphine | ||
155 | crystal meth | ||
156 | |||
157 | NAME | ||
158 | {PRENAME}{NAMEMID}{NAMEIFX} | ||
159 | |||
160 | PRENAME | ||
161 | Oxy | ||
162 | Ari | ||
163 | Zi | ||
164 | Quetia | ||
165 | Mor | ||
166 | Her | ||
167 | Cia | ||
168 | Via | ||
169 | He | ||
170 | Con | ||
171 | Flu | ||
172 | Ser | ||
173 | Es | ||
174 | Ven | ||
175 | Al | ||
176 | Dia | ||
177 | Lamo | ||
178 | Gaba | ||
179 | Aceta | ||
180 | Ibu | ||
181 | Lura | ||
182 | Ris | ||
183 | Li | ||
184 | Estra | ||
185 | Du | ||
186 | Bus | ||
187 | Epin | ||
188 | Co | ||
189 | Lido | ||
190 | Pro | ||
191 | Pri | ||
192 | Bu | ||
193 | Levo | ||
194 | Ro | ||
195 | Me | ||
196 | Dibu | ||
197 | Des | ||
198 | Ha | ||
199 | |||
200 | NAMEMID | ||
201 | pipra | ||
202 | pi | ||
203 | to | ||
204 | stero | ||
205 | cer | ||
206 | oxe | ||
207 | tra | ||
208 | cita | ||
209 | lo | ||
210 | la | ||
211 | fa | ||
212 | pra | ||
213 | zo | ||
214 | ze | ||
215 | tri | ||
216 | pen | ||
217 | mino | ||
218 | pro | ||
219 | si | ||
220 | peri | ||
221 | thi | ||
222 | loxe | ||
223 | con | ||
224 | epher | ||
225 | piva | ||
226 | bupi | ||
227 | va | ||
228 | piva | ||
229 | flu | ||
230 | oxy | ||
231 | {NAMEMID}{NAMEMID} | ||
232 | {NAMEMID}{NAMEMID} | ||
233 | |||
234 | NAMEIFX | ||
235 | zole | ||
236 | ne | ||
237 | tine | ||
238 | lin | ||
239 | tamine | ||
240 | gra | ||
241 | phine | ||
242 | ta | ||
243 | line | ||
244 | pram | ||
245 | xine | ||
246 | lam | ||
247 | pam | ||
248 | gine | ||
249 | tin | ||
250 | phen | ||
251 | fin | ||
252 | done | ||
253 | um | ||
254 | diol | ||
255 | tin | ||
256 | rone | ||
257 | ine | ||
258 | caine | ||
259 | rane | ||
260 | ide \ No newline at end of file | ||
diff --git a/vendor/libtwittercpp b/vendor/libtwittercpp new file mode 160000 | |||
Subproject 6c9f541f34c58ac817f88ffb5e069b929bbbc27 | |||
diff --git a/vendor/twitcurl b/vendor/twitcurl deleted file mode 160000 | |||
Subproject 6659e86de7481e50977b7569c75138f7f69ad3c | |||
diff --git a/vendor/verbly b/vendor/verbly deleted file mode 160000 | |||
Subproject 965a3206df834f846f2c560438c80a707dcee4c | |||
diff --git a/vendor/yaml-cpp b/vendor/yaml-cpp | |||
Subproject 34bd1a7083e5875e6a4b2d4f61c0b356cc5d53f | Subproject 519d33fea3fbcbe7e1f89f97ee0fa539cec33eb | ||
diff --git a/yandere.cpp b/yandere.cpp new file mode 100644 index 0000000..01b0dca --- /dev/null +++ b/yandere.cpp | |||
@@ -0,0 +1,194 @@ | |||
1 | #include <yaml-cpp/yaml.h> | ||
2 | #include <iostream> | ||
3 | #include <cstdlib> | ||
4 | #include <ctime> | ||
5 | #include <sstream> | ||
6 | #include <fstream> | ||
7 | #include <twitter.h> | ||
8 | #include <chrono> | ||
9 | #include <thread> | ||
10 | |||
11 | template <class InputIterator> | ||
12 | std::string implode(InputIterator first, InputIterator last, std::string delimiter) | ||
13 | { | ||
14 | std::stringstream result; | ||
15 | |||
16 | for (InputIterator it = first; it != last; it++) | ||
17 | { | ||
18 | if (it != first) | ||
19 | { | ||
20 | result << delimiter; | ||
21 | } | ||
22 | |||
23 | result << *it; | ||
24 | } | ||
25 | |||
26 | return result.str(); | ||
27 | } | ||
28 | |||
29 | template <class Container> | ||
30 | Container split(std::string input, std::string delimiter) | ||
31 | { | ||
32 | Container result; | ||
33 | |||
34 | while (!input.empty()) | ||
35 | { | ||
36 | int divider = input.find(delimiter); | ||
37 | if (divider == std::string::npos) | ||
38 | { | ||
39 | result.push_back(input); | ||
40 | |||
41 | input = ""; | ||
42 | } else { | ||
43 | result.push_back(input.substr(0, divider)); | ||
44 | |||
45 | input = input.substr(divider+delimiter.length()); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | return result; | ||
50 | } | ||
51 | |||
52 | int main(int argc, char** argv) | ||
53 | { | ||
54 | srand(time(NULL)); | ||
55 | rand(); rand(); rand(); rand(); | ||
56 | |||
57 | YAML::Node config = YAML::LoadFile("config.yml"); | ||
58 | |||
59 | twitter::auth auth; | ||
60 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | ||
61 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); | ||
62 | auth.setAccessKey(config["access_key"].as<std::string>()); | ||
63 | auth.setAccessSecret(config["access_secret"].as<std::string>()); | ||
64 | |||
65 | twitter::client client(auth); | ||
66 | |||
67 | std::map<std::string, std::vector<std::string>> groups; | ||
68 | std::ifstream datafile("data.txt"); | ||
69 | if (!datafile.is_open()) | ||
70 | { | ||
71 | std::cout << "Could not find data.txt" << std::endl; | ||
72 | return 1; | ||
73 | } | ||
74 | |||
75 | bool newgroup = true; | ||
76 | std::string line; | ||
77 | std::string curgroup; | ||
78 | while (getline(datafile, line)) | ||
79 | { | ||
80 | if (line.back() == '\r') | ||
81 | { | ||
82 | line.pop_back(); | ||
83 | } | ||
84 | |||
85 | if (newgroup) | ||
86 | { | ||
87 | curgroup = line; | ||
88 | newgroup = false; | ||
89 | } else { | ||
90 | if (line.empty()) | ||
91 | { | ||
92 | newgroup = true; | ||
93 | } else { | ||
94 | groups[curgroup].push_back(line); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | for (;;) | ||
100 | { | ||
101 | std::cout << "Generating tweet" << std::endl; | ||
102 | std::string action = "{MAIN}"; | ||
103 | int tknloc; | ||
104 | while ((tknloc = action.find("{")) != std::string::npos) | ||
105 | { | ||
106 | std::string token = action.substr(tknloc+1, action.find("}")-tknloc-1); | ||
107 | std::string modifier; | ||
108 | int modloc; | ||
109 | if ((modloc = token.find(":")) != std::string::npos) | ||
110 | { | ||
111 | modifier = token.substr(modloc+1); | ||
112 | token = token.substr(0, modloc); | ||
113 | } | ||
114 | |||
115 | int eqloc; | ||
116 | std::string eqvarname; | ||
117 | if ((eqloc = token.find("=")) != std::string::npos) | ||
118 | { | ||
119 | eqvarname = token.substr(0, eqloc); | ||
120 | token = token.substr(eqloc+1); | ||
121 | } | ||
122 | |||
123 | std::string canontkn; | ||
124 | std::transform(std::begin(token), std::end(token), std::back_inserter(canontkn), [] (char ch) { | ||
125 | return std::toupper(ch); | ||
126 | }); | ||
127 | |||
128 | std::string result; | ||
129 | if (canontkn == "\\N") | ||
130 | { | ||
131 | result = "\n"; | ||
132 | } else { | ||
133 | auto group = groups[canontkn]; | ||
134 | result = group[rand() % group.size()]; | ||
135 | } | ||
136 | |||
137 | if (!eqvarname.empty()) | ||
138 | { | ||
139 | groups[eqvarname].push_back(result); | ||
140 | } | ||
141 | |||
142 | if (modifier == "indefinite") | ||
143 | { | ||
144 | if ((result.length() > 1) && (isupper(result[0])) && (isupper(result[1]))) | ||
145 | { | ||
146 | result = "an " + result; | ||
147 | } else if ((result[0] == 'a') || (result[0] == 'e') || (result[0] == 'i') || (result[0] == 'o') || (result[0] == 'u')) | ||
148 | { | ||
149 | result = "an " + result; | ||
150 | } else { | ||
151 | result = "a " + result; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | std::string finalresult; | ||
156 | if (islower(token[0])) | ||
157 | { | ||
158 | std::transform(std::begin(result), std::end(result), std::back_inserter(finalresult), [] (char ch) { | ||
159 | return std::tolower(ch); | ||
160 | }); | ||
161 | } else if (isupper(token[0]) && !isupper(token[1])) | ||
162 | { | ||
163 | auto words = split<std::list<std::string>>(result, " "); | ||
164 | for (auto& word : words) | ||
165 | { | ||
166 | word[0] = std::toupper(word[0]); | ||
167 | } | ||
168 | |||
169 | finalresult = implode(std::begin(words), std::end(words), " "); | ||
170 | } else { | ||
171 | finalresult = result; | ||
172 | } | ||
173 | |||
174 | action.replace(tknloc, action.find("}")-tknloc+1, finalresult); | ||
175 | } | ||
176 | |||
177 | action.resize(140); | ||
178 | |||
179 | try | ||
180 | { | ||
181 | client.updateStatus(action); | ||
182 | } catch (const twitter::twitter_error& e) | ||
183 | { | ||
184 | std::cout << "Twitter error: " << e.what() << std::endl; | ||
185 | } | ||
186 | |||
187 | std::cout << action << std::endl; | ||
188 | std::cout << "Waiting" << std::endl; | ||
189 | |||
190 | std::this_thread::sleep_for(std::chrono::hours(1)); | ||
191 | |||
192 | std::cout << std::endl; | ||
193 | } | ||
194 | } | ||