@@ -14,6 +14,7 @@ use Discord\Discord as discord,
 | 
				
			|||||||
	Discord\Parts\Guild\Role as role,
 | 
						Discord\Parts\Guild\Role as role,
 | 
				
			||||||
	Discord\Parts\Guild\CommandPermissions as permissions,
 | 
						Discord\Parts\Guild\CommandPermissions as permissions,
 | 
				
			||||||
	Discord\Parts\User\Member as member,
 | 
						Discord\Parts\User\Member as member,
 | 
				
			||||||
 | 
						Discord\Parts\Guild\ScheduledEvent as schedule,
 | 
				
			||||||
	Discord\Parts\Interactions\Interaction as interaction,
 | 
						Discord\Parts\Interactions\Interaction as interaction,
 | 
				
			||||||
	Discord\WebSockets\Event as event,
 | 
						Discord\WebSockets\Event as event,
 | 
				
			||||||
	Discord\Parts\Interactions\Command\Command as command,
 | 
						Discord\Parts\Interactions\Command\Command as command,
 | 
				
			||||||
@@ -22,7 +23,9 @@ use Discord\Discord as discord,
 | 
				
			|||||||
	Discord\Parts\Interactions\Command\Option as option;
 | 
						Discord\Parts\Interactions\Command\Option as option;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Встроенные библиотеки
 | 
					// Встроенные библиотеки
 | 
				
			||||||
use exception;
 | 
					use exception,
 | 
				
			||||||
 | 
						datetime,
 | 
				
			||||||
 | 
						datetimezone;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Контроллер головного управления
 | 
					 * Контроллер головного управления
 | 
				
			||||||
