Compare commits
	
		
			380 Commits
		
	
	
		
			3a1ea7e56c
			...
			main
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 72f96576ba | ||
|  | 81db0b2bdb | ||
|  | 2830335b12 | ||
|  | 7e52c86067 | ||
|  | 5f0d211a9b | ||
|  | f4a1cee509 | ||
| 3b4454fd44 | |||
| f7a13962f0 | |||
| 8a1013d280 | |||
| afc9b61e92 | |||
| 825d415766 | |||
| 567ce5f2ad | |||
| 1f3b4ec80f | |||
| a67531ce98 | |||
| 2542e601c1 | |||
| d173eb019b | |||
| 43148417c8 | |||
| 9f7ae4b9a7 | |||
|  | d41eeb3232 | ||
|  | 55e5303ab2 | ||
|  | 31235ef9ac | ||
|  | 6709eebb88 | ||
|  | 1533c5eb91 | ||
|  | 4c520b39fe | ||
|  | db842a1ceb | ||
|  | a571709afa | ||
|  | 192687a5ea | ||
|  | f20c90ea34 | ||
|  | 1b2410afc4 | ||
|  | 56450bc566 | ||
|  | aa3ea439fe | ||
|  | dae3f05aa7 | ||
|  | 66c2ef80c3 | ||
|  | 4a3f799284 | ||
|  | 7090ab218e | ||
|  | 53bac66692 | ||
|  | ee27dbfd7b | ||
|  | 14c238ec2f | ||
|  | 9d6d8791fd | ||
|  | d2b8c76817 | ||
|  | 48d53fd1b9 | ||
|  | 505d90aea8 | ||
|  | eb59091615 | ||
|  | c8a9936a00 | ||
|  | ecbe419abb | ||
|  | a58f6c404f | ||
|  | e677591b97 | ||
|  | c734044b71 | ||
|  | e55b1c54d8 | ||
|  | 21bc3724c8 | ||
|  | 52f9edf9f4 | ||
|  | ef4c806071 | ||
|  | b188edd98d | ||
|  | bb91a90e9e | ||
|  | d6da239718 | ||
|  | deac88534a | ||
|  | 50504b14ce | ||
|  | 3965b11643 | ||
|  | 4e128198b7 | ||
|  | 0cf7423806 | ||
|  | 28d0e6fdbf | ||
|  | 49ac3b7a48 | ||
|  | 2b7cbb0664 | ||
|  | bba000877e | ||
|  | 6c22fa72d1 | ||
|  | 1a6d0e7e91 | ||
|  | 9315a123f1 | ||
|  | 1f31c5155b | ||
|  | fc437530e4 | ||
|  | cbd8e13d79 | ||
|  | 8fc70c267d | ||
|  | f49233b811 | ||
|  | 3831d4e8d4 | ||
|  | 0278189ded | ||
|  | a842b3ae01 | ||
|  | d427d189b1 | ||
|  | 08cc6b40c1 | ||
|  | ba0867f662 | ||
|  | c764b71af0 | ||
|  | b9cd608d9b | ||
|  | 77b6293ea6 | ||
|  | 8c269fd768 | ||
|  | 256bdfb89b | ||
|  | b5903bf79f | ||
|  | 11ddb1536c | ||
|  | 19999b28ad | ||
|  | e8190a500d | ||
|  | 76d14126a1 | ||
|  | 345168aa80 | ||
|  | e2467803c5 | ||
|  | 489a3304a4 | ||
|  | 456d0619df | ||
|  | 360f8d4c55 | ||
|  | c39f1cde04 | ||
|  | 3f04de5cb1 | ||
|  | 53c48dbb44 | ||
|  | 361648f1c7 | ||
|  | 2de30513b2 | ||
|  | f46ba32473 | ||
|  | 8d599c239b | ||
|  | 9403350e15 | ||
|  | 9f27070585 | ||
|  | 40927b95cc | ||
|  | 460fccc6ab | ||
|  | 1e4e6fa4d6 | ||
|  | c4ca3a98a1 | ||
|  | 25e82e28d5 | ||
|  | e93d2c0ef7 | ||
|  | b673b43c93 | ||
|  | c02215574d | ||
|  | dea7805dff | ||
|  | 40abc7065d | ||
|  | c02458b209 | ||
| fe64756bc4 | |||
| 6923cd2aa8 | |||
| b73468c73f | |||
| 671c39be27 | |||
| b9813528b1 | |||
| 293d90fb29 | |||
| 9432f67ada | |||
|  | 2357ebe6bd | ||
|  | 82652e1b82 | ||
|  | 67145b9657 | ||
|  | 8d2ebff6f3 | ||
|  | fb54c27514 | ||
|  | 688c61642b | ||
|  | b2d58f4320 | ||
|  | e619022112 | ||
|  | b849bc26b2 | ||
|  | 8caf244923 | ||
|  | 9c06b19d12 | ||
|  | 23328de316 | ||
|  | 9c91fc5420 | ||
|  | 157833e41a | ||
|  | adcf425183 | ||
|  | fdd802a3c1 | ||
|  | 226a6effd0 | ||
|  | cbc8ba4710 | ||
|  | d0e1d92d26 | ||
|  | f277613a9c | ||
|  | bb6e5c5a9b | ||
|  | bcc5f68151 | ||
| 1b868e430b | |||
| 41c4b7c1c4 | |||
| e954ffcef5 | |||
| 751bda0681 | |||
| 9b64b498ec | |||
| 771aaceaf3 | |||
| 21c41aebaa | |||
| a26e02f9c9 | |||
| bd3ad3b459 | |||
| 8a9675cd0d | |||
| 230c03942d | |||
| 1215937856 | |||
| 71b87a97ff | |||
| 92db050945 | |||
| 8864e1ce38 | |||
| f3e8454f58 | |||
| bc7a2e367d | |||
| d351c0eb72 | |||
| 2b23fa727f | |||
| bfe6adea42 | |||
| 7d28bb1093 | |||
| aefe9f6a09 | |||
| 17bb367a3a | |||
| 18b1a1d7f8 | |||
| 4749ee885d | |||
| 82d5aa14ee | |||
| ae13e5a8ff | |||
| 46fc25db39 | |||
| e02089442f | |||
| 820e53b678 | |||
| 0316ef5e05 | |||
| aae4506ffe | |||
| 456e37f07f | |||
| 4dff284b7f | |||
| 4b3c1f6f79 | |||
| 9cbe80b9ed | |||
| 78759e9a8a | |||
| 45d4aa8c9a | |||
| 502dca273d | |||
| 8682555bcb | |||
| 0391206ee6 | |||
| 31abb3460a | |||
| c0e0b51dee | |||
| e748ee3913 | |||
| cc4549d598 | |||
| 0861e266c7 | |||
| 5b668f1a6d | |||
| 89ccbf1810 | |||
| ec8c67a23b | |||
| 5c7935e430 | |||
| 3dd2b32086 | |||
| 103f6222fa | |||
| 25760e4c60 | |||
| 2234545bda | |||
| 2abd634c4d | |||
| 1a5cad9c0d | |||
| 3ac8fe1cb5 | |||
| f1a147ead3 | |||
| cc6627f664 | |||
| 73bf3af7a4 | |||
| 50b7131b51 | |||
| cdc65332a7 | |||
| 550406f699 | |||
| ff50eed8e7 | |||
| 6f7989a5d6 | |||
| 0d945cfb36 | |||
| aed4df32f9 | |||
| 445d624732 | |||
| 82c27c90a1 | |||
| d7813e2b42 | |||
| e6d7d5f53f | |||
| 3662e02958 | |||
| 7a02dad330 | |||
| 37a203a055 | |||
| 8b24b3e34f | |||
| 8b122a53d6 | |||
| 8bce6dc065 | |||
| b171f76c63 | |||
| 5610549a7f | |||
| c087670be2 | |||
| e167ea2bf6 | |||
| 0129229269 | |||
| 84d083ac5c | |||
| 2c58165984 | |||
| f942001b8d | |||
| 960c9c97a7 | |||
| b38bf77c57 | |||
| ff24d27119 | |||
| c10fa1c5bc | |||
| ec4b0f6eb8 | |||
| cb0bce71cd | |||
| 8ad2cf8287 | |||
| 29ced2a4a4 | |||
| 89e560e708 | |||
| 93ae11843e | |||
| b3f3b561db | |||
| 08c00b988c | |||
| 4907b0e524 | |||
| 7a917d2794 | |||
| d81f950f3f | |||
| fdaf3c38f7 | |||
| ff7b0eced9 | |||
| 09925430cf | |||
| a9803f5b04 | |||
| ac3dc9dfc6 | |||
| 5f0773c163 | |||
| 046489d894 | |||
| 694b0ab4fb | |||
| 1690d75cb6 | |||
| 01957f5cc1 | |||
| 5c34aa8e1a | |||
| 066e8421b4 | |||
| 1e311ae23c | |||
| 6f624e34f7 | |||
| 0670ca47fe | |||
| be5e1fcbd5 | |||
| b310cabcbc | |||
| 206d1f4251 | |||
| 121950da70 | |||
| 11af9fc2b2 | |||
| 2ce143a212 | |||
| 2f518da5db | |||
| 1f0be6557b | |||
| 9feb5f5d9e | |||
| 0fcbd8fab5 | |||
| 297d993103 | |||
| 59c8d1ba23 | |||
| 80bd88ab5f | |||
| 14459239f5 | |||
| e96b1aadee | |||
| bc1231cab1 | |||
| 9171a922d9 | |||
| 1286769ace | |||
| 79b338e5d4 | |||
| b6f98b6a7a | |||
| 429a605a01 | |||
| ae3b3cc35d | |||
| 47a2f11be5 | |||
| 147f5c5096 | |||
| 7d00f9d22f | |||
| ff529fca70 | |||
| 2d4dbca227 | |||
| 8cf4928db5 | |||
| edd316eadc | |||
| 486d207bec | |||
|  | 1b09c2caef | ||
|  | f15fab81a2 | ||
| e32c1dc991 | |||
| 0c15876deb | |||
| 78d1e4e1d7 | |||
| 0cb4920505 | |||
| 1b9d62bdce | |||
| 653340480a | |||
| d0957e9ca3 | |||
| 2bf7a26b69 | |||
| ceb43511ef | |||
| 5c8cd68b6f | |||
| b148e10393 | |||
| b3dce30491 | |||
| dadde986a2 | |||
| ecbe804bf3 | |||
| 7cba5b3eb5 | |||
| 6c17598623 | |||
| 5d1e0e2d67 | |||
| 91f5cdf483 | |||
| 57d313e4fe | |||
| 91aa03a226 | |||
| c1053d99f4 | |||
| 6e887f8925 | |||
| 1069a20093 | |||
| 171cdfc5fe | |||
| 0b5305c02a | |||
| 7ebca8c370 | |||
| 331ad2e399 | |||
| 54bcef5df9 | |||
| 99533b80e6 | |||
| e7d48632f4 | |||
| 0f4b4caed0 | |||
| 319624729f | |||
| 07e3008d69 | |||
| 3c605db9f2 | |||
| c07822862e | |||
| 41ce94578a | |||
| b9cd1502aa | |||
| 98d16e35f2 | |||
| cf74ad895d | |||
| bf908614eb | |||
| 17f7df25c0 | |||
| fc2ba31181 | |||
| e8db939c32 | |||
| 1683e23232 | |||
| e458da2f55 | |||
| 6a51bea3d0 | |||
| eaa37713cd | |||
| 988f5ca1e2 | |||
| a07cce2fd8 | |||
| 6f1fb178ed | |||
| 329c110061 | |||
| 8bd92463d2 | |||
| 53ec3f8ef3 | |||
| 11ade24251 | |||
| 29c37dea22 | |||
| 999b8843e8 | |||
| 36940601d3 | |||
| 63b5d0809b | |||
| 804bea284a | |||
| a96240d561 | |||
| 0f50512cd1 | |||
| d0113757cd | |||
| 21671001e1 | |||
| ad04a7680d | |||
| 5ef8c9b893 | |||
| df3dcc5716 | |||
| c6042b33fd | |||
| e5f56c24c3 | |||
| 9775118ab3 | |||
| cffd4aae1b | |||
| f8edff24e8 | |||
| 0e53b0d234 | |||
| 1f1e47c912 | |||
| 9ab8401ddc | |||
| e1c6bc7cf7 | |||
| b2160eac83 | |||
| fdc32e8d18 | |||
| 70c3e62162 | |||
| a2aad0e497 | |||
| 9ebf6c87c1 | |||
| 619c4def42 | |||
| 8edb6ee2a3 | |||
| 1b2d496ec2 | |||
| b91fc77934 | |||
| 32962db65f | |||
| 432334964d | |||
| 620e3fcd10 | |||
| e481e4a813 | |||
| 0cf1f28ccf | |||
| 6976d89ee8 | |||
| 7eecab26bd | 
							
								
								
									
										17
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								.drone.yml
									
									
									
									
									
								
							| @@ -7,6 +7,10 @@ platform: | |||||||
