about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules9
-rw-r--r--CMakeLists.txt18
-rw-r--r--data.txt260
m---------vendor/libtwittercpp0
m---------vendor/twitcurl0
m---------vendor/verbly0
m---------vendor/yaml-cpp0
-rw-r--r--yandere.cpp194
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 @@
1cmake_minimum_required (VERSION 3.1) 1cmake_minimum_required (VERSION 3.1)
2project (chemist) 2project (yandere)
3 3
4set(CMAKE_BUILD_TYPE Debug) 4set(CMAKE_BUILD_TYPE Debug)
5 5
6find_package(PkgConfig) 6add_subdirectory(vendor/libtwittercpp)
7pkg_check_modules(sqlite3 sqlite3 REQUIRED)
8
9add_subdirectory(vendor/twitcurl/libtwitcurl)
10add_subdirectory(vendor/verbly)
11add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL) 7add_subdirectory(vendor/yaml-cpp EXCLUDE_FROM_ALL)
12 8
13include_directories(vendor/twitcurl/libtwitcurl ${sqlite3_INCLUDE_DIR} vendor/verbly/lib vendor/yaml-cpp/include) 9include_directories(vendor/libtwittercpp/src vendor/yaml-cpp/include)
14add_executable(chemist chemist.cpp) 10add_executable(yandere yandere.cpp)
15set_property(TARGET chemist PROPERTY CXX_STANDARD 11) 11set_property(TARGET yandere PROPERTY CXX_STANDARD 11)
16set_property(TARGET chemist PROPERTY CXX_STANDARD_REQUIRED ON) 12set_property(TARGET yandere PROPERTY CXX_STANDARD_REQUIRED ON)
17target_link_libraries(chemist verbly ${sqlite3_LIBRARIES} yaml-cpp twitcurl curl) 13target_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 @@
1MAIN
2{PRIMARY} {SECONDARY}
3
4PRIMARY
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
15SECONDARY
16Developed due to the Great {Noun} Epidemic of {year} in {Region}.
17Frequently prescribed off-label for {SYNDROME}.
18Sometimes used for {SYNDROME} because of its {verbing} effect.
19Illegal to own in the US because of its {verbing} effect.
20Developed in {year} to replace {EXISTENT}.
21Overtook {EXISTENT} due to its {adjective} effect.
22Synthesized by {FamousName} in {year} in a {verbing} accident.
23Used mainly in {year}, before {EXISTENT} became popular.
24Only legal in {Region} because of its {verbing} effect.
25
26SYNDROME
27irritable {noun} syndrome
28{adjective} {noun} syndrome
29severe {noun}
30major {adjective} disorder
31{adjective} {noun} disorder
32obsessive {noun} disorder
33clinical {noun}
34{adjective} personality disorder
35respiratory {adjective} disease
36{bodypart} cancer
37restless {bodypart}
38{bodypart} failure
39congenital {noun} disease
40{FamousName}'s disease
41{adjective} fever
42hypo{noun}ism
43
44CLASS
45analgesic
46painkiller
47anaesthetic
48antihistamine
49anticonvulsant
50antiepileptic
51antidepressant
52antimigraine
53antipsychotic
54benzodiazepine
55antiparkinsonian
56immunosuppressive
57antianaemia
58anticoagulant
59blood thinner
60antiarrhythmic
61antithrombotic
62antifungal
63anti-infective
64anti-inflammatory
65disinfectant
66antiseptic
67antiemetic
68diuretic
69opiod painkiller
70antiulcer
71laxative
72sedative
73hormone
74estrogen
75androgen
76contraceptive
77ovulation inducer
78thyroid stimulant
79antithyroid
80insulin
81vaccine
82oxytocin
83SSRI
84anxiolytic
85antipanic agent
86tricyclic
87MAOI
88SNRI
89antiandrogen
90psychedelic
91vitamin
92probiotic
93antibiotic
94antiviral drug
95stimulant
96depressant
97aphrodisiac
98
99EXISTENT
100fluoxetine
101Prozac
102sertraline
103Zoloft
104escitalopram
105Lexapro
106venlafaxine
107Effexor
108aripiprazole
109Abilify
110alprazolam
111Xanax
112diazepam
113Valium
114lamotrigine
115Lamictal
116gabapentin
117Neurontin
118acetaminophen
119Tylenol
120ibuprofin
121Advil
122lurasidone
123Latuda
124lithium
125activated charcoal
126estradiol
127AndroGel
128ziprasidone
129Geodon
130risperidone
131Risperdal
132quetiapine
133Seroquel
134Cymbalta
135duloxetine
136bupropion
137Welbutrin
138buspirone
139Buspar
140oxycontin
141Oxycodone
142Concerta
143methylphenidate
144Ritalin
145Vyvanse
146lisdexamfetamine
147Adderall
148epinephrine
149adrenaline
150testosterone gel
151Cialis
152Viagra
153heroin
154morphine
155crystal meth
156
157NAME
158{PRENAME}{NAMEMID}{NAMEIFX}
159
160PRENAME
161Oxy
162Ari
163Zi
164Quetia
165Mor
166Her
167Cia
168Via
169He
170Con
171Flu
172Ser
173Es
174Ven
175Al
176Dia
177Lamo
178Gaba
179Aceta
180Ibu
181Lura
182Ris
183Li
184Estra
185Du
186Bus
187Epin
188Co
189Lido
190Pro
191Pri
192Bu
193Levo
194Ro
195Me
196Dibu
197Des
198Ha
199
200NAMEMID
201pipra
202pi
203to
204stero
205cer
206oxe
207tra
208cita
209lo
210la
211fa
212pra
213zo
214ze
215tri
216pen
217mino
218pro
219si
220peri
221thi
222loxe
223con
224epher
225piva
226bupi
227va
228piva
229flu
230oxy
231{NAMEMID}{NAMEMID}
232{NAMEMID}{NAMEMID}
233
234NAMEIFX
235zole
236ne
237tine
238lin
239tamine
240gra
241phine
242ta
243line
244pram
245xine
246lam
247pam
248gine
249tin
250phen
251fin
252done
253um
254diol
255tin
256rone
257ine
258caine
259rane
260ide \ 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
11template <class InputIterator>
12std::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
29template <class Container>
30Container 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
52int 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}