-
Notifications
You must be signed in to change notification settings - Fork 1
/
handlers.py
2231 lines (1975 loc) · 128 KB
/
handlers.py
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
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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
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
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from main import gostbot as gostbot
from buttons import *
# Словарь для добавления списков пользователей для состовляющих ГОСТ-ов (Например: имя книги, год издания и тд.)
gost_dict = dict()
#Итак здесь будут списки городов исключений(чтобы не писать по нескольку раз)
SPB = ["Санкт-Петербург", "Санкт Петербург", "cанкт-петербург","Питер", "питер", "СПБ", "CПб", "спб"]
MSC = ["Москва", "Москоу", "москва"]
# Handler - штука, которая исполняет по команде определённые действия
# В фильтрах можно указать определенную команду после которой будут выполняться действия
# Handler для вывода главного меню
@gostbot.message_handler(commands=["start"])
def main(message):
id_chat = message.chat.id
print(id_chat)
if id_chat not in gost_dict:
gost_dict[id_chat] = []
username = message.from_user
print(username)
gostbot.send_message(id_chat, f"Привет, {username.first_name}, я продвинутый инструмент для гостов - GOSTOVIC")
# Бот может отсылать сообщения с встроенной клавиатурой reply_markup
# Которая может быть как inline, так и обычной
# Здесь сообщению передается значение функции markup_main, которая возращает inline клавиатуру
gostbot.send_message(id_chat, "Выберите одну из категорий:", reply_markup=markup_main())
# УЧЕНИКИ
# 2003 год
# Handler для работы с журналом ГОСТ-а 2003 года
@gostbot.message_handler(commands=["Начать_Journal-2003"])
def jour_avtors_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите авторов\nОбразец: Иванов А.А., Петров А.А.")
gostbot.register_next_step_handler(send, jour_tema_2003)
def jour_tema_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите тему")
gostbot.register_next_step_handler(send, jour_name_2003)
def jour_name_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название журнала")
gostbot.register_next_step_handler(send, jour_year_2003)
def jour_year_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите год издания (только цифра)")
gostbot.register_next_step_handler(send, jour_nomer_2003)
def jour_nomer_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер журнала (только цифра)")
gostbot.register_next_step_handler(send, jour_pages_2003)
def jour_pages_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите страницы журнала (через тире)\nОбразец: 65-70")
gostbot.register_next_step_handler(send, journal_result_2003)
def journal_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
jour_avtors = [""]*3
counter = 0
print(gost_dict[id_chat][0].split(",")[:3])
for i in gost_dict[id_chat][0].split(",")[:3]:
jour_avtors[counter] = i
counter += 1
print(jour_avtors)
tema = (gost_dict[id_chat][1][0].capitalize() + gost_dict[id_chat][1][1:]).replace("\n"," ")
journal_name = gost_dict[id_chat][2][0].capitalize() + gost_dict[id_chat][2][1:]
year = gost_dict[id_chat][3].capitalize()
nomer = gost_dict[id_chat][4]
pages = gost_dict[id_chat][5]
a1_f = jour_avtors[0].strip()[:jour_avtors[0].strip().find(" ")].capitalize()
a1_name = jour_avtors[0].strip()[jour_avtors[0].strip().find(" ")+1:]
a1_name = a1_name[0].capitalize() + a1_name[1] + a1_name[2].capitalize() + a1_name[3]
if jour_avtors.count('') == 0:
result = f"""{a1_f}, {a1_name} {tema} [Текст] / {a1_name} {a1_f} и др. // {journal_name}. — {year}. — № {nomer}. — C. {pages}."""
elif jour_avtors.count('') == 1:
a2 = jour_avtors[1].strip()[jour_avtors[1].strip().index(" ")+1:] + " " + jour_avtors[1].strip()[:jour_avtors[1].strip().index(" ")]
result = f"""{a1_f}, {a1_name} {tema} [Текст] / {a1_name} {a1_f}, {a2} // {journal_name}. — {year}. — № {nomer}. — C. {pages}."""
else:
result = f"""{a1_f}, {a1_name} {tema} [Текст] / {a1_name} {a1_f} // {journal_name}. — {year}. — № {nomer}. — C. {pages}."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Journal-2003`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Book-Normal-2003"])
def book_normal_avtors_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите авторов\nОбразец: Иванов А.А., Петров А.А.")
gostbot.register_next_step_handler(send, book_normal_name_2003)
def book_normal_name_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название")
gostbot.register_next_step_handler(send, book_normal_add_inf_2003)
def book_normal_add_inf_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите доп. сведения, относящиеся к названию (заглавию) если они есть\nЕсли их нет введите: . \nОбразец: учебник")
gostbot.register_next_step_handler(send, book_normal_responsibility_2003)
def book_normal_responsibility_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите доп. сведения об ответственности если они есть\nЕсли их нет введите: . \nОбразец: отв. ред. П. П. Петров ; пер. с англ. С. С. Сидорова")
gostbot.register_next_step_handler(send, book_normal_reissues_2003)
def book_normal_reissues_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите доп. информацию о издании, исправлениях и дополнениях\nЕсли ничего такого нет напишите: . \nОбразец: 6-е изд., испр. и доп.")
gostbot.register_next_step_handler(send, book_normal_city_2003)
def book_normal_city_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите город")
gostbot.register_next_step_handler(send, book_normal_publish_2003)
def book_normal_publish_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название издательства")
gostbot.register_next_step_handler(send, book_normal_year_2003)
def book_normal_year_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name} введите год издания (только цифра)")
gostbot.register_next_step_handler(send, book_normal_pages_2003)
def book_normal_pages_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите количество страниц\nОбразец: 65")
gostbot.register_next_step_handler(send, book_normal_result_2003)
def book_normal_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
book_avtors = [""]*5
counter = 0
print(gost_dict[id_chat][0].split(",")[:5])
for i in gost_dict[id_chat][0].split(",")[:5]:
book_avtors[counter] = i
counter += 1
print(book_avtors)
name = gost_dict[id_chat][1][0].capitalize() + gost_dict[id_chat][1][1:]
if gost_dict[id_chat][2] != ".":
add_inf = " : " + gost_dict[id_chat][2]
else:
add_inf = ""
if gost_dict[id_chat][3] != ".":
responsibility = " / " + gost_dict[id_chat][3]
else:
responsibility = ""
if gost_dict[id_chat][4] != ".":
reissues = " " + gost_dict[id_chat][4] + " — "
else:
reissues = ""
if gost_dict[id_chat][5].lower() in SPB:
city = "СПб."
elif gost_dict[id_chat][5].lower() in MSC:
city = "М."
else:
city = gost_dict[id_chat][5][0].capitalize() + gost_dict[id_chat][5][1:]
publish = gost_dict[id_chat][6][0].capitalize() + gost_dict[id_chat][6][1:]
year = gost_dict[id_chat][7]
pages = gost_dict[id_chat][8]
a1_f = book_avtors[0].strip()[:book_avtors[0].strip().find(" ")]
a1_name = book_avtors[0].strip()[book_avtors[0].strip().find(" ")+1:]
if book_avtors.count('') == 0:
a2 = book_avtors[1].strip()[book_avtors[1].strip().index(" ")+1:] + " " + book_avtors[1].strip()[:book_avtors[1].strip().index(" ")]
a3 = book_avtors[2].strip()[book_avtors[2].strip().index(" ")+1:] + " " + book_avtors[2].strip()[:book_avtors[1].strip().index(" ")]
result = f"""{name} [Текст]{add_inf} / {a1_name} {a1_f}, {a2}, {a3} и др.{responsibility} —{reissues} {city} : {publish}, {year}. — {pages} c."""
elif book_avtors.count('') == 1:
a2 = book_avtors[1].strip()[book_avtors[1].strip().index(" ")+1:] + " " + book_avtors[1].strip()[:book_avtors[1].strip().index(" ")]
a3 = book_avtors[2].strip()[book_avtors[2].strip().index(" ")+1:] + " " + book_avtors[2].strip()[:book_avtors[1].strip().index(" ")]
a4 = book_avtors[3].strip()[book_avtors[3].strip().index(" ")+1:] + " " + book_avtors[3].strip()[:book_avtors[1].strip().index(" ")]
result = f"""{name} [Текст]{add_inf} / {a1_name} {a1_f}, {a2}, {a3}, {a4}{responsibility} —{reissues} {city} : {publish}, {year}. — {pages} c."""
elif book_avtors.count('') == 2:
a2 = book_avtors[1].strip()[book_avtors[1].strip().index(" ")+1:] + " " + book_avtors[1].strip()[:book_avtors[1].strip().index(" ")]
a3 = book_avtors[2].strip()[book_avtors[2].strip().index(" ")+1:] + " " + book_avtors[2].strip()[:book_avtors[1].strip().index(" ")]
result = f"""{a1_f}, {a1_name} {name} [Текст]{add_inf} / {a1_name} {a1_f}, {a2}, {a3}{responsibility} —{reissues} {city} : {publish}, {year}. — {pages} c."""
elif book_avtors.count('') == 3:
a2 = book_avtors[1].strip()[book_avtors[1].strip().index(" ")+1:] + " " + book_avtors[1].strip()[:book_avtors[1].strip().index(" ")]
result = f"""{a1_f}, {a1_name} {name} [Текст]{add_inf} / {a1_name} {a1_f}, {a2}{responsibility} —{reissues} {city} : {publish}, {year}. — {pages} c."""
else:
result = f"""{a1_f}, {a1_name} {name} [Текст]{add_inf} / {a1_name} {a1_f}{responsibility} —{reissues} {city} : {publish}, {year}. — {pages} c."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Book-Normal-2003`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Ethernet-2003"])
def name_of_eth_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название ресурса")
gostbot.register_next_step_handler(send, url_2003)
def url_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите URL")
gostbot.register_next_step_handler(send, date_2003)
def date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите время обращения\nОбразец: 22.01.2023")
gostbot.register_next_step_handler(send, result_eth_2003)
def result_eth_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
name = gost_dict[id_chat][0][0].upper() + gost_dict[id_chat][0][1:]
result = f"""{name} [Электронный ресурс]. — URL: {gost_dict[id_chat][1]} (Дата обращения: {gost_dict[id_chat][2]})."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Ethernet-2003`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Dissertation-2003"])
def dissert_avtor_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите автора диссертации\nОбразец: Иванов Александр Александорович")
gostbot.register_next_step_handler(send, dissert_name_2003)
def dissert_name_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название диссертации")
gostbot.register_next_step_handler(send, dissert_rang_2003)
def dissert_rang_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите ученую степень автора диссертации Образец: канд. ист. наук")
gostbot.register_next_step_handler(send, dissert_shifr_vac_2003)
def dissert_shifr_vac_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите шифр ВАК если он есть, в противном случае вводите: . \nОбразец: 13.00.05")
gostbot.register_next_step_handler(send, dissert_city_2003)
def dissert_city_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите город")
gostbot.register_next_step_handler(send, dissert_year_2003)
def dissert_year_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите год защиты (Просто цифра)")
gostbot.register_next_step_handler(send, dissert_pages_2003)
def dissert_pages_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите количество страниц\nОбразец: 65")
gostbot.register_next_step_handler(send, dissert_result_2003)
def dissert_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
dissert_avtor = gost_dict[id_chat][0].split()
print(dissert_avtor)
dissert_name = (gost_dict[id_chat][1][0].capitalize() + gost_dict[id_chat][1][1:]).replace("\n"," ")
dissert_rang = gost_dict[id_chat][2]
if gost_dict[id_chat][3] != ".":
dissert_shifr_vac = " : " + gost_dict[id_chat][3]
else:
dissert_shifr_vac = ""
if gost_dict[id_chat][4].lower() in SPB:
dissert_city = "СПб."
elif gost_dict[id_chat][4].lower() in MSC:
dissert_city = "М."
else:
dissert_city = gost_dict[id_chat][4][0].capitalize() + gost_dict[id_chat][4][1:]
dissert_year = gost_dict[id_chat][5]
dissert_pages = gost_dict[id_chat][6]
result = f"""{dissert_avtor[0]}, {dissert_avtor[1][0]}.{dissert_avtor[2][0]}. {dissert_name} [Текст] : дис. ... {dissert_rang}{dissert_shifr_vac} / {dissert_avtor[0]} {dissert_avtor[1]} {dissert_avtor[2]}. — {dissert_city}, {dissert_year}. — {dissert_pages} с."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Dissertation-2003`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Aftoreferat-2003"])
def aftoref_avtor_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите автора автореферата\nОбразец: Иванов Александр Александорович")
gostbot.register_next_step_handler(send, aftoref_name_2003)
def aftoref_name_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название автореферата")
gostbot.register_next_step_handler(send, aftoref_rang_2003)
def aftoref_rang_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите ученую степень автора автореферата Образец: канд. ист. наук")
gostbot.register_next_step_handler(send, aftoref_shifr_vac_2003)
def aftoref_shifr_vac_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите шифр ВАК если он есть, в противном случае вводите: . \nОбразец: 13.00.05")
gostbot.register_next_step_handler(send, aftoref_city_2003)
def aftoref_city_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите город")
gostbot.register_next_step_handler(send, aftoref_year_2003)
def aftoref_year_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите год защиты (Просто цифра)")
gostbot.register_next_step_handler(send, aftoref_pages_2003)
def aftoref_pages_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите количество страниц\nОбразец: 65")
gostbot.register_next_step_handler(send, aftoref_result_2003)
def aftoref_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
aftoref_avtor = gost_dict[id_chat][0].split()
aftoref_name = (gost_dict[id_chat][1][0].capitalize() + gost_dict[id_chat][1][1:]).replace("\n"," ")
aftoref_rang = gost_dict[id_chat][2]
if gost_dict[id_chat][3] != ".":
aftoref_shifr_vac = " : " + gost_dict[id_chat][3]
else:
aftoref_shifr_vac = ""
if gost_dict[id_chat][4].lower() in SPB:
aftoref_city = "СПб."
elif gost_dict[id_chat][4].lower() in MSC:
aftoref_city = "М."
else:
aftoref_city = gost_dict[id_chat][4][0].capitalize() + gost_dict[id_chat][4][1:]
aftoref_year = gost_dict[id_chat][5]
aftoref_pages = gost_dict[id_chat][6]
result = f"""{aftoref_avtor[0]}, {aftoref_avtor[1][0]}.{aftoref_avtor[2][0]}. {aftoref_name} [Текст] : афтореф. дис. ... {aftoref_rang}{aftoref_shifr_vac} / {aftoref_avtor[0]} {aftoref_avtor[1]} {aftoref_avtor[2]}. — {aftoref_city}, {aftoref_year}. — {aftoref_pages} c."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Aftoreferat-2003`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Zakon-2003_Document"])
def zakon_document_name_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите полное название документа\nОбразец: Конституция РФ")
gostbot.register_next_step_handler(send, zakon_document_izd_date_2003)
def zakon_document_izd_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату от которой был издан закон\nОбразец: 18.04.2007")
gostbot.register_next_step_handler(send, zakon_document_num_fz_2003)
def zakon_document_num_fz_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер ФЗ (только цифра)")
gostbot.register_next_step_handler(send, zakon_document_redact_date_2003)
def zakon_document_redact_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату редактирования\nОбразец: 27.12.2018")
gostbot.register_next_step_handler(send, zakon_document_who_accept_2003)
def zakon_document_who_accept_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название гос. органа, принявшего/учредившего закон\nОбразец: СЗ РФ")
gostbot.register_next_step_handler(send, zakon_document_pechat_date_2003)
def zakon_document_pechat_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату печати Образец: 09.05.2011")
gostbot.register_next_step_handler(send, zakon_document_num_2003)
def zakon_document_num_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер издания")
gostbot.register_next_step_handler(send, zakon_document_statya_2003)
def zakon_document_statya_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите статью")
gostbot.register_next_step_handler(send, zakon_document_result_2003)
def zakon_document_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
name = (gost_dict[id_chat][0][0].capitalize() + gost_dict[id_chat][0][1:]).replace("\n"," ")
izd_date = gost_dict[id_chat][1]
num_fz = gost_dict[id_chat][2]
redact_date = gost_dict[id_chat][3]
who_accept = gost_dict[id_chat][4][0].capitalize() + gost_dict[id_chat][4][1:]
pechat_date = gost_dict[id_chat][5]
num = gost_dict[id_chat][6]
statya = gost_dict[id_chat][7]
result = f"{name} от {izd_date} № {num_fz}-ФЗ (ред. от {redact_date}) // {who_accept}. — {pechat_date} — № {num} — Ст. {statya}."
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`Начать_Zakon-2003_Document`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Zakon-2003_Federation"])
def zakon_federation_name_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите полное название закона (без кавычек!)\nОбразец: О лицензировании отдельных видов деятельности")
gostbot.register_next_step_handler(send, zakon_federation_izd_date_2003)
def zakon_federation_izd_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату от которой был издан закон\nОбразец: 18.04.2007")
gostbot.register_next_step_handler(send, zakon_federation_num_fz_2003)
def zakon_federation_num_fz_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер ФЗ (только цифра)")
gostbot.register_next_step_handler(send, zakon_federation_redact_date_2003)
def zakon_federation_redact_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату редактирования\nОбразец: 27.12.2018")
gostbot.register_next_step_handler(send, zakon_federation_who_accept_2003)
def zakon_federation_who_accept_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название гос. органа, принявшего/учредившего закон\n Образуц: СЗ РФ")
gostbot.register_next_step_handler(send, zakon_federation_pechat_date_2003)
def zakon_federation_pechat_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату печати Образец: 09.05.2011")
gostbot.register_next_step_handler(send, zakon_federation_num_2003)
def zakon_federation_num_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер издания")
gostbot.register_next_step_handler(send, zakon_federation_statya_2003)
def zakon_federation_statya_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите статью")
gostbot.register_next_step_handler(send, zakon_federation_result_2003)
def zakon_federation_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
name = (gost_dict[id_chat][0][0].capitalize() + gost_dict[id_chat][0][1:]).replace("\n"," ")
izd_date = gost_dict[id_chat][1]
num_fz = gost_dict[id_chat][2]
redact_date = gost_dict[id_chat][3]
who_accept = gost_dict[id_chat][4][0].capitalize() + gost_dict[id_chat][4][1:]
pechat_date = gost_dict[id_chat][5]
num = gost_dict[id_chat][6]
statya = gost_dict[id_chat][7]
result = f"Федеральный закон от {izd_date} № {num_fz}-ФЗ (ред. от {redact_date}) «{name}» // {who_accept}. — {pechat_date} — № {num} — Ст. {statya}."
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Zakon-2003_Federation`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Zakon-2003_Federation_Internet"])
def zakon_federation_internet_name_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите полное название закона (без кавычек)\nОбразец: О лицензировании отдельных видов деятельности")
gostbot.register_next_step_handler(send, zakon_federation_internet_izd_date_2003)
def zakon_federation_internet_izd_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату от которой был издан закон\nОбразец: 18.04.2007")
gostbot.register_next_step_handler(send, zakon_federation_internet_num_fz_2003)
def zakon_federation_internet_num_fz_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер ФЗ (Просто цифра)")
gostbot.register_next_step_handler(send, zakon_federation_internet_redact_date_2003)
def zakon_federation_internet_redact_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату редактирования\nОбразец: 27.12.2018")
gostbot.register_next_step_handler(send, zakon_federation_internet_url_2003)
def zakon_federation_internet_url_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите URL сайта на котором расположен закон")
gostbot.register_next_step_handler(send, zakon_federation_internet_result_2003)
def zakon_federation_internet_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
name = (gost_dict[id_chat][0][0].capitalize() + gost_dict[id_chat][0][1:]).replace("\n"," ")
izd_date = gost_dict[id_chat][1]
num_fz = gost_dict[id_chat][2]
redact_date = gost_dict[id_chat][3]
url = gost_dict[id_chat][4]
result = f"Федеральный закон от {izd_date} № {num_fz}-ФЗ (ред. от {redact_date}) «{name}» [Электронный ресурс]. — URL: {url}"
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Zakon-2003_Federation_Internet`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Zakon-2003_Postanovlenie"])
def zakon_postan_name_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите полное название постановления (без кавычек)")
gostbot.register_next_step_handler(send, zakon_postan_who_postan_2003)
def zakon_postan_who_postan_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите чьё именно постановиление\nОбразец: Правительства РФ")
gostbot.register_next_step_handler(send, zakon_postan_izd_date_2003)
def zakon_postan_izd_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату от которой был издан закон\nОбразец: 18.04.2007")
gostbot.register_next_step_handler(send, zakon_postan_num_postan_2003)
def zakon_postan_num_postan_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер постановления (только цифра)")
gostbot.register_next_step_handler(send, zakon_postan_redact_date_2003)
def zakon_postan_redact_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату редактирования\nОбразец: 27.12.2018")
gostbot.register_next_step_handler(send, zakon_postan_who_accept_2003)
def zakon_postan_who_accept_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название Гос. органа, принявшего/учредившего закон\nОбразец: ФЗ РФ")
gostbot.register_next_step_handler(send, zakon_postan_pechat_date_2003)
def zakon_postan_pechat_date_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите дату печати Образец: 09.05.2011")
gostbot.register_next_step_handler(send, zakon_postan_num_2003)
def zakon_postan_num_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер издания")
gostbot.register_next_step_handler(send, zakon_postan_statya_2003)
def zakon_postan_statya_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите статью")
gostbot.register_next_step_handler(send, zakon_postan_result_2003)
def zakon_postan_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
name = (gost_dict[id_chat][0][0].capitalize() + gost_dict[id_chat][0][1:]).replace("\n"," ")
who_postan = gost_dict[id_chat][1]
izd_date = gost_dict[id_chat][2]
num_postan = gost_dict[id_chat][3]
redact_date = gost_dict[id_chat][4]
who_accept = gost_dict[id_chat][5][0].capitalize() + gost_dict[id_chat][5][1:]
pechat_date = gost_dict[id_chat][6]
num = gost_dict[id_chat][7]
statya = gost_dict[id_chat][8]
result = f"Постановление {who_postan} от {izd_date} № {num_postan} (ред. от {redact_date}) «{name}» // {who_accept}. — {pechat_date} — № {num} — Ст. {statya}."
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Zakon-2003_Postanovlenie`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Mnogotomnik-2003_toms"])
def book_mnogotomnic_toms_avtors_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите авторов\nОбразец: Иванов А.А., Петров А.А.")
gostbot.register_next_step_handler(send, book_mnogotomnic_toms_name_2003)
def book_mnogotomnic_toms_name_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название моготомного издания")
gostbot.register_next_step_handler(send, book_mnogotomnic_toms_count_toms_2003)
def book_mnogotomnic_toms_count_toms_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите количество томов всего (укажите только цифру)")
gostbot.register_next_step_handler(send, book_mnogotomnic_toms_add_inf_tom_2003)
def book_mnogotomnic_toms_add_inf_tom_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите информацию о номере вашего тома (укажите только цифру)")
gostbot.register_next_step_handler(send, book_mnogotomnic_toms_city_2003)
def book_mnogotomnic_toms_city_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите город")
gostbot.register_next_step_handler(send, book_mnogotomnic_toms_publish_2003)
def book_mnogotomnic_toms_publish_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название издательства")
gostbot.register_next_step_handler(send, book_mnogotomnic_toms_year_2003)
def book_mnogotomnic_toms_year_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите год издания (только цифра)")
gostbot.register_next_step_handler(send, book_mnogotomnic_toms_result_2003)
def book_mnogotomnic_toms_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
book_mnogotomnic_avtors = [""]*5
counter = 0
print(gost_dict[id_chat][0].split(",")[:5])
for i in gost_dict[id_chat][0].split(",")[:5]:
book_mnogotomnic_avtors[counter] = i
counter += 1
print(book_mnogotomnic_avtors)
name = gost_dict[id_chat][1][0].capitalize() + gost_dict[id_chat][1][1:]
count_toms = gost_dict[id_chat][2]
tom_num = gost_dict[id_chat][3]
if gost_dict[id_chat][4].lower() in SPB:
city = "СПб."
elif gost_dict[id_chat][4].lower() in MSC:
city = "М."
else:
city = gost_dict[id_chat][4][0].capitalize() + gost_dict[id_chat][4][1:]
publish = gost_dict[id_chat][5][0].capitalize() + gost_dict[id_chat][5][1:]
year = gost_dict[id_chat][6]
a1_f = book_mnogotomnic_avtors[0].strip()[:book_mnogotomnic_avtors[0].strip().find(" ")]
a1_name = book_mnogotomnic_avtors[0].strip()[book_mnogotomnic_avtors[0].strip().find(" ")+1:]
if book_mnogotomnic_avtors.count('') == 0:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a3 = book_mnogotomnic_avtors[2].strip()[book_mnogotomnic_avtors[2].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[2].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{name} [Текст] : в {count_toms} / {a1_name} {a1_f}, {a2}, {a3} и др. — {city} : {publish}, {year}. — {tom_num} т."""
elif book_mnogotomnic_avtors.count('') == 1:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a3 = book_mnogotomnic_avtors[2].strip()[book_mnogotomnic_avtors[2].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[2].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a4 = book_mnogotomnic_avtors[3].strip()[book_mnogotomnic_avtors[3].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[3].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{name} [Текст] : в {count_toms} т. / {a1_name} {a1_f}, {a2}, {a3}, {a4}. — {city} : {publish}, {year}. — {tom_num} т."""
elif book_mnogotomnic_avtors.count('') == 2:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a3 = book_mnogotomnic_avtors[2].strip()[book_mnogotomnic_avtors[2].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[2].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{a1_f}, {a1_name} {name} [Текст] : в {count_toms} т. / {a1_name} {a1_f}, {a2}, {a3}. — {city} : {publish}, {year}. — {tom_num} т."""
elif book_mnogotomnic_avtors.count('') == 3:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{a1_f}, {a1_name} {name} [Текст] : в {count_toms} т. / {a1_name} {a1_f}, {a2}. — {city} : {publish}, {year}. — {tom_num} т."""
else:
result = f"""{a1_f}, {a1_name} {name} [Текст] : в {count_toms} т. / {a1_name} {a1_f}. — {city} : {publish}, {year}. — {tom_num} т."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Mnogotomnik-2003_toms`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Mnogotomnik-2003_chapters"])
def book_mnogotomnic_chapters_avtors_2003(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите авторов\nОбразец: Иванов А.А., Петров А.А.")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_name_2003)
def book_mnogotomnic_chapters_name_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_count_chapters_2003)
def book_mnogotomnic_chapters_count_chapters_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите количество частей всего (укажите только цифру)")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_inf_chapter_2003)
def book_mnogotomnic_chapters_inf_chapter_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер вашей части (укажите только цифру)")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_inf_chapter_name_2003)
def book_mnogotomnic_chapters_inf_chapter_name_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название части")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_city_2003)
def book_mnogotomnic_chapters_city_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите город")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_publish_2003)
def book_mnogotomnic_chapters_publish_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название издательства")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_year_2003)
def book_mnogotomnic_chapters_year_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите год издания (только цифра)")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_pages_2003)
def book_mnogotomnic_chapters_pages_2003(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите количество страниц (только цифра)")
gostbot.register_next_step_handler(send, book_mnogotomnic_chapters_result_2003)
def book_mnogotomnic_chapters_result_2003(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
book_mnogotomnic_avtors = [""]*5
counter = 0
print(gost_dict[id_chat][0].split(",")[:5])
for i in gost_dict[id_chat][0].split(",")[:5]:
book_mnogotomnic_avtors[counter] = i
counter += 1
print(book_mnogotomnic_avtors)
name = gost_dict[id_chat][1][0].capitalize() + gost_dict[id_chat][1][1:]
count_chapters = gost_dict[id_chat][2]
chapter_num = gost_dict[id_chat][3]
chapter_name = gost_dict[id_chat][4][0].capitalize() + gost_dict[id_chat][4][1:]
if gost_dict[id_chat][5].lower() in SPB:
city = "СПб."
elif gost_dict[id_chat][5].lower() in MSC:
city = "М."
else:
city = gost_dict[id_chat][5][0].capitalize() + gost_dict[id_chat][5][1:]
publish = gost_dict[id_chat][6][0].capitalize() + gost_dict[id_chat][6][1:]
year = gost_dict[id_chat][7]
mnogotomnic_pages = gost_dict[id_chat][8]
a1_f = book_mnogotomnic_avtors[0].strip()[:book_mnogotomnic_avtors[0].strip().find(" ")]
a1_name = book_mnogotomnic_avtors[0].strip()[book_mnogotomnic_avtors[0].strip().find(" ")+1:]
if book_mnogotomnic_avtors.count('') == 0:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a3 = book_mnogotomnic_avtors[2].strip()[book_mnogotomnic_avtors[2].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[2].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{name} [Текст] : В {count_chapters} ч. Ч. {chapter_num} {chapter_name} / {a1_name} {a1_f}, {a2}, {a3} и др. — {city} : {publish}, {year}. — {mnogotomnic_pages} c."""
elif book_mnogotomnic_avtors.count('') == 1:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a3 = book_mnogotomnic_avtors[2].strip()[book_mnogotomnic_avtors[2].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[2].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a4 = book_mnogotomnic_avtors[3].strip()[book_mnogotomnic_avtors[3].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[3].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{name} [Текст] : В {count_chapters} ч. Ч. {chapter_num} {chapter_name} / {a1_name} {a1_f}, {a2}, {a3}, {a4}. — {city} : {publish}, {year}. — {mnogotomnic_pages} c."""
elif book_mnogotomnic_avtors.count('') == 2:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
a3 = book_mnogotomnic_avtors[2].strip()[book_mnogotomnic_avtors[2].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[2].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{a1_f}, {a1_name} {name} [Текст] : В {count_chapters} ч. Ч. {chapter_num} {chapter_name} / {a1_name} {a1_f}, {a2}, {a3}. — {city} : {publish}, {year}. — {mnogotomnic_pages} c."""
elif book_mnogotomnic_avtors.count('') == 3:
a2 = book_mnogotomnic_avtors[1].strip()[book_mnogotomnic_avtors[1].strip().index(" ")+1:] + " " + book_mnogotomnic_avtors[1].strip()[:book_mnogotomnic_avtors[1].strip().index(" ")]
result = f"""{a1_f}, {a1_name} {name} [Текст] : В {count_chapters} ч. Ч. {chapter_num} {chapter_name} / {a1_name} {a1_f}, {a2}. — {city} : {publish}, {year}. — {mnogotomnic_pages} c."""
else:
result = f"""{a1_f}, {a1_name} {name} [Текст] : В {count_chapters} ч. Ч. {chapter_num} {chapter_name} / {a1_name} {a1_f}. — {city} : {publish}, {year}. — {mnogotomnic_pages} c."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Mnogotomnik-2003_chapters`", parse_mode="MarkdownV2",reply_markup=back())
print(result)
gost_dict[id_chat].clear()
# 2008 год
# Handler для работы с журналом ГОСТ-а 2008 года
@gostbot.message_handler(commands=["Начать_Journal-2008"])
def jour_avtors_2008(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите авторов\nОбразец: Иванов А.А., Петров А.А.")
gostbot.register_next_step_handler(send, jour_tema_2008)
def jour_tema_2008(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите тему")
gostbot.register_next_step_handler(send, jour_name_2008)
def jour_name_2008(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите название журнала")
gostbot.register_next_step_handler(send, jour_year_2008)
def jour_year_2008(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите год издания (только цифра)")
gostbot.register_next_step_handler(send, jour_nomer_2008)
def jour_nomer_2008(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите номер журнала (только цифра)")
gostbot.register_next_step_handler(send, jour_pages_2008)
def jour_pages_2008(message):
id_chat = message.chat.id
username = message.from_user
gost_dict[id_chat].append(message.text)
send = gostbot.send_message(id_chat, f"{username.first_name}, введите страницы журнала (через тире)\nОбразец: 65-70")
gostbot.register_next_step_handler(send, journal_result_2008)
def journal_result_2008(message):
id_chat = message.chat.id
result = ""
gost_dict[id_chat].append(message.text)
jour_avtors = [""]*4
counter = 0
print(gost_dict[id_chat][0].split(",")[:4])
for i in gost_dict[id_chat][0].split(",")[:4]:
jour_avtors[counter] = i
counter += 1
print(jour_avtors)
tema = (gost_dict[id_chat][1][0].capitalize() + gost_dict[id_chat][1][1:]).replace("\n"," ")
journal_name = gost_dict[id_chat][2][0].capitalize() + gost_dict[id_chat][2][1:]
year = gost_dict[id_chat][3]
nomer = gost_dict[id_chat][4]
pages = gost_dict[id_chat][5]
a1_f = jour_avtors[0].strip()[:jour_avtors[0].strip().find(" ")]
a1_name = jour_avtors[0].strip()[jour_avtors[0].strip().find(" ")+1:]
if jour_avtors.count('') == 0:
result = f"""{tema} / {a1_name} {a1_f} и [др.] // {journal_name}. {year}. № {nomer}. C. {pages}."""
elif jour_avtors.count('') == 1:
a2 = jour_avtors[1].strip()[:jour_avtors[1].strip().index(" ")] + " " + jour_avtors[1].strip()[jour_avtors[1].strip().index(" ")+1:]
a3 = jour_avtors[2].strip()[:jour_avtors[2].strip().index(" ")] + " " + jour_avtors[2].strip()[jour_avtors[2].strip().index(" ")+1:]
result = f"""{a1_f} {a1_name}, {a2}, {a3} {tema} // {journal_name}. {year}. № {nomer}. C. {pages}."""
elif jour_avtors.count('') == 2:
a2 = jour_avtors[1].strip()[:jour_avtors[1].strip().index(" ")] + " " + jour_avtors[1].strip()[jour_avtors[1].strip().index(" ")+1:]
result = f"""{a1_f} {a1_name}, {a2} {tema} // {journal_name}. {year}. № {nomer}. C. {pages}."""
else:
result = f"""{a1_f} {a1_name} {tema} // {journal_name}. {year}. № {nomer}. C. {pages}."""
gostbot.send_message(id_chat, f"Твой ГОСТ готов \!\n`{result}`", parse_mode="MarkdownV2")
gostbot.send_message(id_chat, f"Чтобы воспользоваться этим оформлением снова введите:\n`/Начать_Journal-2008`", parse_mode="MarkdownV2")
print(result)
gost_dict[id_chat].clear()
@gostbot.message_handler(commands=["Начать_Book-Normal-2008"])
def book_normal_avtors_2008(message):
id_chat = message.chat.id
username = message.from_user
send = gostbot.send_message(id_chat, f"{username.first_name}, введите автора(ов), если их нет введите: . \nОбразец: Иванов А.А., Петров А.А.")
gostbot.register_next_step_handler(send, book_normal_name_2008)
def book_normal_name_2008(message):
id_chat = message.chat.id
username = message.from_user