|   os: linux |   os: linux | ||||||
|   arch: amd64 |   arch: amd64 | ||||||
|  |  | ||||||
|  | node: | ||||||
|  |   gay: nigger | ||||||
|  |  | ||||||
|  |  | ||||||
| #clone: | #clone: | ||||||
|   # убрано так как сейчас не тестим ничего предварительно а сразу тянем в директорию  |   # убрано так как сейчас не тестим ничего предварительно а сразу тянем в директорию  | ||||||
|   #disable: true |   #disable: true | ||||||
| @@ -15,10 +19,23 @@ steps: | |||||||
| - name: test it first | - name: test it first | ||||||
|   commands: |   commands: | ||||||
|   - /usr/bin/python3 -m py_compile bot.py |   - /usr/bin/python3 -m py_compile bot.py | ||||||
|  |   - /usr/bin/python3 pipisa_functions/pipisa_time.py | ||||||
| - name: pull into the folduh | - name: pull into the folduh | ||||||
|   commands: |   commands: | ||||||
|   - cd /usr/share/$DRONE_REPO_NAME |   - cd /usr/share/$DRONE_REPO_NAME | ||||||
|   - git pull  |   - git pull  | ||||||
|  |   #- chown -R jack:jack . | ||||||
|  |   when: | ||||||
|  |     branch: | ||||||
|  |     - main | ||||||
|  |   environment: | ||||||
|  |     ARANGO_PASSWORD: | ||||||
|  |       from_secret: arango-pwd | ||||||
|  |     ARANGO_USERNAME: | ||||||
|  |       from_secret: arango-usr | ||||||
| - name: restart systemd unit | - name: restart systemd unit | ||||||
|   commands: |   commands: | ||||||
|   - systemctl restart jack_bot |   - systemctl restart jack_bot | ||||||
|  |   when: | ||||||
|  |     branch: | ||||||
|  |     - main | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | __pycache__ | ||||||
|  | testDB.py | ||||||
|  | TIME.py | ||||||
|  | .vscode | ||||||
|  | tests | ||||||
|  | qeqeqe | ||||||
|  | env | ||||||
|  | handlers/userdata.json | ||||||
							
								
								
									
										13
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | Пробуем проверять что-либо.  | ||||||
|  |  | ||||||
|  | ```mermaid | ||||||
|  | journey | ||||||
|  |   title Пиписа | ||||||
|  |   section Наш Чат | ||||||
|  |     Оче больше пипис: 5: ГЕГЕМОН | ||||||
|  |     Обычно большепенис: 3: Догоняющие | ||||||
|  |     Скромный дик: 1: Отставшие | ||||||
|  |   section Не наш чат | ||||||
|  |     Не запустил: -1: Отставшие | ||||||
|  |     Не крутил: 1: Отставшие | ||||||
|  | ``` | ||||||
							
								
								
									
										0
									
								
								__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										64
									
								
								bot.py
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								bot.py
									
									
									
									
									
								
							| @@ -1,33 +1,49 @@ | |||||||
