config.php
+.ac-php-conf.json
{
"require": {
- "irazasyed/telegram-bot-sdk": "^2.0"
+ "irazasyed/telegram-bot-sdk": "^2.0",
+ "cmfcmf/openweathermap-php-api": "^2.4"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "4fc59fc846328b44db644ed8cd44face",
+ "content-hash": "a41da94e191cd544dfcb2eaaff20f9c4",
"packages": [
{
+ "name": "cmfcmf/openweathermap-php-api",
+ "version": "v2.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api.git",
+ "reference": "37f2e1178948a07c8d50d5063a15ca84b5b51f6a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/cmfcmf/OpenWeatherMap-PHP-Api/zipball/37f2e1178948a07c8d50d5063a15ca84b5b51f6a",
+ "reference": "37f2e1178948a07c8d50d5063a15ca84b5b51f6a",
+ "shasum": ""
+ },
+ "require": {
+ "ext-xml": "*",
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8 || ^5.0.5"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Cmfcmf\\": "Cmfcmf"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Flach (cmfcmf)",
+ "email": "cmfcmf.flach@gmail.com",
+ "homepage": "http://cmfcmf.github.io",
+ "role": "Developer"
+ }
+ ],
+ "description": "A php api to parse weather data from OpenWeatherMap.org. This api tries to normalise and abstract the data and remove inconsistencies.",
+ "homepage": "https://github.com/cmfcmf/OpenWeatherMap-PHP-Api",
+ "keywords": [
+ "OpenWeatherMap",
+ "api",
+ "free",
+ "owm",
+ "weather"
+ ],
+ "time": "2018-08-30T07:35:48+00:00"
+ },
+ {
"name": "doctrine/inflector",
"version": "v1.2.0",
"source": {
--- /dev/null
+<?php declare(strict_types=1);
+
+require 'common.php';
+
+use Cmfcmf\OpenWeatherMap;
+
+$temps =
+ array_values(
+array_map(function($forecast) {
+ return $forecast->temperature->now->getValue();
+},
+array_filter(
+ iterator_to_array(
+ (new OpenWeatherMap(OWM_API_KEY))->getWeatherForecast(2063523, 'metric', 'en', '', 2)
+ ),
+ function($forecast) {
+ $forecastDayLocal = DateTimeImmutable::createFromMutable($forecast->time->from)->setTimezone(new DateTimeZone('Australia/Perth'));
+ return (int)(new DateTimeImmutable())->format('d') + 1 == (int)$forecastDayLocal->format('d');
+ }
+)));
+
+getTelegram()->sendMessage(
+ [
+ 'chat_id' => array_flip(PARTICIPANT_IDS)['Cam'],
+ 'text' => max($temps) > 30
+ ? getString('goodnightWearShorts', ceil($temps[1]) . '°', ceil(max($temps)) . '°')
+ : getString('goodnight', ceil($temps[1]) . '°', ceil(max($temps)) . '°'),
+ ]
+);
'takeoutthebins' => 'Take out that BINZ #TrashSLAM 🚮',
'newbill' => '%s bill: $%s each due on the %s',
'billreminder' => '[REMINDER %d DAYS] %s bill: $%s each due on the %s',
- 'drinksomewater' => '🚰 Consider drinking some water! 💦 #HydrationNation'
-];
\ No newline at end of file
+ 'drinksomewater' => '🚰 Consider drinking some water! 💦 #HydrationNation',
+ 'goodnightWearShorts' => 'I\'m signing off for the night. Before I go; tomorrow it\'s going to be about %s when you get up and %s later in the day. So consider wearing summer clothes. ☀️☀️☀️',
+ 'goodnight' => 'I\'m signing off for the night. Before I go; tomorrow it\'s going to be about %s when you get up and %s later in the day. So consider wearing summer clothes.'
+];