diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2fa7ce7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+config.ini
diff --git a/.idea/php.xml b/.idea/php.xml
index f324872..e84699f 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -10,6 +10,7 @@
+
diff --git a/config-example.ini b/config-example.ini
new file mode 100644
index 0000000..e08cb19
--- /dev/null
+++ b/config-example.ini
@@ -0,0 +1,18 @@
+; Each bot is given a unique authentication token when it is created.
+; The token looks something like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11.
+; You can learn about obtaining tokens and generating new ones in the Telegram Bot API document.
+token =
+
+; The Telegram Bot API endpoint. Change this when you want to use your own Bot API server.
+endpoint = https://api.telegram.org/bot
+
+; The file that saves the last update id to tell Telegram that we already processed the updates.
+last_update_id_file = last-update-id.txt
+
+; Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
+limit = 100
+
+; Timeout in seconds for long polling.
+; Defaults to 0, i.e. usual short polling.
+; Should be positive, short polling should be used for testing purposes only.
+timeout = 60
diff --git a/last-update-id.txt b/last-update-id.txt
new file mode 100644
index 0000000..b38341f
--- /dev/null
+++ b/last-update-id.txt
@@ -0,0 +1 @@
+952645275
\ No newline at end of file
diff --git a/main.php b/main.php
new file mode 100755
index 0000000..029f881
--- /dev/null
+++ b/main.php
@@ -0,0 +1,71 @@
+#!/usr/bin/env php
+ file_exists($config['last_update_id_file']) ? (int)file_get_contents($config['last_update_id_file']) : 0;
+$putLastUpdateId = fn($lastUpdateId) => file_put_contents($config['last_update_id_file'], "$lastUpdateId");
+
+// request Telegram Bot API
+$requestApi = fn(string $method, ?array $payload = null) => json_decode(file_get_contents(
+ "$config[endpoint]$config[token]/$method",
+ false,
+ stream_context_create(['http' => [
+ 'method' => 'POST',
+ 'header' => 'Content-Type: application/json',
+ 'content' => json_encode($payload),
+ ]]),
+), true);
+
+// some method we are using
+$getMe = fn() => $requestApi('getMe');
+$getUpdates = fn(int $offset = 0) => $requestApi('getUpdates', [
+ 'offset' => $offset,
+ 'limit' => (int)$config['limit'],
+ 'timeout' => (int)$config['timeout'],
+]);
+$sendMessage = fn($params) => $requestApi('sendMessage', $params);
+
+$response = $getMe();
+if (!$response['ok']) {
+ error_log('Failed to start the bot.');
+ error_log("Error message: $response[description]");
+ error_log("Error code: $response[error_code]");
+ exit(1);
+}
+
+$me = $response['result'];
+error_log('Login as: ' . json_encode($me, JSON_UNESCAPED_UNICODE));
+error_log('Start receiving updates…');
+while (($response = $getUpdates($getLastUpdateId() + 1))['ok']) {
+ $updates = $response['result'];
+ $lastUpdateId = null;
+ foreach ($updates as $update) {
+ $lastUpdateId = $update['update_id'];
+
+ error_log('Got an update: ' . json_encode($update, JSON_UNESCAPED_UNICODE));
+ if (isset($update['message'])) {
+ $sendMessage([
+ 'chat_id' => $update['message']['chat']['id'],
+ 'text' => '喵',
+ 'reply_to_message_id' => $update['message']['message_id'],
+ ]);
+ }
+
+ $putLastUpdateId($lastUpdateId);
+ }
+}
+
+if (!$response['ok']) {
+ error_log('Failed to get updates.');
+ error_log("Error message: $response[description]");
+ error_log("Error code: $response[error_code]");
+ exit(1);
+}