| import time |  | ||||||
| import logging | import logging | ||||||
|  | from aiogram import executor, Bot, Dispatcher | ||||||
|  | from create_bot import dp | ||||||
|  | import handlers | ||||||
|  | import json, logging | ||||||
|  | from global_conf import CONFIG | ||||||
|  | from prometheus_client import start_http_server | ||||||
|  |  | ||||||
| from aiogram import Bot, Dispatcher, executor, types |  | ||||||
| from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton |  | ||||||
| from aiogram.types import FSInputFile |  | ||||||
|  |  | ||||||
| API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w' | def remake_field_generator(d, field='text'): | ||||||
|  |     if isinstance(d, list): | ||||||
|  |         for k2 in d: | ||||||
|  |             for id_val in remake_field_generator(k2): | ||||||
|  |                 yield id_val | ||||||
|  |     elif isinstance(d, dict): | ||||||
|  |         for k, v in d.items(): | ||||||
|  |             if k == field:  | ||||||
|  |                 d[k] = '<blank!>' | ||||||
|  |                 yield v | ||||||
|  |             elif isinstance(v, list): | ||||||
|  |                 for k2 in v: | ||||||
|  |                     for id_val in remake_field_generator(k2): | ||||||
|  |                         yield id_val | ||||||
|  |             elif isinstance(v, dict): | ||||||
|  |                 for id_val in remake_field_generator(v): | ||||||
|  |                     yield id_val | ||||||
|  |  | ||||||
|  | def filter_grammar_messages(record): | ||||||
|  |     if record.args and (not None in record.args): | ||||||
|  |         j = json.loads(record.args[2]) | ||||||
|  |         for _ in remake_field_generator(j): | ||||||
|  |             pass | ||||||
|  |         record.args = (record.args[0], record.args[1], json.dumps(j)) | ||||||
|  |     return True | ||||||
|  |  | ||||||
| logging.basicConfig(level=logging.DEBUG) | logging.basicConfig(level=logging.DEBUG) | ||||||
|  | logging.getLogger("aiogram").addFilter(filter_grammar_messages) | ||||||
|  |  | ||||||
| bot = Bot(token=API_TOKEN) | # pipisa.register_handlers_pipisa(dp) | ||||||
| dp = Dispatcher(bot) | # time_new_year.register_handlers_time(dp) | ||||||
|  | # sendalarm.register_handlers_test(dp) | ||||||
| @dp.message_handler(commands=['start']) | # start_help.register_handlers_StartHelp(dp) | ||||||
| async def start_func(message: types.Message): |  | ||||||
|     user_id = message.from_user.id |  | ||||||
|     user_full_name = message.from_user.full_name |  | ||||||
|     logging.INFO(f'{user_id=} {user_full_name=}', {time.asctime()}) |  | ||||||
|     await message.reply('hello') |  | ||||||
|  |  | ||||||
| @dp.message_handler(commands=['photo']) |  | ||||||
| async def send_image(message: types.Message): |  | ||||||
|     await bot.send_photo(message.chat.id, photo='http://git.vdk2ch.ru:3000/Pavel_Durov/python_bot/raw/branch/main/ya-pidoras.jpg') |  | ||||||
|  |  | ||||||
| #хуй |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|  |     #print(CONFIG) | ||||||
|  |     start_http_server(1337) | ||||||
|  |     logging.info('Бот в строю.') | ||||||
|     executor.start_polling(dp, skip_updates=True) |     executor.start_polling(dp, skip_updates=True) | ||||||
|  |     logging.info('Всем пока.') | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								config.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								config.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | --- | ||||||
|  | databaso: | ||||||
|  |   host:                     'http://arango.guaranteedstruggle.host:8529' | ||||||
|  |   #user:                      root | ||||||
|  |   #pass:                      stolendick527 | ||||||
|  |   base:                      pipisa | ||||||
|  |   collection:                dicks | ||||||
|  |   posts_removal_collection:  posts_removal | ||||||
|  |  | ||||||
|  | telegram_token: 6991523312:AAFpxPlWHfnNq2dVXM_v1GuHcrbNgWdSWBM | ||||||
|  | telegram_admins_ids: | ||||||
|  | - 317051301 # hogweed1 | ||||||
|  | - 226765676 # blackjack | ||||||
|  | - 94830892  # viktorRMI | ||||||
|  | - 132002803 | ||||||
|  |  | ||||||
|  | openai: | ||||||
|  |   token:   5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc | ||||||
|  |   api_key: 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  ## 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 | ||||||
							
								
								
									
										6
									
								
								create_bot.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								create_bot.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | from aiogram import Bot, Dispatcher | ||||||
|  | from global_conf import CONFIG | ||||||
|  |  | ||||||
|  |  | ||||||
|  | bot = Bot(token=CONFIG['telegram_token'], parse_mode="HTML") | ||||||
|  | dp  = Dispatcher(bot) | ||||||
							
								
								
									
										0
									
								
								db_logic/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								db_logic/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										40
									
								
								db_logic/collections.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								db_logic/collections.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | |||||||
|  | from global_conf import CONFIG | ||||||
|  | #### https://docs.python-arango.com/en/main/ | ||||||
|  | from arango import ArangoClient | ||||||
|  | import logging | ||||||
|  | import os  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def get_dicks_collection(): | ||||||
|  |     try: | ||||||
|  |         arango_client = ArangoClient(hosts=CONFIG['databaso']['host'] ) | ||||||
|  |         pipisa_db     = arango_client.db( | ||||||
|  |             CONFIG['databaso']['base'], | ||||||
|  |             username=os.environ['ARANGO_USR'], | ||||||
|  |             password=os.environ['ARANGO_PWD'], | ||||||
|  |             #username=CONFIG['databaso']['user'], | ||||||
|  |             #password=CONFIG['databaso']['pass'] | ||||||
|  |         ) | ||||||
|  |         dicks_collection = pipisa_db.collection(CONFIG['databaso']['collection']) | ||||||
|  |  | ||||||
|  |         return dicks_collection | ||||||
|  |     except Exception as e: | ||||||
|  |         logging.error('ошибка DB при взятии коллекции пипис') | ||||||
|  |         logging.error(e) | ||||||
|  |  | ||||||
|  | def get_posts_removal_collection(): | ||||||
|  |     try: | ||||||
|  |         arango_client = ArangoClient(hosts=CONFIG['databaso']['host']) | ||||||
|  |         pipisa_db     = arango_client.db( | ||||||
|  |             CONFIG['databaso']['base'], | ||||||
|  |             username=os.environ['ARANGO_USR'], | ||||||
|  |             password=os.environ['ARANGO_PWD'], | ||||||
|  |             #username=CONFIG['databaso']['user'], | ||||||
|  |             #password=CONFIG['databaso']['pass'] | ||||||
|  |         ) | ||||||
|  |         posts_removal_collection = pipisa_db.collection(CONFIG['databaso']['posts_removal_collection']) | ||||||
|  |  | ||||||
|  |         return posts_removal_collection | ||||||
|  |     except Exception as e: | ||||||
|  |         logging.error('ошибка DB при взятии коллекции постов-на-удаление') | ||||||
|  |         logging.error(e) | ||||||
							
								
								
									
										70
									
								
								db_logic/postcleaner.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								db_logic/postcleaner.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | |||||||
