├── .gitignore
├── .idea
├── .idea.DevelopersGame
│ ├── .idea
│ │ ├── contentModel.xml
│ │ ├── encodings.xml
│ │ ├── indexLayout.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ ├── projectSettingsUpdater.xml
│ │ ├── vcs.xml
│ │ └── workspace.xml
│ └── riderModule.iml
└── config
│ └── applicationhost.config
├── DevelopersGame.sln
├── DevelopersGame.sln.DotSettings.user
└── src
├── DevelopersGame.DataAccess.Migrations
├── DevelopersGame.DataAccess.Migrations.csproj
└── Migrations
│ ├── 20200227201757_AddedUserTable.Designer.cs
│ ├── 20200227201757_AddedUserTable.cs
│ ├── 20200227203404_AddedRoles.Designer.cs
│ ├── 20200227203404_AddedRoles.cs
│ └── DataContextModelSnapshot.cs
├── DevelopersGame.DataAccess
├── DataContext.cs
├── DevelopersGame.DataAccess.csproj
├── Entities
│ ├── BaseEntity.cs
│ ├── IEntity.cs
│ ├── Role.cs
│ ├── User.cs
│ └── UserRoles.cs
├── Enums
│ └── RankType.cs
├── Repositories
│ ├── DbRepository.cs
│ └── IDbRepository.cs
└── migration.ps1
├── DevelopersGame.Domain
├── Abstractions
│ ├── ICommandService.cs
│ └── TelegramCommand.cs
├── Commands
│ ├── HelpCommand.cs
│ ├── MainCommand.cs
│ ├── RankCommand.cs
│ ├── ShopCommand.cs
│ └── StartCommand.cs
├── DevelopersGame.Domain.csproj
└── Services
│ └── CommandService.cs
└── DevelopersGame.Web
├── Controllers
└── BotController.cs
├── DevelopersGame.Web.csproj
├── Program.cs
├── Properties
└── launchSettings.json
├── ServiceCollectionExtensions.cs
├── Startup.cs
└── appsettings.json
/.gitignore:
--------------------------------------------------------------------------------
1 | [Bb]in/
2 | [Oo]bj/
3 | [Dd]ebug/
4 | [Rr]ealese/
5 | *.zip
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/contentModel.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/projectSettingsUpdater.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
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 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 | 1582644094522
237 |
238 |
239 | 1582644094522
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
269 |
270 |
271 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 | file://$PROJECT_DIR$/src/DevelopersGame.DataAccess/DataContext.cs
408 | 12
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
--------------------------------------------------------------------------------
/.idea/.idea.DevelopersGame/riderModule.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/config/applicationhost.config:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
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 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
--------------------------------------------------------------------------------
/DevelopersGame.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevelopersGame.Web", "src\DevelopersGame.Web\DevelopersGame.Web.csproj", "{57A58C5C-3943-44F4-9283-D7A159D05AB2}"
4 | EndProject
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevelopersGame.Domain", "src\DevelopersGame.Domain\DevelopersGame.Domain.csproj", "{D1749FE7-BC68-462C-B9F6-948C4A0254AD}"
6 | EndProject
7 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevelopersGame.DataAccess", "src\DevelopersGame.DataAccess\DevelopersGame.DataAccess.csproj", "{CDA6A992-146D-4AA7-82B0-D08B8006C44D}"
8 | EndProject
9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevelopersGame.DataAccess.Migrations", "src\DevelopersGame.DataAccess.Migrations\DevelopersGame.DataAccess.Migrations.csproj", "{4E232870-5031-4333-8B41-4766E050AADE}"
10 | EndProject
11 | Global
12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
13 | Debug|Any CPU = Debug|Any CPU
14 | Release|Any CPU = Release|Any CPU
15 | EndGlobalSection
16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
17 | {57A58C5C-3943-44F4-9283-D7A159D05AB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 | {57A58C5C-3943-44F4-9283-D7A159D05AB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 | {57A58C5C-3943-44F4-9283-D7A159D05AB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {57A58C5C-3943-44F4-9283-D7A159D05AB2}.Release|Any CPU.Build.0 = Release|Any CPU
21 | {D1749FE7-BC68-462C-B9F6-948C4A0254AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {D1749FE7-BC68-462C-B9F6-948C4A0254AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {D1749FE7-BC68-462C-B9F6-948C4A0254AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {D1749FE7-BC68-462C-B9F6-948C4A0254AD}.Release|Any CPU.Build.0 = Release|Any CPU
25 | {CDA6A992-146D-4AA7-82B0-D08B8006C44D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {CDA6A992-146D-4AA7-82B0-D08B8006C44D}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {CDA6A992-146D-4AA7-82B0-D08B8006C44D}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {CDA6A992-146D-4AA7-82B0-D08B8006C44D}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {4E232870-5031-4333-8B41-4766E050AADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {4E232870-5031-4333-8B41-4766E050AADE}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {4E232870-5031-4333-8B41-4766E050AADE}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {4E232870-5031-4333-8B41-4766E050AADE}.Release|Any CPU.Build.0 = Release|Any CPU
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/DevelopersGame.sln.DotSettings.user:
--------------------------------------------------------------------------------
1 |
2 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
3 | 2
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess.Migrations/DevelopersGame.DataAccess.Migrations.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess.Migrations/Migrations/20200227201757_AddedUserTable.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using DevelopersGame.DataAccess;
4 | using Microsoft.EntityFrameworkCore;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.EntityFrameworkCore.Migrations;
7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
9 |
10 | namespace DevelopersGame.DataAccess.Migrations.Migrations
11 | {
12 | [DbContext(typeof(DataContext))]
13 | [Migration("20200227201757_AddedUserTable")]
14 | partial class AddedUserTable
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
21 | .HasAnnotation("ProductVersion", "3.1.2")
22 | .HasAnnotation("Relational:MaxIdentifierLength", 63);
23 |
24 | modelBuilder.Entity("DevelopersGame.DataAccess.Entities.User", b =>
25 | {
26 | b.Property("Id")
27 | .ValueGeneratedOnAdd()
28 | .HasColumnType("uuid");
29 |
30 | b.Property("ChatId")
31 | .HasColumnType("text");
32 |
33 | b.Property("Coins")
34 | .HasColumnType("numeric");
35 |
36 | b.Property("FirstName")
37 | .HasColumnType("text");
38 |
39 | b.Property("IsActive")
40 | .HasColumnType("boolean");
41 |
42 | b.Property("LastName")
43 | .HasColumnType("text");
44 |
45 | b.Property("Rank")
46 | .HasColumnType("integer");
47 |
48 | b.Property("UserId")
49 | .HasColumnType("text");
50 |
51 | b.Property("Username")
52 | .HasColumnType("text");
53 |
54 | b.HasKey("Id");
55 |
56 | b.ToTable("Users");
57 | });
58 | #pragma warning restore 612, 618
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess.Migrations/Migrations/20200227201757_AddedUserTable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 |
4 | namespace DevelopersGame.DataAccess.Migrations.Migrations
5 | {
6 | public partial class AddedUserTable : Migration
7 | {
8 | protected override void Up(MigrationBuilder migrationBuilder)
9 | {
10 | migrationBuilder.CreateTable(
11 | name: "Users",
12 | columns: table => new
13 | {
14 | Id = table.Column(nullable: false),
15 | IsActive = table.Column(nullable: false),
16 | FirstName = table.Column(nullable: true),
17 | LastName = table.Column(nullable: true),
18 | Username = table.Column(nullable: true),
19 | UserId = table.Column(nullable: true),
20 | ChatId = table.Column(nullable: true),
21 | Coins = table.Column(nullable: false),
22 | Rank = table.Column(nullable: false)
23 | },
24 | constraints: table =>
25 | {
26 | table.PrimaryKey("PK_Users", x => x.Id);
27 | });
28 | }
29 |
30 | protected override void Down(MigrationBuilder migrationBuilder)
31 | {
32 | migrationBuilder.DropTable(
33 | name: "Users");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess.Migrations/Migrations/20200227203404_AddedRoles.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using DevelopersGame.DataAccess;
4 | using Microsoft.EntityFrameworkCore;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.EntityFrameworkCore.Migrations;
7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
9 |
10 | namespace DevelopersGame.DataAccess.Migrations.Migrations
11 | {
12 | [DbContext(typeof(DataContext))]
13 | [Migration("20200227203404_AddedRoles")]
14 | partial class AddedRoles
15 | {
16 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
17 | {
18 | #pragma warning disable 612, 618
19 | modelBuilder
20 | .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
21 | .HasAnnotation("ProductVersion", "3.1.2")
22 | .HasAnnotation("Relational:MaxIdentifierLength", 63);
23 |
24 | modelBuilder.Entity("DevelopersGame.DataAccess.Entities.User", b =>
25 | {
26 | b.Property("Id")
27 | .ValueGeneratedOnAdd()
28 | .HasColumnType("uuid");
29 |
30 | b.Property("ChatId")
31 | .HasColumnType("text");
32 |
33 | b.Property("Coins")
34 | .HasColumnType("numeric");
35 |
36 | b.Property("FirstName")
37 | .HasColumnType("text");
38 |
39 | b.Property("IsActive")
40 | .HasColumnType("boolean");
41 |
42 | b.Property("LastName")
43 | .HasColumnType("text");
44 |
45 | b.Property("Rank")
46 | .HasColumnType("integer");
47 |
48 | b.Property("UserId")
49 | .HasColumnType("text");
50 |
51 | b.Property("Username")
52 | .HasColumnType("text");
53 |
54 | b.HasKey("Id");
55 |
56 | b.ToTable("Users");
57 | });
58 | #pragma warning restore 612, 618
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess.Migrations/Migrations/20200227203404_AddedRoles.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace DevelopersGame.DataAccess.Migrations.Migrations
4 | {
5 | public partial class AddedRoles : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 |
10 | }
11 |
12 | protected override void Down(MigrationBuilder migrationBuilder)
13 | {
14 |
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess.Migrations/Migrations/DataContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using DevelopersGame.DataAccess;
4 | using Microsoft.EntityFrameworkCore;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
8 |
9 | namespace DevelopersGame.DataAccess.Migrations.Migrations
10 | {
11 | [DbContext(typeof(DataContext))]
12 | partial class DataContextModelSnapshot : ModelSnapshot
13 | {
14 | protected override void BuildModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
19 | .HasAnnotation("ProductVersion", "3.1.2")
20 | .HasAnnotation("Relational:MaxIdentifierLength", 63);
21 |
22 | modelBuilder.Entity("DevelopersGame.DataAccess.Entities.User", b =>
23 | {
24 | b.Property("Id")
25 | .ValueGeneratedOnAdd()
26 | .HasColumnType("uuid");
27 |
28 | b.Property("ChatId")
29 | .HasColumnType("text");
30 |
31 | b.Property("Coins")
32 | .HasColumnType("numeric");
33 |
34 | b.Property("FirstName")
35 | .HasColumnType("text");
36 |
37 | b.Property("IsActive")
38 | .HasColumnType("boolean");
39 |
40 | b.Property("LastName")
41 | .HasColumnType("text");
42 |
43 | b.Property("Rank")
44 | .HasColumnType("integer");
45 |
46 | b.Property("UserId")
47 | .HasColumnType("text");
48 |
49 | b.Property("Username")
50 | .HasColumnType("text");
51 |
52 | b.HasKey("Id");
53 |
54 | b.ToTable("Users");
55 | });
56 | #pragma warning restore 612, 618
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/DataContext.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Threading.Tasks;
3 | using DevelopersGame.DataAccess.Entities;
4 | using Microsoft.EntityFrameworkCore;
5 |
6 | namespace DevelopersGame.DataAccess
7 | {
8 | public class DataContext: DbContext
9 | {
10 | public DbSet Users { get; set; }
11 |
12 | public DataContext(DbContextOptions options): base(options)
13 | {
14 | }
15 |
16 | public async Task SaveChangesAsync()
17 | {
18 | return await base.SaveChangesAsync();
19 | }
20 |
21 | public DbSet DbSet() where T : class
22 | {
23 | return Set();
24 | }
25 |
26 | public new IQueryable Query() where T : class
27 | {
28 | return Set();
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/DevelopersGame.DataAccess.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Entities/BaseEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DevelopersGame.DataAccess.Entities
4 | {
5 | public class BaseEntity: IEntity
6 | {
7 | public Guid Id { get; set; }
8 | public bool IsActive { get; set; } = true;
9 | }
10 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Entities/IEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DevelopersGame.DataAccess.Entities
4 | {
5 | public interface IEntity
6 | {
7 | Guid Id { get; set; }
8 | bool IsActive { get; set; }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Entities/Role.cs:
--------------------------------------------------------------------------------
1 | namespace DevelopersGame.DataAccess.Entities
2 | {
3 | public class Role: BaseEntity
4 | {
5 | public string Name { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Entities/User.cs:
--------------------------------------------------------------------------------
1 | using DevelopersGame.DataAccess.Enums;
2 |
3 | namespace DevelopersGame.DataAccess.Entities
4 | {
5 | public class User: BaseEntity
6 | {
7 | public string FirstName { get; set; }
8 | public string LastName { get; set; }
9 | public string Username { get; set; }
10 | public string UserId { get; set; }
11 | public string ChatId { get; set; }
12 | public decimal Coins { get; set; }
13 | public RankType Rank { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Entities/UserRoles.cs:
--------------------------------------------------------------------------------
1 | namespace DevelopersGame.DataAccess.Entities
2 | {
3 | public class UserRoles: BaseEntity
4 | {
5 | public User User { get; set; }
6 | public Role Role { get; set; }
7 | }
8 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Enums/RankType.cs:
--------------------------------------------------------------------------------
1 | namespace DevelopersGame.DataAccess.Enums
2 | {
3 | public enum RankType
4 | {
5 | Intern = 0,
6 | StrongIntern = 1,
7 | LowJunior = 2,
8 | Junior = 3,
9 | StrongJunior = 4,
10 | LowMiddle = 5,
11 | Middle = 6,
12 | StrongMiddle = 7,
13 | LowSenior = 8,
14 | Senior = 9,
15 | StrongSenior = 10,
16 | GrandMasterBit = 11
17 | }
18 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Repositories/DbRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 | using System.Threading.Tasks;
6 | using DevelopersGame.DataAccess.Entities;
7 | using Microsoft.EntityFrameworkCore;
8 |
9 | namespace DevelopersGame.DataAccess.Repositories
10 | {
11 | public class DbRepository: IDbRepository
12 | {
13 | private readonly DataContext _context;
14 |
15 | public DbRepository(DataContext context)
16 | {
17 | _context = context;
18 | }
19 |
20 | public IQueryable Get() where T: class, IEntity
21 | {
22 | return _context.Set().Where(x=> x.IsActive).AsQueryable();
23 | }
24 |
25 | public IQueryable Get(Expression> selector) where T : class, IEntity
26 | {
27 | return _context.Set().Where(selector).Where(x => x.IsActive).AsQueryable();
28 | }
29 |
30 | public async Task Add(T newEntity) where T: class, IEntity
31 | {
32 | var entity = await _context.Set().AddAsync(newEntity);
33 | return entity.Entity.Id;
34 | }
35 |
36 | public async Task AddRange(IEnumerable newEntities) where T: class, IEntity
37 | {
38 | await _context.Set().AddRangeAsync(newEntities);
39 | }
40 |
41 | public async Task Delete(Guid id) where T : class, IEntity
42 | {
43 | var activeEntity = await _context.Set().FirstOrDefaultAsync(x => x.Id == id);
44 | activeEntity.IsActive = false;
45 | await Task.Run(() => _context.Update(activeEntity));
46 | }
47 |
48 | public async Task Remove(T entity) where T: class, IEntity
49 | {
50 | await Task.Run(() => _context.Set().Remove(entity));
51 | }
52 |
53 | public async Task RemoveRange(IEnumerable entities) where T: class, IEntity
54 | {
55 | await Task.Run(() => _context.Set().RemoveRange(entities));
56 | }
57 |
58 | public async Task Update(T entity) where T: class, IEntity
59 | {
60 | await Task.Run(() => _context.Set().Update(entity));
61 | }
62 |
63 | public async Task UpdateRange(IEnumerable entities) where T: class, IEntity
64 | {
65 | await Task.Run(() => _context.Set().UpdateRange(entities));
66 | }
67 |
68 | public async Task SaveChangesAsync()
69 | {
70 | return await _context.SaveChangesAsync();
71 | }
72 |
73 | public IQueryable GetAll() where T: class, IEntity
74 | {
75 | return _context.Set().AsQueryable();
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/Repositories/IDbRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 | using System.Threading.Tasks;
6 | using DevelopersGame.DataAccess.Entities;
7 |
8 | namespace DevelopersGame.DataAccess.Repositories
9 | {
10 | public interface IDbRepository
11 | {
12 | IQueryable Get(Expression> selector) where T: class, IEntity;
13 | IQueryable Get() where T: class, IEntity;
14 | IQueryable GetAll() where T : class, IEntity;
15 |
16 | Task Add(T newEntity) where T: class, IEntity;
17 | Task AddRange(IEnumerable newEntities) where T: class, IEntity;
18 |
19 | Task Delete(Guid entity) where T : class, IEntity;
20 |
21 | Task Remove(T entity) where T: class, IEntity;
22 | Task RemoveRange(IEnumerable entities) where T: class, IEntity;
23 |
24 | Task Update(T entity) where T: class, IEntity;
25 | Task UpdateRange(IEnumerable entities) where T: class, IEntity;
26 |
27 | Task SaveChangesAsync();
28 | }
29 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.DataAccess/migration.ps1:
--------------------------------------------------------------------------------
1 | // execute in WebProject
2 |
3 | dotnet ef migrations add name -c DataContext --project ../DevelopersGame.DataAccess.Migrations
4 | dotnet ef database update -c DataContext --project ../DevelopersGame.DataAccess.Migrations
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Abstractions/ICommandService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DevelopersGame.Domain.Abstractions
4 | {
5 | public interface ICommandService
6 | {
7 | List Get();
8 | }
9 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Abstractions/TelegramCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Telegram.Bot;
3 | using Telegram.Bot.Types;
4 |
5 | namespace DevelopersGame.Domain.Abstractions
6 | {
7 | public abstract class TelegramCommand
8 | {
9 | public abstract string Name { get; }
10 |
11 | public abstract Task Execute(Message message, ITelegramBotClient client);
12 |
13 | public abstract bool Contains(Message message);
14 | }
15 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Commands/HelpCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using DevelopersGame.Domain.Abstractions;
3 | using Telegram.Bot;
4 | using Telegram.Bot.Types;
5 | using Telegram.Bot.Types.Enums;
6 | using Telegram.Bot.Types.ReplyMarkups;
7 |
8 | namespace DevelopersGame.Domain.Commands
9 | {
10 | public class HelpCommand: TelegramCommand
11 | {
12 | public override string Name { get; } = "\U0001F4D6 Помощь";
13 | public override async Task Execute(Message message, ITelegramBotClient client)
14 | {
15 | var chatId = message.Chat.Id;
16 | var keyBoard = new ReplyKeyboardMarkup
17 | {
18 | Keyboard = new[]
19 | {
20 | new[]
21 | {
22 | new KeyboardButton("\U0001F3E0 Главная")
23 | },
24 | new[]
25 | {
26 | new KeyboardButton("\U0001F451 Ранк")
27 | },
28 | new []
29 | {
30 | new KeyboardButton("\U0001F45C Магазин")
31 | },
32 | new []
33 | {
34 | new KeyboardButton("\U0001F4D6 Помощь")
35 | }
36 | }
37 | };
38 | await client.SendTextMessageAsync(chatId, "\U0001F4D6 Помощь",
39 | parseMode: ParseMode.Markdown, replyMarkup:keyBoard);
40 | }
41 |
42 | public override bool Contains(Message message)
43 | {
44 | if (message.Type != MessageType.Text)
45 | return false;
46 |
47 | return message.Text.Contains(Name);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Commands/MainCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using DevelopersGame.Domain.Abstractions;
3 | using Telegram.Bot;
4 | using Telegram.Bot.Types;
5 | using Telegram.Bot.Types.Enums;
6 | using Telegram.Bot.Types.ReplyMarkups;
7 |
8 | namespace DevelopersGame.Domain.Commands
9 | {
10 | public class MainCommand: TelegramCommand
11 | {
12 | public override string Name { get; } = "\U0001F3E0 Главная";
13 | public override async Task Execute(Message message, ITelegramBotClient client)
14 | {
15 | var chatId = message.Chat.Id;
16 | var keyBoard = new ReplyKeyboardMarkup
17 | {
18 | Keyboard = new[]
19 | {
20 | new[]
21 | {
22 | new KeyboardButton("\U0001F3E0 Главная")
23 | },
24 | new[]
25 | {
26 | new KeyboardButton("\U0001F451 Ранк")
27 | },
28 | new []
29 | {
30 | new KeyboardButton("\U0001F45C Магазин")
31 | },
32 | new []
33 | {
34 | new KeyboardButton("\U0001F4D6 Помощь")
35 | }
36 | }
37 | };
38 | await client.SendTextMessageAsync(chatId, "\U0001F3E0 Главная страница!",
39 | parseMode: ParseMode.Html, replyMarkup:keyBoard);
40 | }
41 |
42 | public override bool Contains(Message message)
43 | {
44 | if (message.Type != MessageType.Text)
45 | return false;
46 |
47 | return message.Text.Contains(Name);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Commands/RankCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using DevelopersGame.Domain.Abstractions;
3 | using Telegram.Bot;
4 | using Telegram.Bot.Types;
5 | using Telegram.Bot.Types.Enums;
6 | using Telegram.Bot.Types.ReplyMarkups;
7 |
8 | namespace DevelopersGame.Domain.Commands
9 | {
10 | public class RankCommand:TelegramCommand
11 | {
12 | public override string Name { get; } = "\U0001F451 Ранк";
13 | public override async Task Execute(Message message, ITelegramBotClient client)
14 | {
15 | var chatId = message.Chat.Id;
16 | var keyBoard = new ReplyKeyboardMarkup
17 | {
18 | Keyboard = new[]
19 | {
20 | new[]
21 | {
22 | new KeyboardButton("\U0001F3E0 Главная")
23 | },
24 | new[]
25 | {
26 | new KeyboardButton("\U0001F451 Ранк")
27 | },
28 | new []
29 | {
30 | new KeyboardButton("\U0001F45C Магазин")
31 | },
32 | new []
33 | {
34 | new KeyboardButton("\U0001F4D6 Помощь")
35 | }
36 | }
37 | };
38 | await client.SendTextMessageAsync(chatId, "\U0001F451 Ранк",
39 | parseMode: ParseMode.Html, replyMarkup:keyBoard);
40 | }
41 |
42 | public override bool Contains(Message message)
43 | {
44 | if (message.Type != MessageType.Text)
45 | return false;
46 |
47 | return message.Text.Contains(Name);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Commands/ShopCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using DevelopersGame.Domain.Abstractions;
3 | using Telegram.Bot;
4 | using Telegram.Bot.Types;
5 | using Telegram.Bot.Types.Enums;
6 | using Telegram.Bot.Types.ReplyMarkups;
7 |
8 | namespace DevelopersGame.Domain.Commands
9 | {
10 | public class ShopCommand: TelegramCommand
11 | {
12 | public override string Name { get; } = "\U0001F45C Магазин";
13 | public override async Task Execute(Message message, ITelegramBotClient client)
14 | {
15 | var chatId = message.Chat.Id;
16 | var keyBoard = new ReplyKeyboardMarkup
17 | {
18 | Keyboard = new[]
19 | {
20 | new[]
21 | {
22 | new KeyboardButton("\U0001F3E0 Главная")
23 | },
24 | new[]
25 | {
26 | new KeyboardButton("\U0001F451 Ранк")
27 | },
28 | new []
29 | {
30 | new KeyboardButton("\U0001F45C Магазин")
31 | },
32 | new []
33 | {
34 | new KeyboardButton("\U0001F4D6 Помощь")
35 | }
36 | }
37 | };
38 | await client.SendTextMessageAsync(chatId, "\U0001F45C Магазин",
39 | parseMode: ParseMode.Html, replyMarkup:keyBoard);
40 | }
41 |
42 | public override bool Contains(Message message)
43 | {
44 | if (message.Type != MessageType.Text)
45 | return false;
46 |
47 | return message.Text.Contains(Name);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Commands/StartCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using DevelopersGame.Domain.Abstractions;
3 | using Telegram.Bot;
4 | using Telegram.Bot.Types;
5 | using Telegram.Bot.Types.Enums;
6 | using Telegram.Bot.Types.ReplyMarkups;
7 |
8 | namespace DevelopersGame.Domain.Commands
9 | {
10 | public class StartCommand : TelegramCommand
11 | {
12 | public override string Name => @"/start";
13 |
14 | public override bool Contains(Message message)
15 | {
16 | if (message.Type != MessageType.Text)
17 | return false;
18 |
19 | return message.Text.Contains(Name);
20 | }
21 |
22 | public override async Task Execute(Message message, ITelegramBotClient botClient)
23 | {
24 | var chatId = message.Chat.Id;
25 |
26 | var keyBoard = new ReplyKeyboardMarkup
27 | {
28 | Keyboard = new[]
29 | {
30 | new[]
31 | {
32 | new KeyboardButton("\U0001F3E0 Главная")
33 | },
34 | new[]
35 | {
36 | new KeyboardButton("\U0001F451 Ранк")
37 | },
38 | new []
39 | {
40 | new KeyboardButton("\U0001F45C Магазин")
41 | },
42 | new []
43 | {
44 | new KeyboardButton("\U0001F4D6 Помощь")
45 | }
46 | }
47 | };
48 | await botClient.SendTextMessageAsync(chatId, "Привет! Тебе присвоено звание Intern! Чтоб достичь больших " +
49 | "успехов, тебе необходимо накопить определенное количество монет(К-от слова контрибуций)! Дерзай!",
50 | parseMode: ParseMode.Html, false, false, 0, keyBoard);
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/DevelopersGame.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/DevelopersGame.Domain/Services/CommandService.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using DevelopersGame.Domain.Abstractions;
3 | using DevelopersGame.Domain.Commands;
4 |
5 | namespace DevelopersGame.Domain.Services
6 | {
7 | public class CommandService: ICommandService
8 | {
9 | private readonly List _commands;
10 |
11 | public CommandService()
12 | {
13 | _commands = new List
14 | {
15 | new HelpCommand(),
16 | new MainCommand(),
17 | new RankCommand(),
18 | new ShopCommand(),
19 | new StartCommand()
20 | };
21 | }
22 |
23 | public List Get() => _commands;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Web/Controllers/BotController.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using DevelopersGame.Domain.Abstractions;
3 | using Microsoft.AspNetCore.Mvc;
4 | using Telegram.Bot;
5 | using Telegram.Bot.Types;
6 |
7 | namespace DevelopersGame.Web.Controllers
8 | {
9 | [ApiController]
10 | [Route("api/message/update")]
11 | public class BotController : Controller
12 | {
13 | private readonly ITelegramBotClient _telegramBotClient;
14 | private readonly ICommandService _commandService;
15 | public BotController(ICommandService commandService, ITelegramBotClient telegramBotClient)
16 | {
17 | _commandService = commandService;
18 | _telegramBotClient = telegramBotClient;
19 | }
20 |
21 | [HttpGet]
22 | public IActionResult Get()
23 | {
24 | return Ok("Started");
25 | }
26 |
27 | [HttpPost]
28 | public async Task Post([FromBody]Update update)
29 | {
30 | if (update == null) return Ok();
31 |
32 | var message = update.Message;
33 |
34 | foreach (var command in _commandService.Get())
35 | {
36 | if (command.Contains(message))
37 | {
38 | await command.Execute(message, _telegramBotClient);
39 | break;
40 | }
41 | }
42 | return Ok();
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Web/DevelopersGame.Web.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/DevelopersGame.Web/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace DevelopersGame.Web
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); });
22 | }
23 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Web/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:9008",
7 | "sslPort": 44312
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "DevelopersGame.Web": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
22 | "environmentVariables": {
23 | "ASPNETCORE_ENVIRONMENT": "Development"
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/DevelopersGame.Web/ServiceCollectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Configuration;
2 | using Microsoft.Extensions.DependencyInjection;
3 | using Telegram.Bot;
4 |
5 | namespace DevelopersGame.Web
6 | {
7 | public static class ServiceCollectionExtensions
8 | {
9 | public static IServiceCollection AddTelegramBotClient(this IServiceCollection serviceCollection,
10 | IConfiguration configuration)
11 | {
12 | var client = new TelegramBotClient(configuration["Token"]);
13 | var webHook = $"{configuration["Url"]}/api/message/update";
14 | client.SetWebhookAsync(webHook).Wait();
15 |
16 | return serviceCollection
17 | .AddTransient(x=> client);
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Web/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using DevelopersGame.DataAccess;
3 | using DevelopersGame.DataAccess.Repositories;
4 | using DevelopersGame.Domain.Abstractions;
5 | using DevelopersGame.Domain.Services;
6 | using FluentValidation.AspNetCore;
7 | using Microsoft.AspNetCore.Builder;
8 | using Microsoft.AspNetCore.Hosting;
9 | using Microsoft.EntityFrameworkCore;
10 | using Microsoft.Extensions.Configuration;
11 | using Microsoft.Extensions.DependencyInjection;
12 | using Newtonsoft.Json.Serialization;
13 |
14 | namespace DevelopersGame.Web
15 | {
16 | public class Startup
17 | {
18 | private readonly IConfiguration _configuration;
19 |
20 | public Startup(IConfiguration configuration)
21 | {
22 | _configuration = configuration;
23 | }
24 |
25 | public void ConfigureServices(IServiceCollection services)
26 | {
27 | services.AddDbContext(options =>
28 | {
29 | options
30 | .UseNpgsql(_configuration.GetConnectionString("DefaultConnection"),
31 | assembly =>
32 | assembly.MigrationsAssembly("DevelopersGame.DataAccess.Migrations"));
33 | });
34 |
35 | services
36 | .AddScoped()
37 | //.AddScoped()
38 | .AddTelegramBotClient(_configuration)
39 | .AddControllers()
40 | .AddNewtonsoftJson(options =>
41 | {
42 | options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
43 | options.SerializerSettings.ContractResolver = new DefaultContractResolver();
44 | })
45 | .AddFluentValidation();
46 | }
47 |
48 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
49 | {
50 | app.UseDeveloperExceptionPage();
51 | app.UseRouting();
52 |
53 | app.UseEndpoints(endpoints =>
54 | {
55 | endpoints.MapDefaultControllerRoute();
56 | });
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/DevelopersGame.Web/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "DefaultConnection": "Server=localhost;Port=5432;Database=DevelopersGame; User Id=postgres;Password=123"
4 | },
5 | "Url": "https://app179-505f2.app.deploy-f.com",
6 | "Token": "1083274215:AAF99Lp4kt4gNHQAUi6HZrrZLiMu_bJOX4s"
7 | }
8 |
--------------------------------------------------------------------------------