Skip to content

Instantly share code, notes, and snippets.

View Mihonarium's full-sized avatar

Mikhail Samin Mihonarium

View GitHub Profile
<?php
/*
*
* Пример простого чат-бота, отвечающего фразами по шаблону.
* Основано на примере из vk.com/dev.
* Распространяется свободно. Автор - Михаил Самин.
*
*/
function echo_ok()
{
<?php
/*
*
* Пример кода для редактирования шаблонов простого чат-бота.
* Основано на Ace.
* Распространяется свободно. Автор - Михаил Самин.
*
*/
session_start();
$mysqli = new mysqli("IP","USER","PASS", "DB");
div.jsoneditor .jsoneditor-search input{height:auto;border:inherit}div.jsoneditor .jsoneditor-search input:focus{border:none!important;box-shadow:none!important}div.jsoneditor table{border-collapse:collapse;width:auto}div.jsoneditor td,div.jsoneditor th{padding:0;display:table-cell;text-align:left;vertical-align:inherit;border-radius:inherit}div.jsoneditor-field,div.jsoneditor-readonly,div.jsoneditor-value{border:1px solid transparent;min-height:16px;min-width:32px;padding:2px;margin:1px;word-wrap:break-word;float:left}div.jsoneditor-field p,div.jsoneditor-value p{margin:0}div.jsoneditor-value{word-break:break-word}div.jsoneditor-readonly{min-width:16px;color:gray}div.jsoneditor-empty{border-color:#d3d3d3;border-style:dashed;border-radius:2px}div.jsoneditor-field.jsoneditor-empty::after,div.jsoneditor-value.jsoneditor-empty::after{pointer-events:none;color:#d3d3d3;font-size:8pt}div.jsoneditor-field.jsoneditor-empty::after{content:"field"}div.jsoneditor-value.jsoneditor-empty::after{content:"value"}a.jsonedito
/*!
* jsoneditor.js
*
* @brief
* JSONEditor is a web-based tool to view, edit, format, and validate JSON.
* It has various modes such as a tree editor, a code editor, and a plain text
* editor.
*
* Supported browsers: Chrome, Firefox, Safari, Opera, Internet Explorer 8+
*
CREATE TABLE `json` (
`json_id` int(11) NOT NULL,
`json` text COLLATE utf8_unicode_ci NOT NULL,
`json_bad` text COLLATE utf8_unicode_ci NOT NULL,
`json_original` text COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `json` (`json_id`, `json`, `json_bad`, `json_original`) VALUES
(1, '[\r\n {\r\n \"q\": [\r\n \"добраться\",\r\n \"доехать\",\r\n \"доехать\",\r\n \"где проходить\",\r\n \"где\"\r\n ],\r\n \"a\": \"КВЦ Экспофорум, как добраться: http://expoforum-center.ru/ru/map/\\nВсе три дня фестиваля будет ходить бесплатный автобус от ст.м. Московская раз в полчаса.\"\r\n },\r\n {\r\n \"q\": [\r\n \"когда\",\r\n \"когда\",\r\n \"сколько начинается\",\r\n \"расписанием\"\r\n ],\r\n \"a\": \"Старкон пройдет с 28 по 30 июля, экспозона будет открыта с 14:00 до 20:00.\\nВ группе ВКонтакте (vk.com/starcon) отражено актуальное расписание и активности фестиваля. Подписывайтесь, чтобы ничег
<?php
include('include/bot_fs.php');
include('include/vk_fs.php');
$confirmation_token = '/* скрыто */';
$token = '/* скрыто */';
$data = json_decode(file_get_contents('php://input'));
$group_id = $data->group_id;
<?php
function echo_ok() {
ob_start();
echo 'ok';
$length = ob_get_length();
header('Connection: close');
header("Content-Length: " . $length);
header("Content-Encoding: none");
<?php
include 'bot_functions.php';
function downloadAudioFile($audiolink)
{
$ext = 'mp3';
$saveFile = 'tmp/'.md5(microtime(true)).'.'.$ext;
file_put_contents("$saveFile", fopen("$audiolink", 'r'));
return $saveFile;

Keybase proof

I hereby claim:

  • I am mihonarium on github.
  • I am mihonarium (https://keybase.io/mihonarium) on keybase.
  • I have a public key ASDS_NKvBMDYetF7UgN430JNqUYoDWHMEAtEGzxSmVg2NQo

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.