2023-03-14 02:11:19 +03:00
<!doctype html>
< html lang = "ru" class = "no-js" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width,initial-scale=1" >
< link rel = "canonical" href = "https://docs.struchkov.dev/godfather-telegram/spring/ru/develop/architecture/general/" >
2023-03-15 02:18:36 +03:00
< link rel = "prev" href = "../../guides/cyclic/" >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< link rel = "next" href = "../../changelog/" >
2023-03-14 02:11:19 +03:00
< link rel = "icon" href = "../../assets/favicon.ico" >
< meta name = "generator" content = "mkdocs-1.4.2, mkdocs-material-9.1.2+insiders-4.32.3" >
< title > Основная идея - GodFather Telegram< / title >
< link rel = "stylesheet" href = "../../assets/stylesheets/main.23dc5c81.min.css" >
< link rel = "stylesheet" href = "../../assets/stylesheets/palette.6932e648.min.css" >
< link rel = "preconnect" href = "https://fonts.gstatic.com" crossorigin >
< link rel = "stylesheet" href = "https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback" >
< style > : root { --md-text-font : "Roboto" ; --md-code-font : "Roboto Mono" } < / style >
< link rel = "stylesheet" href = "../../stylesheets/extra.css" >
< script > _ _md _scope = new URL ( "../.." , location ) , _ _md _hash = e => [ ... e ] . reduce ( ( e , _ ) => ( e << 5 ) - e + _ . charCodeAt ( 0 ) , 0 ) , _ _md _get = ( e , _ = localStorage , t = _ _md _scope ) => JSON . parse ( _ . getItem ( t . pathname + "." + e ) ) , _ _md _set = ( e , _ , t = localStorage , a = _ _md _scope ) => { try { t . setItem ( a . pathname + "." + e , JSON . stringify ( _ ) ) } catch ( e ) { } } < / script >
<!-- Yandex.Metrika counter -->
< script type = "text/javascript" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length ; j + + ) { if ( document . scripts [ j ] . src = == r ) { return ; } }
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(92567341, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
< / script >
< noscript > < div > < img src = "https://mc.yandex.ru/watch/92567215" style = "position:absolute; left:-9999px;" alt = "" / > < / div > < / noscript >
<!-- /Yandex.Metrika counter -->
< script > "undefined" != typeof _ _md _analytics && _ _md _analytics ( ) < / script >
< meta property = "og:type" content = "website" >
< meta property = "og:title" content = "Основная идея - GodFather Telegram" >
< meta property = "og:description" content = "None" >
< meta property = "og:image" content = "https://docs.struchkov.dev/godfather-telegram/spring/ru/develop/assets/images/social/architecture/general.png" >
< meta property = "og:image:type" content = "image/png" >
< meta property = "og:image:width" content = "1200" >
< meta property = "og:image:height" content = "630" >
< meta property = "og:url" content = "https://docs.struchkov.dev/godfather-telegram/spring/ru/develop/architecture/general/" >
< meta name = "twitter:card" content = "summary_large_image" >
< meta name = "twitter:title" content = "Основная идея - GodFather Telegram" >
< meta name = "twitter:description" content = "None" >
< meta name = "twitter:image" content = "https://docs.struchkov.dev/godfather-telegram/spring/ru/develop/assets/images/social/architecture/general.png" >
< / head >
< body dir = "ltr" data-md-color-scheme = "default" data-md-color-primary = "light-blue" data-md-color-accent = "indigo" >
< input class = "md-toggle" data-md-toggle = "drawer" type = "checkbox" id = "__drawer" autocomplete = "off" >
< input class = "md-toggle" data-md-toggle = "search" type = "checkbox" id = "__search" autocomplete = "off" >
< label class = "md-overlay" for = "__drawer" > < / label >
< div data-md-component = "skip" >
< a href = "#_1" class = "md-skip" >
Перейти к содержанию
< / a >
< / div >
< div data-md-component = "announce" >
< / div >
< div data-md-color-scheme = "default" data-md-component = "outdated" hidden >
< / div >
< header class = "md-header md-header--shadow md-header--lifted" data-md-component = "header" >
< nav class = "md-header__inner md-grid" aria-label = "Верхний колонтитул" >
< a href = "../.." title = "GodFather Telegram" class = "md-header__button md-logo" aria-label = "GodFather Telegram" data-md-component = "logo" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z" / > < / svg >
< / a >
< label class = "md-header__button md-icon" for = "__drawer" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z" / > < / svg >
< / label >
< div class = "md-header__title" data-md-component = "header-title" >
< div class = "md-header__ellipsis" >
< div class = "md-header__topic" >
< span class = "md-ellipsis" >
GodFather Telegram
< / span >
< / div >
< div class = "md-header__topic" data-md-component = "header-topic" >
< span class = "md-ellipsis" >
Основная идея
< / span >
< / div >
< / div >
< / div >
< form class = "md-header__option" data-md-component = "palette" >
< input class = "md-option" data-md-color-media = "(prefers-color-scheme)" data-md-color-scheme = "default" data-md-color-primary = "light-blue" data-md-color-accent = "indigo" aria-label = "Switch to light mode" type = "radio" name = "__palette" id = "__palette_0" >
< label class = "md-header__button md-icon" title = "Switch to light mode" for = "__palette_1" hidden >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "m14.3 16-.7-2h-3.2l-.7 2H7.8L11 7h2l3.2 9h-1.9M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12 20 8.69m-9.15 3.96h2.3L12 9l-1.15 3.65Z" / > < / svg >
< / label >
< input class = "md-option" data-md-color-media = "(prefers-color-scheme: light)" data-md-color-scheme = "default" data-md-color-primary = "light-blue" data-md-color-accent = "indigo" aria-label = "Switch to dark mode" type = "radio" name = "__palette" id = "__palette_1" >
< label class = "md-header__button md-icon" title = "Switch to dark mode" for = "__palette_2" hidden >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12 20 8.69Z" / > < / svg >
< / label >
< input class = "md-option" data-md-color-media = "(prefers-color-scheme: dark)" data-md-color-scheme = "slate" data-md-color-primary = "" data-md-color-accent = "" aria-label = "Switch to system preference" type = "radio" name = "__palette" id = "__palette_2" >
< label class = "md-header__button md-icon" title = "Switch to system preference" for = "__palette_0" hidden >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12c0-2.42-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12 20 8.69Z" / > < / svg >
< / label >
< / form >
< script > var media , input , key , value , palette = _ _md _get ( "__palette" ) ; if ( palette && palette . color ) { "(prefers-color-scheme)" === palette . color . media && ( media = matchMedia ( "(prefers-color-scheme: light)" ) , input = document . querySelector ( media . matches ? "[data-md-color-media='(prefers-color-scheme: light)']" : "[data-md-color-media='(prefers-color-scheme: dark)']" ) , palette . color . media = input . getAttribute ( "data-md-color-media" ) , palette . color . scheme = input . getAttribute ( "data-md-color-scheme" ) , palette . color . primary = input . getAttribute ( "data-md-color-primary" ) , palette . color . accent = input . getAttribute ( "data-md-color-accent" ) ) ; for ( [ key , value ] of Object . entries ( palette . color ) ) document . body . setAttribute ( "data-md-color-" + key , value ) } < / script >
< label class = "md-header__button md-icon" for = "__search" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z" / > < / svg >
< / label >
< div class = "md-search" data-md-component = "search" role = "dialog" >
< label class = "md-search__overlay" for = "__search" > < / label >
< div class = "md-search__inner" role = "search" >
< form class = "md-search__form" name = "search" >
< input type = "text" class = "md-search__input" name = "query" aria-label = "Поиск" placeholder = "Поиск" autocapitalize = "off" autocorrect = "off" autocomplete = "off" spellcheck = "false" data-md-component = "search-query" required >
< label class = "md-search__icon md-icon" for = "__search" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z" / > < / svg >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z" / > < / svg >
< / label >
< nav class = "md-search__options" aria-label = "Поиск" >
< button type = "reset" class = "md-search__icon md-icon" title = "Очистить" aria-label = "Очистить" tabindex = "-1" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z" / > < / svg >
< / button >
< / nav >
< div class = "md-search__suggest" data-md-component = "search-suggest" > < / div >
< / form >
< div class = "md-search__output" >
< div class = "md-search__scrollwrap" data-md-scrollfix >
< div class = "md-search-result" data-md-component = "search-result" >
< div class = "md-search-result__meta" >
Инициализация поиска
< / div >
< ol class = "md-search-result__list" role = "presentation" > < / ol >
< / div >
< / div >
< / div >
< / div >
< / div >
< div class = "md-header__source" >
< a href = "https://github.com/Godfather-Bots/telegram-bot" title = "Перейти к репозиторию" class = "md-source" data-md-component = "source" >
< div class = "md-source__icon md-icon" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 496 512" > <!-- ! Font Awesome Free 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --> < path d = "M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z" / > < / svg >
< / div >
< div class = "md-source__repository" >
Godfather-Bots/telegram-bot
< / div >
< / a >
< / div >
< / nav >
< nav class = "md-tabs" aria-label = "Вкладки" data-md-component = "tabs" >
< div class = "md-grid" >
< ul class = "md-tabs__list" >
< li class = "md-tabs__item" >
< a href = "../.." class = "md-tabs__link" >
О проекте
< / a >
< / li >
2023-03-15 02:18:36 +03:00
< li class = "md-tabs__item" >
< a href = "../../getting-started/hello-godfather/" class = "md-tabs__link" >
Конфигурация
< / a >
< / li >
< li class = "md-tabs__item" >
< a href = "../../guides/security/" class = "md-tabs__link" >
Гайды
< / a >
< / li >
2023-03-14 02:11:19 +03:00
< li class = "md-tabs__item" >
< a href = "./" class = "md-tabs__link md-tabs__link--active" >
Архитектура
< / a >
< / li >
2023-03-15 02:18:36 +03:00
< li class = "md-tabs__item" >
< a href = "../../changelog/" class = "md-tabs__link" >
ChangeLog
< / a >
< / li >
< li class = "md-tabs__item" >
< a href = "../../support-development/" class = "md-tabs__link" >
Поддержать
< / a >
< / li >
2023-03-14 02:11:19 +03:00
< / ul >
< / div >
< / nav >
< / header >
< div class = "md-container" data-md-component = "container" >
< main class = "md-main" data-md-component = "main" >
< div class = "md-main__inner md-grid" >
< div class = "md-sidebar md-sidebar--primary" data-md-component = "sidebar" data-md-type = "navigation" >
< div class = "md-sidebar__scrollwrap" >
< div class = "md-sidebar__inner" >
< nav class = "md-nav md-nav--primary md-nav--lifted md-nav--integrated" aria-label = "Навигация" data-md-level = "0" >
< label class = "md-nav__title" for = "__drawer" >
< a href = "../.." title = "GodFather Telegram" class = "md-nav__button md-logo" aria-label = "GodFather Telegram" data-md-component = "logo" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z" / > < / svg >
< / a >
GodFather Telegram
< / label >
< div class = "md-nav__source" >
< a href = "https://github.com/Godfather-Bots/telegram-bot" title = "Перейти к репозиторию" class = "md-source" data-md-component = "source" >
< div class = "md-source__icon md-icon" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 496 512" > <!-- ! Font Awesome Free 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --> < path d = "M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z" / > < / svg >
< / div >
< div class = "md-source__repository" >
Godfather-Bots/telegram-bot
< / div >
< / a >
< / div >
< ul class = "md-nav__list" data-md-scrollfix >
2023-03-15 02:18:36 +03:00
< li class = "md-nav__item md-nav__item--pruned md-nav__item--nested" >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< a href = "../.." class = "md-nav__link" >
< span class = "md-ellipsis" >
О проекте
< / span >
< / a >
< / li >
2023-03-14 02:11:19 +03:00
< li class = "md-nav__item md-nav__item--pruned md-nav__item--nested" >
2023-03-15 02:18:36 +03:00
< a href = "../../getting-started/hello-godfather/" class = "md-nav__link" >
2023-03-14 02:11:19 +03:00
< span class = "md-ellipsis" >
2023-03-15 02:18:36 +03:00
Конфигурация
2023-03-14 02:11:19 +03:00
< / span >
< span class = "md-nav__icon md-icon" > < / span >
< / a >
< / li >
2023-03-15 02:18:36 +03:00
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< li class = "md-nav__item md-nav__item--pruned md-nav__item--nested" >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< a href = "../../guides/security/" class = "md-nav__link" >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< span class = "md-ellipsis" >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
Гайды
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< / span >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< span class = "md-nav__icon md-icon" > < / span >
< / a >
< / li >
2023-03-14 02:11:19 +03:00
< li class = "md-nav__item md-nav__item--active md-nav__item--nested" >
2023-03-15 02:18:36 +03:00
< input class = "md-nav__toggle md-toggle " type = "checkbox" id = "__nav_4" checked >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< label class = "md-nav__link" for = "__nav_4" id = "__nav_4_label" tabindex = "0" >
2023-03-14 02:11:19 +03:00
< span class = "md-ellipsis" >
Архитектура
< / span >
< span class = "md-nav__icon md-icon" > < / span >
< / label >
2023-03-15 02:18:36 +03:00
< nav class = "md-nav" data-md-level = "1" aria-labelledby = "__nav_4_label" aria-expanded = "true" >
< label class = "md-nav__title" for = "__nav_4" >
2023-03-14 02:11:19 +03:00
< span class = "md-nav__icon md-icon" > < / span >
Архитектура
< / label >
< ul class = "md-nav__list" data-md-scrollfix >
< li class = "md-nav__item md-nav__item--active" >
< input class = "md-nav__toggle md-toggle" type = "checkbox" id = "__toc" >
< label class = "md-nav__link md-nav__link--active" for = "__toc" >
< span class = "md-ellipsis" >
Основная идея
< / span >
< span class = "md-nav__icon md-icon" > < / span >
< / label >
< a href = "./" class = "md-nav__link md-nav__link--active" >
< span class = "md-ellipsis" >
Основная идея
< / span >
< / a >
< nav class = "md-nav md-nav--secondary" aria-label = "Содержание" >
< label class = "md-nav__title" for = "__toc" >
< span class = "md-nav__icon md-icon" > < / span >
Содержание
< / label >
< ul class = "md-nav__list" data-md-component = "toc" data-md-scrollfix >
< li class = "md-nav__item" >
< a href = "#_2" class = "md-nav__link" >
< span class = "md-ellipsis" >
< span class = "md-typeset" >
Юнит
< / span >
< / span >
< / a >
< / li >
< li class = "md-nav__item" >
2023-03-15 02:18:36 +03:00
< a href = "#_3" class = "md-nav__link" >
2023-03-14 02:11:19 +03:00
< span class = "md-ellipsis" >
< span class = "md-typeset" >
Сценарий
< / span >
< / span >
< / a >
< / li >
< li class = "md-nav__item" >
2023-03-15 02:18:36 +03:00
< a href = "#_4" class = "md-nav__link" >
2023-03-14 02:11:19 +03:00
< span class = "md-ellipsis" >
< span class = "md-typeset" >
Механизм выбора юнита
< / span >
< / span >
< / a >
< / li >
< / ul >
< / nav >
< / li >
2023-03-15 02:18:36 +03:00
< / ul >
< / nav >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
< / li >
2023-03-14 02:11:19 +03:00
2023-03-15 02:18:36 +03:00
2023-03-14 02:11:19 +03:00
< li class = "md-nav__item" >
2023-03-15 02:18:36 +03:00
< a href = "../../changelog/" class = "md-nav__link" >
2023-03-14 02:11:19 +03:00
< span class = "md-ellipsis" >
2023-03-15 02:18:36 +03:00
ChangeLog
2023-03-14 02:11:19 +03:00
< / span >
< / a >
< / li >
2023-03-15 02:18:36 +03:00
2023-03-14 02:11:19 +03:00
< li class = "md-nav__item" >
2023-03-15 02:18:36 +03:00
< a href = "../../support-development/" class = "md-nav__link" >
2023-03-14 02:11:19 +03:00
< span class = "md-ellipsis" >
2023-03-15 02:18:36 +03:00
Поддержать
2023-03-14 02:11:19 +03:00
< / span >
< / a >
< / li >
< / ul >
< / nav >
< / div >
< / div >
< / div >
< div class = "md-content" data-md-component = "content" >
< article class = "md-content__inner md-typeset" >
< a href = "https://github.com/Godfather-Bots/telegram-bot/edit/master/docs/architecture/general.md" title = "Редактировать страницу" class = "md-content__button md-icon" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M10 20H6V4h7v5h5v3.1l2-2V8l-6-6H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h4v-2m10.2-7c.1 0 .3.1.4.2l1.3 1.3c.2.2.2.6 0 .8l-1 1-2.1-2.1 1-1c.1-.1.2-.2.4-.2m0 3.9L14.1 23H12v-2.1l6.1-6.1 2.1 2.1Z" / > < / svg >
< / a >
< h1 id = "_1" > Основная идея< a class = "headerlink" href = "#_1" title = "Permanent link" > ⚓︎< / a > < / h1 >
2023-03-15 02:18:36 +03:00
< p > Проект GodFather направлен на унификацию создания ботов для различных мессенджеров сетей.< / p >
< h2 id = "_2" > Юнит< a class = "headerlink" href = "#_2" title = "Permanent link" > ⚓︎< / a > < / h2 >
< p > Базовая сущность фреймворка. Юнит содержит в с е б е различные лямба выражения, которые встраиваются в процесс обработки сообщений. Именно в написании этих лямбд и заключается основная работа с библиотекой.< / p >
< p > Есть несколько разных типов юнитов, подробнее о каждом читайте в отдельном разделе.< / p >
< p > Юнит представляет собой некую конфигурацию, которая передается в обработчик юнита. У каждого типа юнита есть свой обработчик. < / p >
< p > Юниты могут образовывать связный список, тем самым определяя дерево сценарий бота.< / p >
< h2 id = "_3" > Сценарий< a class = "headerlink" href = "#_3" title = "Permanent link" > ⚓︎< / a > < / h2 >
2023-03-14 02:11:19 +03:00
< p > Для понимания рассмотрим небольшой пример по схеме изображенной ниже. Так же небольшие примеры обработки есть в тестах.< / p >
< p > < img align = "left" alt = "Типичный сценарий" loading = "lazy" src = "../img/scenario.png" / > < / p >
< p > Сценариями в данном случае являются:< / p >
< ul >
< li > Unit1 —> Unit2 —> Unit5 —> Unit7 —> Unit9< / li >
< li > Unit1 —> Unit2 —> Unit6 —> Unit8;< / li >
< li > Unit1 —> Unit3 —> Unit6 —> Unit8;< / li >
< li > Unit1 —> Unit4 —> Unit9;< / li >
< li > Unit10.< / li >
< / ul >
< p > Пользователь присылает боту свое первое сообщение, например, «Привет». Если сообщение удовлетворяет регулярному выражению или содержит необходимое количество ключевых слов Unit1, то возвращается Unit1, то же самое относится к Unit10.< / p >
< p > Если о б а юнита удовлетворяют запросу пользователя, то будет возвращен юнит с большим приоритетом (поле priority). Если приоритеты равны, то случайный Unit.< / p >
< p > В нашем примере, на первое сообщение, пользователь получил Unit1, поэтому следующее сообщение пользователя будет ассоциироваться с множеством: Unit2, Unit3 и Unit4.< / p >
2023-03-15 02:18:36 +03:00
< h2 id = "_4" > Механизм выбора юнита< a class = "headerlink" href = "#_4" title = "Permanent link" > ⚓︎< / a > < / h2 >
< p class = "annotate" > Пока сценарий линейный никакой необходимости в определении юнита нет. Однако, когда у вас на одном уровне находится несколько юнитов, то возникает необходимость выбрать юнит для последующей обработки сообщений. (1)< / p >
< ol >
< li > Обратимся к предыдущей схеме сценария. Как выбрать какой юнит обработать после обработки Unit 1?< / li >
< / ol >
< p > Юниты обладают триггерами, которые сигнализируют о том, что данный юнит может обработать запрос от пользователя. < / p >
< p > Механизм выбора можно описать несколькими этапами:< / p >
< ul >
< li > Сначала проверяются триггеры у всех юнитов.< / li >
< li > В с е юниты, триггеры которых сработали, являются потенциальными кандидатами на обработку< / li >
< li > Из этих юнитов выбирается юнит с наибольшим приоритетом. Если у них одинаковый приоритет, то выбирается случайный юнит.< / li >
< / ul >
< p class = "annotate" > Н о как выбираются первые юниты (1) для обработки? В начале сценария стоят main юниты. Именно main юниты участвуют в первом раунде выбора обработчика. Чтобы создать main юнит, необходимо в аннотации < code > @Unit< / code > установить параметр < code > main = true< / code > .< / p >
< ol >
< li > Н а схеме это Unit 1 и Unit 2< / li >
< / ol >
< p > Также существуют так называемые глобальные юниты, которые участвуют в каждом раунде выбора. Чтобы создать глобальный unit, необходимо в аннотации < code > @Unit< / code > установить параметр < code > global = true< / code > .< / p >
2023-03-14 02:11:19 +03:00
< h2 id = "__comments" > Комментарии< / h2 >
< div id = "remark42" > < / div >
< script >
var remark_config = {
host: "https://comments.struchkov.dev",
site_id: 'docs',
components: ['embed'],
locale: 'ru',
theme: localStorage.theme,
show_email_subscription: true,
simple_view: false
};
< / script >
< script > ! function ( e , n ) { for ( var o = 0 ; o < e . length ; o ++ ) { var r = n . createElement ( "script" ) , c = ".js" , d = n . head || n . body ; "noModule" in r ? ( r . type = "module" , c = ".mjs" ) : r . async = ! 0 , r . defer = ! 0 , r . src = remark _config . host + "/web/" + e [ o ] + c , d . appendChild ( r ) } } ( remark _config . components || [ "embed" ] , document ) ; < / script >
< / article >
< / div >
< script > var target = document . getElementById ( location . hash . slice ( 1 ) ) ; target && target . name && ( target . checked = target . name . startsWith ( "__tabbed_" ) ) < / script >
< / div >
< / main >
< footer class = "md-footer" >
< nav class = "md-footer__inner md-grid" aria-label = "Нижний колонтитул" >
2023-03-15 02:18:36 +03:00
< a href = "../../guides/cyclic/" class = "md-footer__link md-footer__link--prev" aria-label = "Назад: Циклическая зависимость" rel = "prev" >
2023-03-14 02:11:19 +03:00
< div class = "md-footer__button md-icon" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z" / > < / svg >
< / div >
< div class = "md-footer__title" >
< div class = "md-ellipsis" >
< span class = "md-footer__direction" >
Назад
< / span >
2023-03-15 02:18:36 +03:00
Циклическая зависимость
2023-03-14 02:11:19 +03:00
< / div >
< / div >
< / a >
2023-03-15 02:18:36 +03:00
< a href = "../../changelog/" class = "md-footer__link md-footer__link--next" aria-label = "Вперед: ChangeLog" rel = "next" >
2023-03-14 02:11:19 +03:00
< div class = "md-footer__title" >
< div class = "md-ellipsis" >
< span class = "md-footer__direction" >
Вперед
< / span >
2023-03-15 02:18:36 +03:00
ChangeLog
2023-03-14 02:11:19 +03:00
< / div >
< / div >
< div class = "md-footer__button md-icon" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 24 24" > < path d = "M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z" / > < / svg >
< / div >
< / a >
< / nav >
< div class = "md-footer-meta md-typeset" >
< div class = "md-footer-meta__inner md-grid" >
< div class = "md-copyright" >
< div class = "md-copyright__highlight" >
Copyright © 2018 - 2023 Struchkov Mark
< / div >
< / div >
< / div >
< / div >
< / footer >
< / div >
< div class = "md-dialog" data-md-component = "dialog" >
< div class = "md-dialog__inner md-typeset" > < / div >
< / div >
< script id = "__config" type = "application/json" > { "base" : "../.." , "features" : [ "navigation.instant" , "navigation.indexes" , "navigation.sections" , "navigation.tracking" , "navigation.footer" , "navigation.tabs" , "navigation.tabs.sticky" , "navigation.prune" , "search" , "search.suggest" , "search.highlight" , "content.action.edit" , "content.code.copy" , "content.code.annotate" , "content.tooltips" , "toc.follow" , "toc.integrate" ] , "search" : "../../assets/javascripts/workers/search.6c7302c4.min.js" , "translations" : { "clipboard.copied" : "\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u0431\u0443\u0444\u0435\u0440" , "clipboard.copy" : "\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440" , "search.result.more.one" : "\u0415\u0449\u0451 1 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435" , "search.result.more.other" : "\u0415\u0449\u0451 # \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435" , "search.result.none" : "\u0421\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e" , "search.result.one" : "\u041d\u0430\u0439\u0434\u0435\u043d\u043e 1 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435" , "search.result.other" : "\u041d\u0430\u0439\u0434\u0435\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439: #" , "search.result.placeholder" : "\u041d\u0430\u0447\u043d\u0438\u0442\u0435 \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430" , "search.result.term.missing" : "\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442" , "select.version" : "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u044e" } , "version" : { "provider" : "mike" } } < / script >
< script src = "../../assets/javascripts/bundle.a3170f90.min.js" > < / script >
< / body >
< / html >