武汉疫情实时播报 Telegram RSS

https://t.me/nCoV2019

https://rsshub.app/telegram/channel/nCoV2019

https://juzsharelah.wordpress.com

New NodeJS 12 feature look more enterprise java now

New NodeJS 12 support thread and it is more stable

Threads are almost stable!

With the last LTS we’ve got access to threads. Of course, it was an experimental feature and required a special flag called –experimental-worker for it to work.

With the upcoming LTS (Node 12) it’s still experimental, but won’t require a flag anymore. We are getting closer to a stable version!

https://morioh.com/p/027e49ee6bce/new-node-js-12-features-will-see-it-disrupt-ai-iot-and-more-surprising-areas

V8 Gets an Upgrade: V8 update to V8 7.4

Hello TLS 1.3

Properly configure default heap limits

Switch default http parser to llhttp

Making Native Modules Easier — progress continues

Worker Threads

Diagnostic Reports

Heap Dumps

Startup Improvements

ES6 Module Support

New compiler and platform minimums

https://medium.com/@nodejs/introducing-node-js-12-76c41a1b3f3f

The creation of Telegram MyWeatherTodayBot

What is Telegram?

Telegram is a messaging app with a focus on speed and security, it’s super-fast, simple and free. You can use Telegram on all your devices at the same time — your messages sync seamlessly across any number of your phones, tablets or computers.

With Telegram, you can send messages, photos, videos and files of any type (doc, zip, mp3, etc), as well as create groups for up to 200,000 people or channels for broadcasting to unlimited audiences. You can write to your phone contacts and find people by their usernames. As a result, Telegram is like SMS and email combined — and can take care of all your personal or business messaging needs.

What is Telegram Bot?

Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands and inline requests.

What is MyWeatherTodayBot?

MyWeatherTodayBot is a Telegram Bot that’s able to send your location and get real time weather forecast.

How MyWeatherTodayBot made?

MyWeatherTodayBot is made by PHP and a web service to get weather forecast. First it receives user input as location (latitude and longitude), and the bot will send a REST POST to an external web service to get weather forecast.

To make your own MyWeatherTodayBot, you need Telegram Apps, and Invited @BotFather (a Telegram own bot that you can create your bot) to your accounts, that you can get started to create bot.

Step by Step to create MyWeatherTodayBot

  1. Chat with @BotFather
  2. Click and send /newbot
  3. Name your bot
  4. Copy the API token and it looks like this: 898795721:AAGkiU2Taw83m6CDpVSpH4PaVbEaFkIByHo
  5. Write a PHP file and hosts on a web server, assume the location of the file is at https://<your web server>/bot/telegrambot.php
  6. With following code
[code] $endpoint = 'https://api.telegram.org/bot898795721:AAGkiU2Taw83m6CDpVSpH4PaVbEaFkIByHo'; $action = !empty($_GET['action']) ? $_GET['action']:''; function reply($chat_id, $text, $opts = array()) { global $endpoint; $url = $endpoint . ‘/sendMessage?text=’.urlencode($text) . ‘&chat_id=’.$chat_id; if(!empty($opts[‘reply_markup’])) { $url .= ‘&reply_markup=’ . json_encode($opts[‘reply_markup’]); } if(!empty($opts[‘parse_mode’])) { $url .= ‘&parse_mode=’ . urlencode($opts[‘parse_mode’]); } file_get_contents($url); } if($action == ‘setWebhook’) { $url = ‘https://<your web server>/bot/telegrambot.php?action=incoming’; echo file_get_contents($endpoint.’/setWebhook?url=’.urlencode($url)); } else if($action == ‘info’) { echo file_get_contents($endpoint.’/getMe’); } else if($action == ‘incoming’) { $entityBody = file_get_contents(‘php://input’); $incoming = json_decode($entityBody, true); $username = $incoming[‘message’][‘from’][‘username’]; $chatid = $incoming[‘message’][‘from’][‘id’]; $input = $incoming[‘message’][‘text’]; $location = $incoming[‘message’][‘location’]; if(!empty($location)) { $latitude = $location[‘latitude’]; $longitude = $location[‘longitude’]; $userData[‘weather’][‘latitude’] = $latitude; $userData[‘weather’][‘longitude’] = $longitude; $url = “https://api.imgshow-apps.com/?api=1&k=q:name=weather,lat=$latitude,lng=$longitude,display=label,stat=telegrambot”; $label = file_get_contents($url); reply($chatid, $label); } else { reply($chatid, ‘Enter your location to get weather now’, array( ‘reply_markup’ => array( ‘one_time_keyboard’ => true, ‘keyboard’ => array( array( array(‘text’ => ‘My Location’,’request_location’ => true) ) ) ) )); } } [/code]

 

7. Now, in your Internet browser, access https:///bot/telegrambot.php?action=setWebhook, which will register a webhook to your bot.

8. And now, you can start testing with your telegram bot now.