|  | from db_logic import collections | ||||||
|  | import datetime, logging | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def append_post_to_cleaning_sequence(message, type=None): | ||||||
|  |     try: | ||||||
|  |         novenkiy = { | ||||||
|  |             'msg_id':    message.message_id, | ||||||
|  |             'chat_id':   message.chat.id, | ||||||
|  |             'type':      type, | ||||||
|  |             'datetimes': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||||||
|  |         } | ||||||
|  |         metadata = collections.get_posts_removal_collection().insert(novenkiy, overwrite_mode='update') | ||||||
|  |  | ||||||
|  |         logging.debug('Успешно добавлен пост на удаление') | ||||||
|  |     except Exception as e2: | ||||||
|  |         logging.error('ошибка DB :: добавление нового поста на удаление') | ||||||
|  |         logging.error(e2) | ||||||
|  |  | ||||||
|  | def get_posts_to_be_removed(chat_id, type=None, max_id=None): | ||||||
|  |     # собираем | ||||||
|  |     try: | ||||||
|  |         #posts = [p for p in collections.get_posts_removal_collection().all( ) ] | ||||||
|  |           | ||||||
|  |         if type: | ||||||
|  |             posts = [p for p in collections.get_posts_removal_collection().find({'chat_id': chat_id, 'type': type}, skip=0, limit=1100) ] | ||||||
|  |         else: | ||||||
|  |             posts = [p for p in collections.get_posts_removal_collection().find({'chat_id': chat_id}, skip=0, limit=1100) ] | ||||||
|  |  | ||||||
|  |         posts_ret = [ p for p in posts ] | ||||||
|  |         # # for p in posts: | ||||||
|  |         # #     last_time    = datetime.datetime.strptime(p['datetimes'], '%Y-%m-%d %H:%M:%S') | ||||||
|  |         # #     timediff = (datetime.datetime.now() - last_time).total_seconds() | ||||||
|  |  | ||||||
|  |         # #     if timediff > 60: | ||||||
|  |         # #         posts_ret.append(p) | ||||||
|  |   | ||||||
|  |         if max_id: | ||||||
|  |             posts_ret = [ p for p in posts_ret if p['msg_id'] != max_id] | ||||||
|  |         else: | ||||||
|  |             posts_ret = [ p for p in posts_ret if p['msg_id'] != max([pp['msg_id'] for pp in posts_ret])] | ||||||
|  |  | ||||||
|  |         #### TODO удалять все предыдущие без учёта времени | ||||||
|  |  | ||||||
|  |         return posts_ret | ||||||
|  |     except Exception as e: | ||||||
|  |         logging.error('ошибка DB :: получение постов на удаление') | ||||||
|  |         logging.error(e) | ||||||
|  |  | ||||||
|  | def del_post(msg_id, chat_id): | ||||||
|  |     # удаляем из базы | ||||||
|  |     try: | ||||||
|  |         candidate_cursor = collections.get_posts_removal_collection().find( | ||||||
|  |             { | ||||||
|  |                 'msg_id':  msg_id, | ||||||
|  |                 'chat_id': chat_id, | ||||||
|  |             }, | ||||||
|  |             skip  = 0, | ||||||
|  |             limit = 1488 | ||||||
|  |         ) | ||||||
|  |         if candidate_cursor.count() > 0: | ||||||
|  |             pp = candidate_cursor.pop() | ||||||
|  |         else: | ||||||
|  |             pp = None | ||||||
|  |  | ||||||
|  |         collections.get_posts_removal_collection().delete(pp) | ||||||
|  |   | ||||||
|  |     except Exception as e: | ||||||
|  |         logging.error('ошибка DB :: удаление поста на удаление') | ||||||
|  |         logging.error(e) | ||||||
							
								
								
									
										63
									
								
								db_logic/tops.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								db_logic/tops.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | |||||||
|  | from global_conf import CONFIG | ||||||
|  | from db_logic import collections | ||||||
|  | import logging | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def get_tops(top_ = False, glob_ = False, chat_id = None): | ||||||
|  |     if top_: | ||||||
|  |         try: | ||||||
|  |             dicks = [d for d in collections.get_dicks_collection().find({'chat_id': chat_id}, skip=0, limit=1100)] | ||||||
|  |         except Exception as e: | ||||||
|  |             logging.error('ошибка DB в /topdick') | ||||||
|  |             logging.error(e) | ||||||
|  |     elif glob_: | ||||||
|  |         try: | ||||||
|  |             dicks = [d for d in collections.get_dicks_collection().all( ) if d['user_id'] != d['chat_id']] | ||||||
|  |         except Exception as e: | ||||||
|  |             logging.error('ошибка DB в /globaldick') | ||||||
|  |             logging.error(e) | ||||||
|  |     else: | ||||||
|  |         logging.error('вызывают хз что!') | ||||||
|  |  | ||||||
|  |     top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True) | ||||||
|  |     top_dicks = top_dicks[:(min(len(top_dicks), 10))] | ||||||
|  |  | ||||||
|  |     dickos = '' | ||||||
|  |     emo    = ['🏆','🚀','🍆','🍌','🐍','🐎','🌭','🌶','👌','💩'] | ||||||
|  |  | ||||||
|  |     if len(top_dicks) > 0: | ||||||
|  |         for i in range(len(top_dicks)): | ||||||
|  |             dickos += f'     {emo[i]} {i+1}. {top_dicks[i]["user_fullname"]}: {top_dicks[i]["dick_size"]}см\n' | ||||||
|  |             i += 1 | ||||||
|  |  | ||||||
|  |     return dickos | ||||||
|  |  | ||||||
|  | def get_antitops(top_ = False, glob_ = False, chat_id = None): | ||||||
|  |     dicks = [] | ||||||
|  |     if top_: | ||||||
|  |         try: | ||||||
|  |             dicks = [d for d in collections.get_dicks_collection().find({'chat_id': chat_id}, skip=0, limit=1100)] | ||||||
|  |         except Exception as e: | ||||||
|  |             logging.error('ошибка DB в /topdick') | ||||||
|  |             logging.error(e) | ||||||
|  |     elif glob_: | ||||||
|  |         try: | ||||||
|  |             dicks = [d for d in collections.get_dicks_collection().all() if d['user_id'] != d['chat_id']] | ||||||
|  |         except Exception as e: | ||||||
|  |             logging.error('ошибка DB в /globaldick') | ||||||
|  |             logging.error(e) | ||||||
|  |     else: | ||||||
|  |         logging.error('вызывают хз что!') | ||||||
|  |  | ||||||
|  |     antitop_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=False) | ||||||
|  |     antitop_dicks = antitop_dicks[:( min(len(antitop_dicks), 10) )]  | ||||||
|  |  | ||||||
|  |     dickos = '' | ||||||
|  |     emo    = ['💩', '😞', '🤕', '😣', '🙁', '😐', '😑', '😶', '😒', '😕'] | ||||||
|  |  | ||||||
|  |     if len(antitop_dicks) > 0: | ||||||
|  |         for i in range(len(antitop_dicks)):  | ||||||
|  |             dickos += f'     {emo[i]} {i+1}. {antitop_dicks[i]["user_fullname"]}: {antitop_dicks[i]["dick_size"]}см\n' | ||||||
|  |             i += 1 | ||||||
|  |  | ||||||
|  |     return dickos | ||||||
							
								
								
									
										85
									
								
								db_logic/user_stuff.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								db_logic/user_stuff.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | |||||||
