refactor: use plugins to combine multiple functions #1
Reference in New Issue
Block a user
Delete Branch "alpha"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
project changes:
the bot part
/versioncommandflaterrinline_utilslimiterpackage to limit the request ratethe plugin part
init()function or manually initialize inInitPlugins()functionhandler_params.Message,handler_params.InlineQueryFSMAllowAutoTriggerflag, but if there is more than one handler of the same type, a menu will be sentplugin changes:
udoneseudonese(no prefix) command as a slash command/udoneseforwardonly(rename tolimit_message)voicelist(deprecated)saved_messagemeilisearchas databasemessage_indexallow index message (use bot.ForwardMessage method to index message)stickerWebMandmp4toGIF, the conversion process is handled by ffmpeg.tgstoGIF, the conversion process is handled by lottie-converter and gifskidetect_keyword(new)teamspeak3(new)search_images(new)plugin_forwardonlyc908cf1745WIP: refactorto refactor<blockquote expandable>tag 5b2a26ac2aGetMessageFromHyperLinkfunc fa20d2219355eab58f07to066a28c0df556f0aebc5tob09f172f39GetMessageAttributepanic 818587881fupdatetypetoupdate_type29eb97a2bforiginInfoas a pointer to avoid empty value 7c2ee3968eplugin_inittointernal_plugin5275277777PanicCatcherto recover from panic 4ef2185892update_typetotype_utilscfa539c046type_utilspackage 737f77e86ahandler_utilstohandler_structs218eaf05d06165e4444dto24acba0bbatsClient.Close()to close client 034e00680bAllowAutoTriggerflag 664514ef0frefactorto refactor: make the bot framework into a templaterefactor: make the bot framework into a templateto WIP: refactor: make the bot framework into a templateadd `SaveDatabase` and `ReadDatabase` database operate function import `github.com/rs/zerolog` use as logger move most config into yaml config file use `filepath.Join()` to combine file path separate some function from `utils` move signal channel to `signals` package make exit code in `SignalsHandler()` change debug script output directory to `${workspaceFolder}/__debug_bin`handlers.go: fix wrong var utils/yaml/yaml.go remove fmt package plugins/teamspeak: allow check online client failed 5 times before reinit all and other: use err template plugin use yaml.Load() and yaml.Save() manage databases use mult error to recored all errorplugin_sticker: add sticker collect to channel feature allow detected `addsticker` link and show download sticker set button database: remove `IsInitialized` and `InitializedErr` in `DatabaseBackend` struct add `context.Context` params in `DatabaseBackend.Initializer` yaml_db: using `yaml.LoadYAML()` and `yaml.SaveYAML()` to save database file using `zerolog` logger replace `log` fix database file protection logic remove `addToYamlDB()` func update `Database.UpdateTimestamp` when change some flag handlers: fix `CustomSymbolCommand` trigger: use `strings.HasPrefix()` to replace `utils.CommandMaybeWithSuffixUsername()`, custom symbol command will not include robot username suffix consts: rename `YAMLDataBasePath` to `YAMLDataBaseDir` mess: remove `PrintLogAndSave()` funchandler_paramsfor each update type 94c249846bpackages: rename `errt` to `err_template` rename `multe` to `flat_err` rename `handler_structs` to `handler_params` with changes logger: move some fields to top logger create sub logger when need handler and sub-handler: create sub params when need plugin_utils: rename `CustomSymbolCommand` to `FullCommand` rename `SlashSymbolCommand` to `SlashCommand`search_imagesplugin 0240070c2b/searchlinkscommand bc91279e08err_templateandflat_errtoflate8751416074go-telegram/botto v1.16.0 2b93bba725`message_utils` and `update_utils`: rename `InString` method to `AsValue` `handlers.go`: make select sub handler logic as function `ByChatIDHandler` and `ByMessageTypeHandler`: remove `MessageHandler` field `plugin_udonese.go`: fix double answer add break when matched `handler_by_chatid.go`: add handler duplicate check `handler_by_message_type.go`: add handler duplicate check support limit handler trigger for some chat only (by set chat ID)byinline command to send media via fileid 288e57dc42CancelHandlerfunc and message notice 097e39316edetect_keyword: use format error message internal_plugin: add a `/cancle` command to let user know there is no state handler handler_state: show plugin name when user send `/cancle` commandinternal_plugin: add a `delete_this_message` callback query handler to delete any message trigger it handler_callback_query: fix `CallbackDatePrefix` field to `CallbackDataPrefix`12*5second 8994b76bc1flatetoflaterrc59c67f4b4b8a689f5a4tofd190b3a0futils.GetUserOrSenderChatDict()logic 084936ae48utils.go: add GetChatAdminIDs function plugin_udonese.go: reuse logger fieldmesspackage 57bbde12b8sub_package_plugin.gotobase.go092b736e55inline_utils9d9449261ainline_utils: add inline query parser configs: add `InlineCategorySymbol` config flag handlers.go: show match prefix inline commands when user typing saved_message: work with inline category featureupdate.Message: NewChatMembers LeftChatMember update.ChatMemberstartgroupbutton for detect keyword 1313bee157contain: remove `ChatType` func add `AnyType` func internal_plugin: allow all chat types for `/start` and `/help` commands only show default help message in `private` chat type add underline suffix to `WithPrefixHandler.Prefix` field when checking command prefix handler_command_slash_start.go: change default chat typesdelete_this_messageto replace other delete action 8f2cab65dadetect_keyword: `/setkeyword` allow for any chat type add `msg.From` nil check in `keywordDetector()` function add `detectkw_g_switch` error callback answer update message in group function manager keyboard send error message when failed to parse chat ID handler_state.go: add `opts.Message.From` nil check in `RunStateHandler()` function utils.go: add `msg.From` nil check in `GetMessageFromHyperLink()` functionhandler_state.go: use chat ID to get handler utils.go: `GetMessageFromHyperLink()` fix format add `TextBlockquoteMarkdown()` function plugin_detect_keyword.go: stop convert text to lowercase use `contain.SubStringCaseInsensitive()` replace `strings.Contains()` use `models.ParseModeMarkdown` in `notifyUser()`plugin_detect_keyword.go: keep use HTML parse mode fix init user bug utils.go: add `GetChatIDLink()` and `IgnoreHTMLTags()` functionplugin_utils: origin `handler_by_chatid` is fork as `handler_by_message_chat_id` rename `AddInlineHandlerHandlers` to `AddInlineHandlers`plugin_message_meilisearch: allow index message allow search mesage use command or inline mode saved_message: test channel mode stop add more entities change main data list sturcts utils: add `meilisearch_utils` package handler_state: rename `StateHandler` to `MessageStateHandler` register: add some field for `/chatinfo` command inline_utils: add a `KeywordQuery()` methodsaved_messageuse meiliserach f3226e6cf4OriginInfoin channel mode 70b71b459dvoicelistplugin 318a227f66saved_message: fix nil user panichandlers.go: add inline no command notice saved_message: allow edit description meilisearch_utils: add `omitempty` tag in MessageData structmessage_type: rename `OnlyText` to `Text`plugin_message_meilisearche2c2645e29plugin_message_meilisearch: become a sub-package of `saved_message` meilisearch_utils: rename `MsgID` to `ID` rename `MsgType` to `Type` saved_message: add search category map listorigin_info: add json tag for `OriginInfo` structsaved_message: add `NoticeChatID` field to receive notice default use first admin as notice chat utils: add `MsgLink` and `MsgLinkPrivate` function origin_info: use `tg://user?id=<userID>` to link to a usersaved_message6906ec5e7fsaved_message: fix no `InlineQueryResultsButton` error add result list check stop fetch public content when result list reaches "configs.BotConfig.InlineResultsPerPage" limit remove result pagination step fix wrong HTML tag plugin_teamspeak3: remove `expandable` attribute in pinned online user listGetCurrentFuncName()func to show function name 8986bf8f48go-telegram/botto v1.17.0 41609f3b04WIP: refactor: make the bot framework into a templateto refactor: make the bot framework into a templateconstsintoconfigspackage 4fc0131dfddatabase: move default database directory to `data/` environment: add `WEBHOOL_ADDR` add `LOG_CHAT_ID` add `LOG_FILE_PATH` rename `CONFIG_PATH_TO_FILE` to `CONFIG_PATH` rename `CONFIG_DIRECTORY` to `CONFIG_DIR`teamspeak3: add re-init timeoutslash start command: fix notes remove prefix argument underline suffix checkDeleteOldPinnedMessageflag a84d22e7e2detect_keyword: fix remove by message chat ID handlersync.RWMutexin yaml database f3324ca521signals: also save plugin database when exitMessage.Chat.IDto delete or save state handler 05db52679frefactor: make the bot framework into a templateto refactor: use plugins to combine multiple functionsrefactor: make the bot framework into a templateto refactor: use plugins to combine multiple functionsf1ad8358e1tofbb8fe04e2fbb8fe04e2to62cc4b320e.tgssticker async download bug ee69a5e98emain: remove multiple worker sticker: add download mutex lock add link for sticker set that exceed the size limitsticker: add missing error returnerror: use `utils.IgnoreHTMLTags()` warp some error collect sticker: show sticker count update detect keyword: make sure notice message not too longsticker: delay zip file close function internal: remove inline prefix handler `log` add slash command `log` add inline prefix handler `gc` version: add `github.com/dustin/go-humanize` for memory