diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Cargo.lock | 442 | ||||
-rw-r--r-- | Cargo.toml | 7 | ||||
-rw-r--r-- | src/main.rs | 23 |
4 files changed, 473 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1 @@ | |||
target | |||
diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..e28540a --- /dev/null +++ b/Cargo.lock | |||
@@ -0,0 +1,442 @@ | |||
1 | [root] | ||
2 | name = "luggas" | ||
3 | version = "0.1.0" | ||
4 | dependencies = [ | ||
5 | "telegram-bot 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
6 | ] | ||
7 | |||
8 | [[package]] | ||
9 | name = "aho-corasick" | ||
10 | version = "0.5.1" | ||
11 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
12 | dependencies = [ | ||
13 | "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
14 | ] | ||
15 | |||
16 | [[package]] | ||
17 | name = "bitflags" | ||
18 | version = "0.4.0" | ||
19 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
20 | |||
21 | [[package]] | ||
22 | name = "buf_redux" | ||
23 | version = "0.1.3" | ||
24 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
25 | |||
26 | [[package]] | ||
27 | name = "cookie" | ||
28 | version = "0.2.2" | ||
29 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
30 | dependencies = [ | ||
31 | "openssl 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
32 | "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", | ||
33 | "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", | ||
34 | "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", | ||
35 | ] | ||
36 | |||
37 | [[package]] | ||
38 | name = "env_logger" | ||
39 | version = "0.3.2" | ||
40 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
41 | dependencies = [ | ||
42 | "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
43 | "regex 0.1.61 (registry+https://github.com/rust-lang/crates.io-index)", | ||
44 | ] | ||
45 | |||
46 | [[package]] | ||
47 | name = "gcc" | ||
48 | version = "0.3.26" | ||
49 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
50 | |||
51 | [[package]] | ||
52 | name = "gdi32-sys" | ||
53 | version = "0.1.1" | ||
54 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
55 | dependencies = [ | ||
56 | "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
57 | ] | ||
58 | |||
59 | [[package]] | ||
60 | name = "hpack" | ||
61 | version = "0.2.0" | ||
62 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
63 | dependencies = [ | ||
64 | "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
65 | ] | ||
66 | |||
67 | [[package]] | ||
68 | name = "httparse" | ||
69 | version = "1.1.2" | ||
70 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
71 | |||
72 | [[package]] | ||
73 | name = "hyper" | ||
74 | version = "0.7.2" | ||
75 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
76 | dependencies = [ | ||
77 | "cookie 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
78 | "httparse 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
79 | "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
80 | "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
81 | "mime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
82 | "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", | ||
83 | "openssl 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
84 | "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", | ||
85 | "solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
86 | "time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", | ||
87 | "traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
88 | "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
89 | "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
90 | "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", | ||
91 | ] | ||
92 | |||
93 | [[package]] | ||
94 | name = "kernel32-sys" | ||
95 | version = "0.2.1" | ||
96 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
97 | dependencies = [ | ||
98 | "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
99 | "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
100 | ] | ||
101 | |||
102 | [[package]] | ||
103 | name = "language-tags" | ||
104 | version = "0.2.2" | ||
105 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
106 | |||
107 | [[package]] | ||
108 | name = "lazy_static" | ||
109 | version = "0.1.15" | ||
110 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
111 | |||
112 | [[package]] | ||
113 | name = "libc" | ||
114 | version = "0.2.9" | ||
115 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
116 | |||
117 | [[package]] | ||
118 | name = "libressl-pnacl-sys" | ||
119 | version = "2.1.6" | ||
120 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
121 | dependencies = [ | ||
122 | "pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
123 | ] | ||
124 | |||
125 | [[package]] | ||
126 | name = "log" | ||
127 | version = "0.3.5" | ||
128 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
129 | dependencies = [ | ||
130 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
131 | ] | ||
132 | |||
133 | [[package]] | ||
134 | name = "matches" | ||
135 | version = "0.1.2" | ||
136 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
137 | |||
138 | [[package]] | ||
139 | name = "memchr" | ||
140 | version = "0.1.10" | ||
141 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
142 | dependencies = [ | ||
143 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
144 | ] | ||
145 | |||
146 | [[package]] | ||
147 | name = "mempool" | ||
148 | version = "0.2.0" | ||
149 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
150 | |||
151 | [[package]] | ||
152 | name = "mime" | ||
153 | version = "0.1.3" | ||
154 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
155 | dependencies = [ | ||
156 | "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
157 | "serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)", | ||
158 | ] | ||
159 | |||
160 | [[package]] | ||
161 | name = "mime_guess" | ||
162 | version = "1.5.0" | ||
163 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
164 | dependencies = [ | ||
165 | "mime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
166 | "phf 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
167 | "phf_codegen 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
168 | ] | ||
169 | |||
170 | [[package]] | ||
171 | name = "multipart" | ||
172 | version = "0.5.1" | ||
173 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
174 | dependencies = [ | ||
175 | "buf_redux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
176 | "env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
177 | "hyper 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
178 | "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
179 | "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
180 | "mime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
181 | "mime_guess 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
182 | "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
183 | "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
184 | ] | ||
185 | |||
186 | [[package]] | ||
187 | name = "num" | ||
188 | version = "0.1.31" | ||
189 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
190 | |||
191 | [[package]] | ||
192 | name = "num_cpus" | ||
193 | version = "0.2.11" | ||
194 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
195 | dependencies = [ | ||
196 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
197 | ] | ||
198 | |||
199 | [[package]] | ||
200 | name = "openssl" | ||
201 | version = "0.7.8" | ||
202 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
203 | dependencies = [ | ||
204 | "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
205 | "gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", | ||
206 | "lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", | ||
207 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
208 | "openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
209 | "openssl-sys-extras 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
210 | ] | ||
211 | |||
212 | [[package]] | ||
213 | name = "openssl-sys" | ||
214 | version = "0.7.8" | ||
215 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
216 | dependencies = [ | ||
217 | "gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
218 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
219 | "libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
220 | "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
221 | "user32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
222 | ] | ||
223 | |||
224 | [[package]] | ||
225 | name = "openssl-sys-extras" | ||
226 | version = "0.7.8" | ||
227 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
228 | dependencies = [ | ||
229 | "gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", | ||
230 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
231 | "openssl-sys 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
232 | ] | ||
233 | |||
234 | [[package]] | ||
235 | name = "phf" | ||
236 | version = "0.7.14" | ||
237 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
238 | dependencies = [ | ||
239 | "phf_shared 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
240 | ] | ||
241 | |||
242 | [[package]] | ||
243 | name = "phf_codegen" | ||
244 | version = "0.7.14" | ||
245 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
246 | dependencies = [ | ||
247 | "phf_generator 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
248 | "phf_shared 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
249 | ] | ||
250 | |||
251 | [[package]] | ||
252 | name = "phf_generator" | ||
253 | version = "0.7.14" | ||
254 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
255 | dependencies = [ | ||
256 | "phf_shared 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
257 | "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
258 | ] | ||
259 | |||
260 | [[package]] | ||
261 | name = "phf_shared" | ||
262 | version = "0.7.14" | ||
263 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
264 | |||
265 | [[package]] | ||
266 | name = "pkg-config" | ||
267 | version = "0.3.8" | ||
268 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
269 | |||
270 | [[package]] | ||
271 | name = "pnacl-build-helper" | ||
272 | version = "1.4.10" | ||
273 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
274 | dependencies = [ | ||
275 | "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
276 | ] | ||
277 | |||
278 | [[package]] | ||
279 | name = "rand" | ||
280 | version = "0.3.14" | ||
281 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
282 | dependencies = [ | ||
283 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
284 | ] | ||
285 | |||
286 | [[package]] | ||
287 | name = "regex" | ||
288 | version = "0.1.61" | ||
289 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
290 | dependencies = [ | ||
291 | "aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
292 | "memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
293 | "mempool 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
294 | "regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
295 | "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
296 | ] | ||
297 | |||
298 | [[package]] | ||
299 | name = "regex-syntax" | ||
300 | version = "0.3.1" | ||
301 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
302 | |||
303 | [[package]] | ||
304 | name = "rustc-serialize" | ||
305 | version = "0.3.18" | ||
306 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
307 | |||
308 | [[package]] | ||
309 | name = "rustc_version" | ||
310 | version = "0.1.7" | ||
311 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
312 | dependencies = [ | ||
313 | "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", | ||
314 | ] | ||
315 | |||
316 | [[package]] | ||
317 | name = "semver" | ||
318 | version = "0.1.20" | ||
319 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
320 | |||
321 | [[package]] | ||
322 | name = "serde" | ||
323 | version = "0.6.15" | ||
324 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
325 | dependencies = [ | ||
326 | "num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", | ||
327 | ] | ||
328 | |||
329 | [[package]] | ||
330 | name = "solicit" | ||
331 | version = "0.4.4" | ||
332 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
333 | dependencies = [ | ||
334 | "hpack 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
335 | "log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
336 | ] | ||
337 | |||
338 | [[package]] | ||
339 | name = "telegram-bot" | ||
340 | version = "0.4.2" | ||
341 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
342 | dependencies = [ | ||
343 | "hyper 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
344 | "multipart 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
345 | "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", | ||
346 | "url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", | ||
347 | ] | ||
348 | |||
349 | [[package]] | ||
350 | name = "tempdir" | ||
351 | version = "0.3.4" | ||
352 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
353 | dependencies = [ | ||
354 | "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
355 | ] | ||
356 | |||
357 | [[package]] | ||
358 | name = "time" | ||
359 | version = "0.1.34" | ||
360 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
361 | dependencies = [ | ||
362 | "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
363 | "libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
364 | "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
365 | ] | ||
366 | |||
367 | [[package]] | ||
368 | name = "traitobject" | ||
369 | version = "0.0.1" | ||
370 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
371 | |||
372 | [[package]] | ||
373 | name = "typeable" | ||
374 | version = "0.1.2" | ||
375 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
376 | |||
377 | [[package]] | ||
378 | name = "unicase" | ||
379 | version = "1.4.0" | ||
380 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
381 | dependencies = [ | ||
382 | "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", | ||
383 | ] | ||
384 | |||
385 | [[package]] | ||
386 | name = "unicode-bidi" | ||
387 | version = "0.2.3" | ||
388 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
389 | dependencies = [ | ||
390 | "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
391 | ] | ||
392 | |||
393 | [[package]] | ||
394 | name = "unicode-normalization" | ||
395 | version = "0.1.2" | ||
396 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
397 | |||
398 | [[package]] | ||
399 | name = "url" | ||
400 | version = "0.5.7" | ||
401 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
402 | dependencies = [ | ||
403 | "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
404 | "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", | ||
405 | "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
406 | "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
407 | "uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", | ||
408 | ] | ||
409 | |||
410 | [[package]] | ||
411 | name = "user32-sys" | ||
412 | version = "0.1.2" | ||
413 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
414 | dependencies = [ | ||
415 | "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
416 | "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
417 | ] | ||
418 | |||
419 | [[package]] | ||
420 | name = "utf8-ranges" | ||
421 | version = "0.1.3" | ||
422 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
423 | |||
424 | [[package]] | ||
425 | name = "uuid" | ||
426 | version = "0.1.18" | ||
427 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
428 | dependencies = [ | ||
429 | "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", | ||
430 | "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", | ||
431 | ] | ||
432 | |||
433 | [[package]] | ||
434 | name = "winapi" | ||
435 | version = "0.2.6" | ||
436 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
437 | |||
438 | [[package]] | ||
439 | name = "winapi-build" | ||
440 | version = "0.1.1" | ||
441 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
442 | |||
diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4737ab2 --- /dev/null +++ b/Cargo.toml | |||
@@ -0,0 +1,7 @@ | |||
1 | [package] | ||
2 | name = "luggas" | ||
3 | version = "0.1.0" | ||
4 | authors = ["jan <jan@ruken.pw>"] | ||
5 | |||
6 | [dependencies] | ||
7 | telegram-bot = "0.4" | ||
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4cca6d1 --- /dev/null +++ b/src/main.rs | |||
@@ -0,0 +1,23 @@ | |||
1 | extern crate telegram_bot; | ||
2 | |||
3 | use telegram_bot::{Api, ListeningMethod, ListeningAction, MessageType, Update}; | ||
4 | |||
5 | fn main() { | ||
6 | let api = Api::from_env("TELEGRAM_BOT_TOKEN").unwrap(); | ||
7 | |||
8 | println!("api started: {:?}", api.get_me()); | ||
9 | |||
10 | let mut listener = api.listener(ListeningMethod::LongPoll(None)); | ||
11 | let res = listener.listen(|u| { | ||
12 | if let Some(m) = u.message { | ||
13 | let name = m.from.first_name; | ||
14 | |||
15 | println!("got message from {}", name); | ||
16 | }; | ||
17 | Ok(ListeningAction::Continue) | ||
18 | }); | ||
19 | |||
20 | if let Err(e) = res { | ||
21 | panic!(e); | ||
22 | } | ||
23 | } | ||