|  | from db_logic import collections | ||||||
|  | from handlers.metrics import metric_wrap | ||||||
|  | import datetime, logging | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def store_new_user(message, result ): | ||||||
|  |     try: | ||||||
|  |         novenkiy = { | ||||||
|  |             'user_id':       message.from_user.id, | ||||||
|  |             'user_fullname': message.from_user.full_name, | ||||||
|  |             'dick_size':     abs(result), | ||||||
|  |             'datetimes':     datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), | ||||||
|  |             'attempts':      1, | ||||||
|  |             'chat_id':       message.chat.id | ||||||
|  |         } | ||||||
|  |         metadata = collections.get_dicks_collection().insert(novenkiy, overwrite_mode='update') | ||||||
|  |  | ||||||
|  |         metric_wrap(message.chat.id, message.from_user.full_name, abs(result), 1) | ||||||
|  |         logging.debug(f'Успешно добавлен нового пользователь @{message.from_user.username}') | ||||||
|  |     except Exception as e2: | ||||||
|  |         logging.error(f'ошибка DB в /dick :: добавление нового пользователя @{message.from_user.username}') | ||||||
|  |         logging.error(e2) | ||||||
|  |  | ||||||
|  | def update_attempts(message, user ): | ||||||
|  |     try: | ||||||
|  |         metadata = collections.get_dicks_collection().insert( | ||||||
|  |             { | ||||||
|  |                 '_key':          user['_key'], ### этот нужен чтобы апдейт прилетал тому же юзеру | ||||||
|  |                 'user_id':       user['user_id'] , | ||||||
|  |                 'user_fullname': message.from_user.full_name, | ||||||
|  |                 'dick_size':     user['dick_size'] , | ||||||
|  |                 'datetimes':     user['datetimes'] , | ||||||
|  |                 'attempts':      user['attempts'] + 1, | ||||||
|  |                 'chat_id':       message.chat.id | ||||||
|  |             }, | ||||||
|  |             overwrite_mode='update' | ||||||
|  |         ) | ||||||
|  |  | ||||||
|  |         metric_wrap(message.chat.id, message.from_user.full_name, user['dick_size'], user['attempts'] + 1) | ||||||
|  |         logging.debug(f'Успешно апдейтнули попытку крутить пипису @{message.from_user.username}') | ||||||
|  |     except Exception as e2: | ||||||
|  |         logging.error(f'ошибка DB в /dick :: обновление попытки крутить пипису @{message.from_user.username}') | ||||||
|  |         logging.error(e2) | ||||||
|  |  | ||||||
|  | def update_dick_size(message, user, updatedDick ): | ||||||
|  |     try: | ||||||
|  |         metadata = collections.get_dicks_collection().insert( | ||||||
|  |             { | ||||||
|  |                 '_key':          user['_key'], ### этот нужен чтобы апдейт прилетал тому же юзеру | ||||||
|  |                 'user_id':       user['user_id'], | ||||||
|  |                 'user_fullname': message.from_user.full_name, | ||||||
|  |                 'dick_size':     updatedDick, | ||||||
|  |                 'datetimes':     datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), | ||||||
|  |                 'attempts':      user['attempts'] + 1, | ||||||
|  |                 'chat_id':       message.chat.id | ||||||
|  |             }, | ||||||
|  |             overwrite_mode='update' | ||||||
|  |         ) | ||||||
|  |  | ||||||
|  |         metric_wrap(message.chat.id, message.from_user.full_name, updatedDick, user['attempts'] + 1) | ||||||
|  |         logging.info(f'Успешно апдейтнули пипису @{message.from_user.username}') | ||||||
|  |     except Exception as e2: | ||||||
|  |         logging.error(f'ошибка DB в /dick :: обновление пиписы @{message.from_user.username}') | ||||||
|  |         logging.error(e2) | ||||||
|  |  | ||||||
|  | def get_user(message): | ||||||
|  |     try: | ||||||
|  |         #### Чекнуть есть ли юзер в базе | ||||||
|  |         candidate_cursor = collections.get_dicks_collection().find( | ||||||
|  |             { | ||||||
|  |                 'user_id': message.from_user.id, | ||||||
|  |                 'chat_id': message.chat.id | ||||||
|  |             }, | ||||||
|  |             skip  = 0, | ||||||
|  |             limit = 1488 | ||||||
|  |         ) | ||||||
|  |         if candidate_cursor.count() > 0: | ||||||
|  |             user = candidate_cursor.pop() | ||||||
|  |         else: | ||||||
|  |             user = None | ||||||
|  |  | ||||||
|  |         return user | ||||||
|  |     except Exception as e: | ||||||
|  |         logging.error('ошибка DB в /dick :: поиск юзера') | ||||||
|  |         logging.error(e) | ||||||
							
								
								
									
										11
									
								
								dicktxt/ForReadDict.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								dicktxt/ForReadDict.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | import random | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def RandomDick(): | ||||||
|  | # Забирает рандомный синоним к слову хуй из dick_sinonims.txt | ||||||
|  | # у линуха и винды не забывай про разные \/ | ||||||
|  | # кёгда указываешь путь | ||||||
|  |     with open('dicktxt/dick_sinonims.txt', 'r', encoding='utf-8') as file: | ||||||
|  |         words = file.readlines() | ||||||
|  |   | ||||||
|  |     return random.choice(words).strip() | ||||||
							
								
								
									
										20
									
								
								dicktxt/WordsChange.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								dicktxt/WordsChange.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | import yaml | ||||||
|  | import random | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def ChangeWord(result): #збiрає будь-якое слiво для змєнєння розмiра пiпiси | ||||||
|  |         with open("dicktxt/dick_changes.yaml", 'r', encoding='utf-8') as f: | ||||||
|  |             words = yaml.load(f, Loader=yaml.Loader) | ||||||
|  |  | ||||||
|  |         dick_inc     = [ f'<b>{w}</b>' for w in words['increment']  ] | ||||||
|  |         dick_static  = [ f'<b>{w}</b>' for w in words['nothing']    ] | ||||||
|  |         dick_decr    = [ f'<b>{w}</b>' for w in words['decrement']  ] | ||||||
|  |  | ||||||
|  |         if result > 0: | ||||||
|  |             size_change  = random.choice(dick_inc)    + '🚀' | ||||||
|  |         elif result == 0: | ||||||
|  |             size_change  = random.choice(dick_static) + '🤨'  | ||||||
|  |         else:  | ||||||
|  |             size_change  = random.choice(dick_decr)   + '✂' | ||||||
|  |  | ||||||
|  |         return size_change | ||||||
							
								
								
									
										2
									
								
								dicktxt/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								dicktxt/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | from . import ForReadDict | ||||||
|  |  | ||||||
							
								
								
									
										30
									
								
								dicktxt/dick_changes.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								dicktxt/dick_changes.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | |||||||
|  | --- | ||||||
|  | increment: | ||||||
|  | - вырос | ||||||
|  | - подрос | ||||||
|  | - привстал | ||||||
|  | - увеличился | ||||||
|  | - преисполнился | ||||||
|  | - приподнялся | ||||||
|  | - изменил размер | ||||||
|  | - облагородился | ||||||
|  | - чрезвычайно преуспел | ||||||
|  | decrement: | ||||||
|  | - неудачно потусил на сходке | ||||||
|  | - уменьшился | ||||||
|  | - откусила злая гадюка | ||||||
|  | - продали евреи, он стал дешевле | ||||||
|  | - схуднул | ||||||
|  | - отрицательно вырос | ||||||
|  | - словил низкие вибрации | ||||||
|  | - повредился после простуды | ||||||
|  | - стал жертвой репрессий | ||||||
|  | - был подло использован | ||||||
|  | nothing: | ||||||
|  | - продвинулся | ||||||
|  | - наноуменьшился | ||||||
|  | - познал стабильность | ||||||
|  | - зафиксировал прибыль | ||||||
|  | - подумал о судьбах Китая | ||||||
|  | - прогулялся по лесу | ||||||
|  | - самоутвердился | ||||||
							
								
								
									
										96
									
								
								dicktxt/dick_sinonims.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								dicktxt/dick_sinonims.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | |||||||
|  | кожаный бабах | ||||||
|  | пистон | ||||||
|  | дуршлаг | ||||||
|  | елдак | ||||||
|  | шлямбур | ||||||
|  | шмайсер | ||||||
|  | хохотунчик | ||||||
|  | головастик | ||||||
|  | пистон | ||||||
|  | мундштук | ||||||
|  | мухомор | ||||||
|  | головач | ||||||
|  | красненький | ||||||
|  | чупа-чупс | ||||||
|  | щекотунчик | ||||||
|  | питательный | ||||||
|  | тюбик | ||||||
|  | джойстик | ||||||
|  | хоббит | ||||||
|  | крючок | ||||||
|  | ласкун | ||||||
|  | красавец | ||||||
|  | хозяин | ||||||
|  | хрящ | ||||||
|  | чудильник | ||||||
|  | царь пижамы | ||||||
|  | целколом | ||||||
|  | щуп | ||||||
|  | эклер | ||||||
|  | долбильник | ||||||
|  | народник | ||||||
|  | духопер | ||||||
|  | ежик малиновый | ||||||
|  | жрец любви | ||||||
|  | жизненный конус | ||||||
|  | злой одноглазый пиратик | ||||||
|  | главтрах | ||||||
|  | веселый парнишка | ||||||
|  | вставень висюлек | ||||||
|  | волосатый чикатило | ||||||
|  | агрессор | ||||||
|  | анакондаз | ||||||
|  | антихрист | ||||||
|  | Анютин глазок | ||||||
|  | бензонасос | ||||||
|  | блудень | ||||||
|  | бог плодородия | ||||||
|  | божий леденец | ||||||
|  | волосатый змiй | ||||||
|  | витамин "Х" | ||||||
|  | вспотевший объектив | ||||||
|  | гендерный габитус | ||||||
|  | двадцать первый палец | ||||||
|  | калдыбобер | ||||||
|  | боброчес | ||||||
|  | кукурузик | ||||||
|  | красноголовый воин | ||||||
|  | красный богатырь | ||||||
|  | любовный мускул | ||||||
|  | леденец | ||||||
|  | обелиск | ||||||
|  | окурок | ||||||
|  | органайзер | ||||||
|  | отбойный | ||||||
|  | молоток | ||||||
|  | посох королей | ||||||
|  | пламенный алмаз мудрости | ||||||
|  | монофалический потенциометр | ||||||
|  | розовый кадилак | ||||||
|  | сексофон | ||||||
|  | трахальник | ||||||
|  | торчильник | ||||||
|  | факало | ||||||
|  | кочанчик | ||||||
|  | писюн | ||||||
|  | губашлеп | ||||||
|  | потенциальный кредитор | ||||||
|  | кок | ||||||
|  | чилим | ||||||
|  | пажилой кабан | ||||||
|  | малой | ||||||
|  | начальник унитаза | ||||||
|  | бесперебойник | ||||||
|  | корнишон | ||||||
|  | банановый смузи | ||||||
|  | кизляк | ||||||
|  | проныра | ||||||
|  | пенис детров | ||||||
|  | бенис | ||||||
|  | кокошник | ||||||
|  | членикс | ||||||
|  | маленький жиголо | ||||||
|  | венерический суккуб | ||||||
|  | боец невидимого фронта | ||||||
|  | сморчок | ||||||
|  | джечник | ||||||
							
								
								
									
										11
									
								
								global_conf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								global_conf.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | import yaml | ||||||
