Download the PHP package matucana/weather-bot without Composer
On this page you can find all versions of the php package matucana/weather-bot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matucana/weather-bot
More information about matucana/weather-bot
Files in matucana/weather-bot
Package weather-bot
Short Description Weather bot sending notifications to vk.com
License MIT
Homepage https://github.com/matucana/weather-bot
Informations about the package weather-bot
Weather bot
Простой проект для отправки погоды в беседу Вконтакте.
Какую задачу решает данный проект?
Есть беседа Вконтакте, в которой общаются работники небольшого тепличного хозяйства. Для планирования деятельности в течение дня часто требуется узнавать прогноз погоды. Данный проект, получает прогноз погоды, используя API OpenWeatherMap, форматирует его, и отправляет его в беседу Вконтакте. Отправка по расписанию производится с помощью cron.
Установка и использование
Weather bot доступен в Packagist (с использованием семантического управления версиями), и установка через Composer является рекомендуемым способом установки Weather bot.
Для установки, выполните команду:
Перейдите в директорию /config/
и переименуйте файл example.env
в .env
Пропишите в файле.env необходимые настройки:
- Ключ API openweathermap.org
- Географическая широта местоположения, для которого необходимо получать погоду.
- Географическая долгота местоположения, для которого необходимо получать погоду.
- Ключ API vk.com
- ID беседы, в которую будут отсылаться сообщения
Настройте запуск файла index.php
в cron, с нужной для вас периодичностью.
Обработчики
В текущей версии проекта есть два готовых обработчика:
Matucana\WeatherBot\Handlers\VkHandler
- для отправки в беседу Вконтакте.
Matucana\WeatherBot\Handlers\FileHandler
- для сохранения прогноза в файл.
Создание обработчиков
Вы можете создать свой собственный обработчик, например для отправки в другой мессенджер, или для сохранения в файл.
Для этого вам необходимо, создать класс, который имплементирует интерфейс Matucana\WeatherBot\Handlers\Handler
Обработчик можно подключить с помощью метода
$app->addHandler(Handler $mainHandler)
Если вы хотите подключить несколько обработчиков, используйте метод
$app->addHandlers(array $handlers)
Полезные ссылки:
- Документация Open Weather API
- Документация Vk.com API
- Репозиторий пакета
cmfcmf/openweathermap-php-api
- Настройка Cron
Лицензия
MIT License
Copyright (c) 2021 Matucana
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Контакты:
All versions of weather-bot with dependencies
symfony/dotenv Version 5.2.*
vkcom/vk-php-sdk Version 5.101.*
cmfcmf/openweathermap-php-api Version 3.3.*
http-interop/http-factory-guzzle Version 1.0.*
php-http/guzzle6-adapter Version 2.0.*
php-di/php-di Version ^6.3
monolog/monolog Version *