@@ -123,16 +126,21 @@ final class index extends core
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
						if (
 | 
											if (
 | 
				
			||||||
							rand(0, 100) < 31
 | 
												rand(0, 100) < 31
 | 
				
			||||||
							and (levenshtein($_word, $marina, 2, 2, 1) < 3 && $word !== 'машина')
 | 
												and
 | 
				
			||||||
 | 
												match ($word) {
 | 
				
			||||||
 | 
													'машинка', 'мария', 'малинка', 'машина', 'малина' => false,
 | 
				
			||||||
 | 
													default => true
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												&& (levenshtein($_word, $marina, 2, 2, 1) < 3)
 | 
				
			||||||
							|| levenshtein($_word, $marishka, 2, 1, 2) < 4
 | 
												|| levenshtein($_word, $marishka, 2, 1, 2) < 4
 | 
				
			||||||
							|| levenshtein($_word, $marinochka, 2, 1, 2) < 4
 | 
												|| levenshtein($_word, $marinochka, 2, 1, 2) < 4
 | 
				
			||||||
							|| levenshtein($_word, $marinushka, 2, 1, 2) < 4
 | 
												|| levenshtein($_word, $marinushka, 2, 1, 2) < 4
 | 
				
			||||||
							|| (levenshtein($_word, $marya, 3, 3, 1) < 3 && $word !== 'мария')
 | 
												|| (levenshtein($_word, $marya, 3, 3, 1) < 3)
 | 
				
			||||||
						) {
 | 
											) {
 | 
				
			||||||
							// Найдено обращение к Марине и шанс 30%
 | 
												// Найдено обращение к Марине и шанс 30%
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							// Отправка сообщения
 | 
												// Отправка сообщения
 | 
				
			||||||
							$message->reply(_message::new()->setContent('ЗДАРОВА'));
 | 
												$message->reply(_message::new()->setContent(rand(0, 100) < 10 ? '🥺' : 'ЗДАРОВА'));
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						// Деинициализация неактуальных переменных
 | 
											// Деинициализация неактуальных переменных
 | 
				
			||||||
@@ -287,6 +295,153 @@ final class index extends core
 | 
				
			|||||||
				 */
 | 
									 */
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								foreach ($discord->guilds as $guild) {
 | 
				
			||||||
 | 
									// Перебор серверов
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (!($guild->guild_scheduled_events->get('name', 'Saturdaynik 🧹') instanceof schedule)) {
 | 
				
			||||||
 | 
										// Не найдено событие: "субботник"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										// Инициализация даты субботника
 | 
				
			||||||
 | 
										$date = new datetime('next saturday', new datetimezone('UTC'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if ($trash = $guild->channels->get('name', 'trash')) {
 | 
				
			||||||
 | 
											// Найден канал: "trash"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											if ($saturdaynik = $trash->threads->get('name', 'Saturdaynik 🧹')) {
 | 
				
			||||||
 | 
												// Найден канал для субботников
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												$saturdaynik->sendMessage("Next saturdaynik starts on <t:{$date->format('U')}:D>")
 | 
				
			||||||
 | 
													->then(function ($message) use ($discord, $date, $guild, $saturdaynik) {
 | 
				
			||||||
 | 
														// Закрепление сообщения
 | 
				
			||||||
 | 
														$saturdaynik->pinMessage($message, 'Notification about the next saturdaynik')
 | 
				
			||||||
 | 
															->then(function ($message) use ($saturdaynik) {
 | 
				
			||||||
 | 
																$saturdaynik->getMessageHistory(['limit' => 1])->then(function ($messages) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																	// Удаление сообщения о том, что Марина закрепила сообщение
 | 
				
			||||||
 | 
																	$messages->first()->delete();
 | 
				
			||||||
 | 
																});
 | 
				
			||||||
 | 
															});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
														// Создание события
 | 
				
			||||||
 | 
														$guild->guild_scheduled_events->save(
 | 
				
			||||||
 | 
															new schedule($discord, [
 | 
				
			||||||
 | 
																'name' => 'Saturdaynik 🧹',
 | 
				
			||||||
 | 
																'description' => "Global saturday cleaning on our server - saturdaynik!\nYour keyboards will be shine! 😼✨",
 | 
				
			||||||
 | 
																'scheduled_start_time' => $date->format(datetime::ATOM),
 | 
				
			||||||
 | 
																'scheduled_end_time' => (clone $date)->modify('+1 day')->format(datetime::ATOM),
 | 
				
			||||||
 | 
																'image' => \Discord\imageToBase64('images/saturdaynik/cover.jpg'),
 | 
				
			||||||
 | 
																'entity_type' => 3,
 | 
				
			||||||
 | 
																'entity_metadata' => [
 | 
				
			||||||
 | 
																	'location' => $message->getLinkAttribute()
 | 
				
			||||||
 | 
																],
 | 
				
			||||||
 | 
																'privacy_level' => 2
 | 
				
			||||||
 | 
															])
 | 
				
			||||||
 | 
														)->then(function ($event) use ($guild) {
 | 
				
			||||||
 | 
															if ($events = $guild->channels->get('name', 'events')) {
 | 
				
			||||||
 | 
																// Найден канал: "events
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																// Инициализация буфера идентификатора роли для оповещения о событиях
 | 
				
			||||||
 | 
																$id = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																foreach ($guild->roles as $role) {
 | 
				
			||||||
 | 
																	// Чтение ролей
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																	if ($role->name === "Events") {
 | 
				
			||||||
 | 
																		// Найдена роль для оповещения о событиях
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																		// Запись идентификатора роли
 | 
				
			||||||
 | 
																		$id = $role->id;
 | 
				
			||||||
 | 
																	}
 | 
				
			||||||
 | 
																}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																// Отправка сообщения с приглашением присоединиться к субботнику
 | 
				
			||||||
 | 
																$events->sendMessage((empty($id) ? '' : "<@&{$id}> ") . "https://discord.gg/pMZaxvH4?event={$event->id}");
 | 
				
			||||||
 | 
															}
 | 
				
			||||||
 | 
														});
 | 
				
			||||||
 | 
													});
 | 
				
			||||||
 | 
											} else {
 | 
				
			||||||
 | 
												// Не найден канал для субботников (подразумевается)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												// Создание канала (ветки) для субботников
 | 
				
			||||||
 | 
												$trash->startThread([
 | 
				
			||||||
 | 
													'name' => 'Saturdaynik 🧹'
 | 
				
			||||||
 | 
												], 'Thread for saturdaynik')
 | 
				
			||||||
 | 
													->then(function ($thread) use ($discord, $date, $guild, $trash) {
 | 
				
			||||||
 | 
														// Отправка первого сообщения в ветке с полной версией обложки
 | 
				
			||||||
 | 
														$thread->sendMessage(
 | 
				
			||||||
 | 
															_message::new()
 | 
				
			||||||
 | 
																->addFile('images/saturdaynik/source.jpg')
 | 
				
			||||||
 | 
														)
 | 
				
			||||||
 | 
															->then(function ($message) use ($discord, $date, $guild, $trash) {
 | 
				
			||||||
 | 
																if ($saturdaynik = $trash->threads->get('name', 'Saturdaynik 🧹')) {
 | 
				
			||||||
 | 
																	// Найден канал для субботников
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																	$saturdaynik->sendMessage("Next saturdaynik starts on <t:{$date->format('U')}:D>")
 | 
				
			||||||
 | 
																		->then(function ($message) use ($discord, $date, $guild, $saturdaynik) {
 | 
				
			||||||
 | 
																			// Закрепление сообщения
 | 
				
			||||||
 | 
																			$saturdaynik->pinMessage($message, 'Notification about the next saturdaynik')
 | 
				
			||||||
 | 
																				->then(function ($message) use ($saturdaynik) {
 | 
				
			||||||
 | 
																					$saturdaynik->getMessageHistory(['limit' => 1])->then(function ($messages) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																						// Удаление сообщения о том, что Марина закрепила сообщение
 | 
				
			||||||
 | 
																						$messages->first()->delete();
 | 
				
			||||||
 | 
																					});
 | 
				
			||||||
 | 
																				});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																			// Создание события
 | 
				
			||||||
 | 
																			$guild->guild_scheduled_events->save(
 | 
				
			||||||
 | 
																				new schedule($discord, [
 | 
				
			||||||
 | 
																					'name' => 'Saturdaynik 🧹',
 | 
				
			||||||
 | 
																					'description' => "Global saturday cleaning - saturdaynik!\nYour keyboards will be shine! 😼✨",
 | 
				
			||||||
 | 
																					'scheduled_start_time' => $date->format(datetime::ATOM),
 | 
				
			||||||
 | 
																					'scheduled_end_time' => (clone $date)->modify('+1 day')->format(datetime::ATOM),
 | 
				
			||||||
 | 
																					'image' => \Discord\imageToBase64('images/saturdaynik/cover.jpg'),
 | 
				
			||||||
 | 
																					'entity_type' => 3,
 | 
				
			||||||
 | 
																					'entity_metadata' => [
 | 
				
			||||||
 | 
																						'location' => $message->getLinkAttribute()
 | 
				
			||||||
 | 
																					],
 | 
				
			||||||
 | 
																					'privacy_level' => 2
 | 
				
			||||||
 | 
																				])
 | 
				
			||||||
 | 
																			)->then(function ($event) use ($guild) {
 | 
				
			||||||
 | 
																				if ($events = $guild->channels->get('name', 'events')) {
 | 
				
			||||||
 | 
																					// Найден канал: "events
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																					// Инициализация буфера идентификатора роли для оповещения о событиях
 | 
				
			||||||
 | 
																					$id = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																					foreach ($guild->roles as $role) {
 | 
				
			||||||
 | 
																						// Чтение ролей
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																						if ($role->name === "Events") {
 | 
				
			||||||
 | 
																							// Найдена роль для оповещения о событиях
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																							// Запись идентификатора роли
 | 
				
			||||||
 | 
																							$id = $role->id;
 | 
				
			||||||
 | 
																						}
 | 
				
			||||||
 | 
																					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
																					// Отправка сообщения с приглашением присоединиться к субботнику
 | 
				
			||||||
 | 
																					$events->sendMessage((empty($id) ? '' : "<@&{$id}> ") . "https://discord.gg/pMZaxvH4?event={$event->id}");
 | 
				
			||||||
 | 
																				}
 | 
				
			||||||
 | 
																			});
 | 
				
			||||||
 | 
																		});
 | 
				
			||||||
 | 
																} else {
 | 
				
			||||||
 | 
																	// Не найден канал для субботников (подразумевается)
 | 
				
			||||||
 | 
																}
 | 
				
			||||||
 | 
															});
 | 
				
			||||||
 | 
													});
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								$discord->on(event::GUILD_SCHEDULED_EVENT_CREATE, function (schedule $schedule, Discord $discord) {
 | 
				
			||||||
 | 
									/* var_dump($schedule); */
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			$discord->application->commands->save(new command($discord, [
 | 
								$discord->application->commands->save(new command($discord, [
 | 
				
			||||||
				'name' => 'dreamers',
 | 
									'name' => 'dreamers',
 | 
				
			||||||
				'description' => 'BEBRA DREAMERS',
 | 
									'description' => 'BEBRA DREAMERS',
 | 
				
			||||||
@@ -317,7 +472,6 @@ final class index extends core
 | 
				
			|||||||
				// Отправка ссылки с приглашением присоединиться на сервер BEBRA DREAMERS
 | 
									// Отправка ссылки с приглашением присоединиться на сервер BEBRA DREAMERS
 | 
				
			||||||
				if ($interaction->data->options->has('rules')) $interaction->respondWithMessage(_message::new()->setContent('https://rules.bebra.team'));
 | 
									if ($interaction->data->options->has('rules')) $interaction->respondWithMessage(_message::new()->setContent('https://rules.bebra.team'));
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
					 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		$this->discord->run();
 | 
							$this->discord->run();
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								mirzaev/marina/system/public/images/saturdaynik/cover.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mirzaev/marina/system/public/images/saturdaynik/cover.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 162 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								mirzaev/marina/system/public/images/saturdaynik/source.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mirzaev/marina/system/public/images/saturdaynik/source.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 316 KiB  | 
		Reference in New Issue
	
	Block a user