|  |  | ||||||
|  |  | ||||||
|  | with open("config.yaml", 'r') as f: | ||||||
|  |     CONFIG = yaml.load(f, Loader=yaml.Loader) | ||||||
|  |  | ||||||
|  | METRICS_INITIALIZED = False | ||||||
|  |  | ||||||
|  | pipisa_length_metric     = None | ||||||
|  | user_attempt_metric      = None | ||||||
|  | user_last_attempt_metric = None | ||||||
							
								
								
									
										4
									
								
								handlers/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								handlers/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | from handlers import pipisa | ||||||
|  | from handlers import start_help | ||||||
|  | from handlers import time_new_year | ||||||
|  |  | ||||||
							
								
								
									
										57
									
								
								handlers/davinci.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								handlers/davinci.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | |||||||
|  | from openai import AsyncOpenAI | ||||||
|  | from aiogram import types | ||||||
|  | from create_bot import dp, bot | ||||||
|  | import logging | ||||||
|  | from global_conf import CONFIG | ||||||
|  |  | ||||||
|  |  | ||||||
|  | admins = CONFIG['telegram_admins_ids'] | ||||||
|  | ban_comands = ['/dick','/topdick'] | ||||||
|  |  | ||||||
|  | # Image_promt =['тупица сгенерируй','тупица сгенерируй картинку',\ | ||||||
|  | #                                          'тупица отправь картинку', 'тупица отправь картинку'] | ||||||
|  | client = AsyncOpenAI(api_key="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") | ||||||
|  |  | ||||||
|  | # @dp.message_handler(commands=['image']) | ||||||
|  | # async def send_image(message: types.Message): | ||||||
|  | #     if message.from_user.id in admins and message.chat.type == 'private': | ||||||
|  | #         try: | ||||||
|  | #             description = message.text.replace('/image', '').strip() | ||||||
|  |              | ||||||
|  | #             if not description: | ||||||
|  | #                 await message.reply('Ты даун, описание запроса напиши после пробела') | ||||||
|  | #                 return | ||||||
|  | #         except Exception as e: | ||||||
|  | #             logging.error(f'Error in send_image: {e}') | ||||||
|  | #         try: | ||||||
|  |  | ||||||
|  | #             response = openai.Image.create( | ||||||
|  | #             prompt=message.text, | ||||||
|  | #             n=1, | ||||||
|  | #             size="1024x1024", | ||||||
|  | #             response_format="url", | ||||||
|  |              | ||||||
|  | #         ) | ||||||
|  | #             image_url = response['data'][0]['url'] | ||||||
|  | #             await message.answer('Генерирую изображение...') | ||||||
|  | #             await message.reply_photo(image_url) | ||||||
|  | #         except Exception as e: | ||||||
|  | #             await message.reply('у меня не получилось') | ||||||
|  |  | ||||||
|  | async def gpt_text(req): | ||||||
|  |     completion = await client.chat.completions.create( | ||||||
|  |         messages=[ | ||||||
|  |             { | ||||||
|  |                 "role": "user", | ||||||
|  |                 "content": req, | ||||||
|  |             } | ||||||
|  |         ], | ||||||
|  |         model="gpt-4", | ||||||
|  |     ) | ||||||
|  |     return completion | ||||||
|  |  | ||||||
|  | @dp.message_handler() | ||||||
|  | async def send(message: types.Message): | ||||||
|  |     if message.from_user.id in admins and message.chat.type == 'private': | ||||||
|  |         response = await gpt_text(message.text) | ||||||
|  |         await message.answer(response.choices[0].message.content) | ||||||
							
								
								
									
										30
									
								
								handlers/metrics.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								handlers/metrics.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | |||||||
|  | import json | ||||||
|  | import time | ||||||
|  | from prometheus_client import Gauge, Info | ||||||
|  | from global_conf import pipisa_length_metric, user_attempt_metric, user_last_attempt_metric | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class user_info_struct: | ||||||
|  |     user_id: str | ||||||
|  |     user_fullname: str | ||||||
|  |     dick_size: int | ||||||
|  |     datetimes: str | ||||||
|  |     attemptsCount: int | ||||||
|  |     chat_id: int | ||||||
|  |  | ||||||
|  | def metric_wrap(chatID:int, userName: str, length: int, attemptsCount: int): | ||||||
|  |     """Pass here chat ID, username, pipisa length and attempts count to wrap them into metric.""" | ||||||
|  |  | ||||||
|  |     global pipisa_length_metric | ||||||
|  |     if not pipisa_length_metric: | ||||||
|  |         pipisa_length_metric = Gauge('user_length_total', 'Pipisa length', labelnames=['ChatID', 'Username']) | ||||||
|  |     global user_attempt_metric | ||||||
|  |     if not user_attempt_metric: | ||||||
|  |         user_attempt_metric = Gauge('user_attempts_total', 'Attempts count', labelnames=['ChatID', 'Username']) | ||||||
|  |     global user_last_attempt_metric | ||||||
|  |     if not user_last_attempt_metric: | ||||||
|  |         user_last_attempt_metric = Gauge('user_last_attempt_time', 'Last attempt time', labelnames=['ChatID', 'Username']) | ||||||
|  |  | ||||||
|  |     pipisa_length_metric.labels(chatID, userName).set(length) | ||||||
|  |     user_attempt_metric.labels(chatID, userName).set(attemptsCount) | ||||||
|  |     user_last_attempt_metric.labels(chatID, userName).set(time.time_ns()) | ||||||
							
								
								
									
										132
									
								
								handlers/pipisa.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								handlers/pipisa.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,132 @@ | |||||||
|  | from aiogram import types | ||||||
|  | from create_bot import bot, dp | ||||||
|  | import random | ||||||
|  | from random import randint | ||||||
|  | import datetime, logging | ||||||
|  | from dicktxt import ForReadDict, WordsChange | ||||||
|  | from pipisa_functions import pipisa_time | ||||||
|  | from global_conf import CONFIG | ||||||
|  | from db_logic import tops, user_stuff, postcleaner | ||||||
|  |  | ||||||
|  |  | ||||||
|  | admins = CONFIG['telegram_admins_ids'] | ||||||
|  |  | ||||||
|  | @dp.message_handler(commands=["dick"]) | ||||||
|  | async def up_dick(message: types.Message): | ||||||
|  |  | ||||||
|  |     if message.from_user.id in admins or message.chat.type != 'private': | ||||||
|  |         postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__DICK') | ||||||
|  |         await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__DICK', max_id=message.message_id) | ||||||
|  |  | ||||||
|  |         #### TODO уплатить нолог с 100 см для самого нищего | ||||||
|  |  | ||||||
|  |         # рандомайзер | ||||||
|  |         result = randint(-9,10)  | ||||||
|  |  | ||||||
|  |         #### Чекнуть есть ли юзер в базе | ||||||
|  |         user = user_stuff.get_user(message) | ||||||
|  |  | ||||||
|  |         if user:  | ||||||
|  |             ## Если есть то нарастить и отправить сообщение | ||||||
|  |  | ||||||
|  |             if pipisa_time.rolltime(check_datetime=user['datetimes'], curr_time=datetime.datetime.now()): | ||||||
|  |                 # пришло время крутить!! | ||||||
|  |  | ||||||
|  |                 updatedDick = user["dick_size"] + result  | ||||||
|  |                 user_stuff.update_dick_size(message, user, updatedDick) | ||||||
|  |  | ||||||
|  |                 randomdickword = ForReadDict.RandomDick()  | ||||||
|  |                 change_phrase  = WordsChange.ChangeWord(result) | ||||||
|  |  | ||||||
|  |                 await bot.send_message( message.chat.id,  | ||||||
|  |                     f'@{message.from_user.username}, ваш <em>{randomdickword}</em> {change_phrase} на <b>{abs(result)}</b> см!\nТеперь он равен <b>{updatedDick}</b> см! ' | ||||||
|  |                 ) | ||||||
|  |             else: | ||||||
|  |                 mmm = await bot.send_message( message.chat.id,  | ||||||
|  |                     f'@{message.from_user.username}, 🚫 вы уже крутили пипису, её размер <b>{user["dick_size"]}</b> см! ' | ||||||
|  |                 ) | ||||||
|  |                 user_stuff.update_attempts( message, user) | ||||||
|  |  | ||||||
|  |                 postcleaner.append_post_to_cleaning_sequence(message=mmm, type='ALREADY_ROLLED') | ||||||
|  |                 await clean_posts(chat_id=mmm.chat.id, type='ALREADY_ROLLED', max_id=mmm.message_id) | ||||||
|  |         else: | ||||||
|  |             ## если нету, то создать | ||||||
|  |             user_stuff.store_new_user(message, result) | ||||||
|  |  | ||||||
|  |             await bot.send_message( message.chat.id, | ||||||
|  |                 f'@{message.from_user.username}, Добро пожаловать в игру! Ваш писюн показал головку 🚀\nна <b>{abs(result)}</b> см!\nТеперь он равен <b>{abs(result)}</b> см!' | ||||||
|  |             ) | ||||||
|  |  | ||||||
|  |     else: | ||||||
|  |         await message.reply('Растить елду можно только в общих чатах!') | ||||||
|  |  | ||||||
|  | @dp.message_handler(commands = ['topdick', 'globaldick']) | ||||||
|  | async def send_topchat(message: types.Message): | ||||||
|  |     if message.from_user.id in admins or message.chat.type != 'private': | ||||||
|  |  | ||||||
|  |         top_  = message['text'].startswith('/topdick') | ||||||
|  |         glob_ = message['text'].startswith('/globaldick') | ||||||
|  |  | ||||||
|  |         if top_: | ||||||
|  |             dickos = tops.get_tops( top_  = True, chat_id=message.chat.id ) | ||||||
|  |             postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__TOPDICK') | ||||||
|  |             await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__TOPDICK', max_id=message.message_id) | ||||||
|  |         elif glob_: | ||||||
|  |             dickos = tops.get_tops( glob_ = True ) | ||||||
|  |             postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__GLOBALDICK') | ||||||
|  |             await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__GLOBALDICK', max_id=message.message_id) | ||||||
|  |         else: | ||||||
|  |             logging.error('вызывают хз что!') | ||||||
|  |  | ||||||
|  |         if not dickos: | ||||||
|  |             await bot.send_message(message.chat.id, '🍆 Никто ничего не нарастил! 🍌') | ||||||
|  |         else: | ||||||
|  |             if top_: | ||||||
|  |                 await bot.send_message(message.chat.id, '🏆Топ 10 бубылд чата🏆\n\n' + dickos) | ||||||
|  |             elif glob_: | ||||||
|  |                 await bot.send_message(message.chat.id, '🏆Топ 10 пипис в мире🏆\n\n' + dickos) | ||||||
|  |     else: | ||||||
|  |         await message.reply('Работает только в общих чатах!\n'\ | ||||||
|  |                             'Вы можете посмотреть топ по миру /globaldick') | ||||||
|  |  | ||||||
|  | @dp.message_handler(commands = ['antitopdick', 'antiglobaldick']) | ||||||
|  | async def send_antitopchat(message: types.Message): | ||||||
|  |     if message.from_user.id in admins or message.chat.type != 'private': | ||||||
|  |         antitop_  = message['text'].startswith('/antitopdick') | ||||||
|  |         antiglob_ = message['text'].startswith('/antiglobaldick') | ||||||
|  |  | ||||||
|  |         if antitop_: | ||||||
|  |             dickos = tops.get_antitops(top_=True, chat_id=message.chat.id) | ||||||
|  |             postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__ANTITOPDICK') | ||||||
|  |             await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__ANTITOPDICK', max_id=message.message_id) | ||||||
|  |         elif antiglob_: | ||||||
|  |             dickos = tops.get_antitops(glob_=True) | ||||||
|  |             postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__ANTIGLOBALDICK') | ||||||
|  |             await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__ANTIGLOBALDICK', max_id=message.message_id) | ||||||
|  |         else: | ||||||
|  |             logging.error('вызывают хз что!') | ||||||
|  |  | ||||||
|  |         if not dickos: | ||||||
|  |             await bot.send_message(message.chat.id, '🍌 У всех пользователей бубылда растёт! 🍆') | ||||||
|  |         else: | ||||||
|  |             if antitop_: | ||||||
|  |                 await bot.send_message(message.chat.id, '🚫Антитоп 10 вагись чата🚫\n\n' + dickos) | ||||||
|  |             elif antiglob_: | ||||||
|  |                 await bot.send_message(message.chat.id, '🚫Антитоп 10 вагись в мире🚫\n\n' + dickos) | ||||||
|  |     else: | ||||||
|  |         await message.reply('Работает только в общих чатах!\n'\ | ||||||
|  |                             'Вы можете посмотреть антитоп по миру /antiglobaldick') | ||||||
|  |  | ||||||
|  | async def clean_posts(chat_id, type=None, max_id=None): | ||||||
|  |     psts = postcleaner.get_posts_to_be_removed(chat_id, type, max_id) | ||||||
|  |  | ||||||
|  |     for p in psts: | ||||||
|  |         postcleaner.del_post(chat_id=p['chat_id'],  msg_id=p['msg_id']) | ||||||
|  |  | ||||||
|  |         #### TODO проверить админит ли бот | ||||||
|  |  | ||||||
|  |         try: | ||||||
|  |             await bot.delete_message(chat_id=p['chat_id'], message_id=p['msg_id']) | ||||||
|  |         except Exception as e:  | ||||||
|  |             logging.error('ошибка удаления поста-на-удаление') | ||||||
|  |             logging.error(e) | ||||||
							
								
								
									
										18
									
								
								handlers/start_help.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								handlers/start_help.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | |||||||
|  | from aiogram import types | ||||||
|  | from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton | ||||||
|  | from create_bot import dp, bot | ||||||
|  |  | ||||||
|  | @dp.message_handler(commands=['start']) | ||||||
|  | async def start_func(message: types.Message): | ||||||
|  |     if message.chat.type == 'private': | ||||||
|  |         lkb = InlineKeyboardMarkup(row_width=1).add(InlineKeyboardButton(text = 'Добавить в группу', callback_data='add_2_group')) | ||||||
|  |  | ||||||
|  |         await message.answer(f'<b>Добро пожаловать, {message.from_user.full_name}!</b>\n' | ||||||
|  |                              'Это бот, который растит члены. Чтобы начать, добавь бота в чат'\ | ||||||
|  |                              , reply_markup=lkb | ||||||
|  |                             ) | ||||||
|  | # TODO добавить кнопку, по которой смогут добавлять юзера в чат | ||||||
|  |  | ||||||
|  | @dp.callback_query_handler(text = 'add_2_group') | ||||||
|  | async def addgroup(callback: types.CallbackQuery): | ||||||
|  |     await callback.answer('жмав') | ||||||
							
								
								
									
										26
									
								
								handlers/time_new_year.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								handlers/time_new_year.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | from aiogram import types, Dispatcher | ||||||
|  | from create_bot import dp, bot | ||||||
|  | import datetime | ||||||
|  |  | ||||||
|  | @dp.message_handler(commands=["time"]) | ||||||
|  | async def send_time(message: types.Message): | ||||||
|  |     new_year = datetime.datetime(datetime.datetime.now().year, 12, 31) #дата нового года | ||||||
|  |     ct = datetime.datetime.now() #датавремя | ||||||
|  |     cd = datetime.datetime.now().strftime("%d/%m/%Y") #дата (д,м,г) | ||||||
|  |     ct1 = ct  # zoichem??? +datetime.timedelta(hours=15) # +14 часов от сервера | ||||||
|  |     ct2 = ct1.strftime('%H:%M') # форматирует датувремя просто во время(ч,м) | ||||||
|  |     raznitsa = (new_year - ct).days #отнимает от нг текущее время и получаем разницу в днях | ||||||
|  |  | ||||||
|  |     days = ['день', 'дня', 'дней'] | ||||||
|  |     if raznitsa % 10 == 1 and raznitsa % 100 != 11: | ||||||
|  |         p = 0 | ||||||
|  |     elif 2 <= raznitsa % 10 <= 4 and (raznitsa % 100 < 10 or raznitsa % 100 >= 20): | ||||||
|  |         p = 1 | ||||||
|  |     else: | ||||||
|  |         p = 2 | ||||||
|  |     num=(str(raznitsa) + ' ' + days[p]) | ||||||
|  |  | ||||||
|  |     await message.reply(f'Сегодня {cd} \nВремя: {ct2} \nДо Нового Года осталось {num}') | ||||||
|  |  | ||||||
|  | def register_handlers_time(dp: Dispatcher): | ||||||
|  |     dp.register_message_handler(send_time) | ||||||
							
								
								
									
										15
									
								
								jack_bot.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								jack_bot.service
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | # пример того что лежит на хосте | ||||||
|  | [Unit] | ||||||
|  | Description=pipisa-bot | ||||||
|  | After=network.target | ||||||
|  |  | ||||||
|  | [Service] | ||||||
|  | User=jack | ||||||
|  | Type=simple | ||||||
|  | Restart=always | ||||||
|  | WorkingDirectory=/usr/share/python_bot | ||||||
|  | ExecStart=/usr/bin/python3 /usr/share/python_bot/bot.py | ||||||
|  | ExecStart=/usr/bin/python3 /usr/share/python_bot/bot.py | ||||||
|  |  | ||||||
|  | [Install] | ||||||
|  | WantedBy=multi-user.target# | ||||||
							
								
								
									
										1
									
								
								pipisa_functions/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								pipisa_functions/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | from . import pipisa_time | ||||||
							
								
								
									
										77
									
								
								pipisa_functions/pipisa_time.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								pipisa_functions/pipisa_time.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | |||||||
|  | import unittest | ||||||
|  | import datetime | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def rolltime(check_datetime , curr_time=datetime.datetime.now()): | ||||||
|  |     last_time    = datetime.datetime.strptime(check_datetime, '%Y-%m-%d %H:%M:%S') | ||||||
|  |     time_to_grow = curr_time.replace(hour=10, minute=0, second=0, microsecond=0) #+ datetime.timedelta(days=0) | ||||||
|  |  | ||||||
|  |     timediff = (time_to_grow - last_time).total_seconds() | ||||||
|  |  | ||||||
|  |     # print() | ||||||
|  |     # print(f'\tlast_time : {last_time}') | ||||||
|  |     # print(f'\ttime_to_grow : {time_to_grow}') | ||||||
|  |     # print(f'\tcurr_time : {curr_time.strftime("%Y-%m-%d %H:%M:%S")}') | ||||||
|  |     # print(f'\t\tsecs diff : {timediff}') | ||||||
|  |  | ||||||
|  |     if timediff > 86400 or (curr_time > time_to_grow and last_time < time_to_grow): | ||||||
|  |         return True | ||||||
|  |     else: | ||||||
|  |         return False | ||||||
|  |   | ||||||
|  | class TestPipisa(unittest.TestCase): | ||||||
|  |     def test_very_long_ago(self): | ||||||
|  |         self.assertEqual(rolltime('2021-10-11 23:44:00'), True, "Пиписа прокручена очень давно. Очевидный прокрут") | ||||||
|  |  | ||||||
|  |     def test_just_after(self): | ||||||
|  |         self.assertEqual(rolltime( | ||||||
|  |             datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0).strftime('%Y-%m-%d %H:%M:%S') | ||||||
|  |             ), False, "Попытка крутить когда старый прокрут был через 1 минуту после сегодняшнего обновления роллов. Фейл.") | ||||||
|  |  | ||||||
|  |     def test_yesterdayroll(self): | ||||||
|  |         self.assertEqual( | ||||||
|  |             rolltime( | ||||||
|  |                 (  | ||||||
|  |                     datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) - datetime.timedelta(days=1) | ||||||
|  |                 ).strftime('%Y-%m-%d %H:%M:%S'), | ||||||
|  |                 datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) | ||||||
|  |             ), True, "Крутилась вчера через минуту после обновления роллов. Должно пропускать ") | ||||||
|  |          | ||||||
|  |     def test_hour_before_roll(self): | ||||||
|  |         self.assertEqual( | ||||||
|  |             rolltime( | ||||||
|  |                 (  | ||||||
|  |                     datetime.datetime.now().replace(hour=10, minute=1, second=1, microsecond=0) - datetime.timedelta(hours=1) | ||||||
|  |                 ).strftime('%Y-%m-%d %H:%M:%S'), | ||||||
|  |                 datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) | ||||||
|  |             ), True, "Крутилась последний раз за час до прокрута. Надо разрешать заново!") | ||||||
|  |          | ||||||
|  |     def test_after_midnight(self):  | ||||||
|  |         self.assertEqual( | ||||||
|  |             rolltime( | ||||||
|  |                 ( | ||||||
|  |                     datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) - datetime.timedelta(hours=14) | ||||||
|  |                 ).strftime('%Y-%m-%d %H:%M:%S'), | ||||||
|  |                 datetime.datetime.now().replace(hour=0, minute=11, second=8, microsecond=0) | ||||||
|  |             ), False, "Где-то ночью прокручивается повторно. Фейл.") | ||||||
|  |  | ||||||
|  |     def test_before_midnight(self): | ||||||
|  |         self.assertEqual( | ||||||
|  |             rolltime( | ||||||
|  |                 ( | ||||||
|  |                     datetime.datetime.now().replace(hour=10, minute=1, second=0, microsecond=0) - datetime.timedelta(hours=15) | ||||||
|  |                 ).strftime('%Y-%m-%d %H:%M:%S'), | ||||||
|  |                 datetime.datetime.now().replace(hour=0, minute=11, second=8, microsecond=0) - datetime.timedelta(hours=15) | ||||||
|  |             ), False, "Где-то ночью прокручивается повторно. Фейл.") | ||||||
|  |  | ||||||
|  |     def test_somewhere_after(self): | ||||||
|  |         self.assertEqual( | ||||||
|  |             rolltime( | ||||||
|  |                 ( | ||||||
|  |                     datetime.datetime.now().replace(hour=10, minute=18, second=0, microsecond=0) | ||||||
|  |                 ).strftime('%Y-%m-%d %H:%M:%S'), | ||||||
|  |                 datetime.datetime.now().replace(hour=10, minute=19, second=0, microsecond=0) | ||||||
|  |             ), False, "Сегодня уже открутили а хотят ещё. Фейл.") | ||||||
|  |  | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     unittest.main(verbosity=2) | ||||||
| @@ -1,6 +1,4 @@ | |||||||
| time | aiogram==2.15 | ||||||
| logging | python-arango | ||||||
|  | pyyaml | ||||||
| aiogram | prometheus-client | ||||||
| from aiogram import Bot, Dispatcher, executor, types |  | ||||||
| from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								ya-pidoras.jpg
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								ya-pidoras.jpg
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 77 KiB | 
		Reference in New Issue
	
	Block a user