handlers.go:
add document log
refactor `messageHandler()` function, it now is update type `message` handler
the parameter type of `inlineHandler()` function is changed to `*handler_params.InlineQuery`
the parameter type of `callbackQueryHandler()` function is changed to `*handler_params.CallbackQuery`
config.go:
change default log file to `warn`
handler_by_chatid.go,
handler_command_full.go,
handler_command_slash.go,
handler_command_slash_start.go,
handler_command_suffix.go,
handler_state.go:
only allow `MessageHandler`
handler_by_message_type.go:
only allow `MessageHandler`
copy `update.CallbackQuery.Message.Message.ReplyToMessage` to `params.Message` in `SelectByMessageTypeHandlerCallback()` function
handler_callback_query.go:
only allow `CallbackQueryHandler`
handler_inline.go:
only allow `InlineHandler`
handler_message.go:
add to tigger `slash`, `full` and `suffix` command
message_type.go:
add `.Str() string` method for `MessageType` and `MessageTypeList` type
update_type.go:
add `.Str() string` method for `UpdateType` and `UpdateTypeList` type
contain.go:
add to replace `utils.AnyContains()` function
utils.go:
remove `AnyContains()`, `checkNested()`, they are replaced by functions in `contain.go`
remove `getCurrentGoroutineStack()` function
add nil check for `ShowUserName()`, `ShowChatName()` function
plugin_sticker.go:
edit message keyboard after success collect sticker set
24 lines
1015 B
Go
24 lines
1015 B
Go
package plugin_utils
|
|
|
|
import "trbot/utils/handler_params"
|
|
|
|
// 为了兼容性考虑,建议请处理好 CallbackDatePrefix 的长度,因为 CallbackQuery 有长度限制,为 64 个字符。
|
|
// 例如贴纸包名的长度最大为 62 个字符,再使用一个符号来隔开内容时,实际上能使用的识别字符长度只有一个字符。
|
|
// 你也可以忽略这个提醒,但在发送消息时使用 ReplyMarkup 参数添加按钮的时候,需要评断并控制一下 CallbackData 的长度是否超过了 64 个字符,否则消息会无法发出。
|
|
type CallbackQuery struct {
|
|
CallbackDataPrefix string
|
|
|
|
CallbackQueryHandler func(*handler_params.CallbackQuery) error
|
|
}
|
|
|
|
func AddCallbackQueryHandlers(handlers ...CallbackQuery) int {
|
|
if AllPlugins.CallbackQuery == nil { AllPlugins.CallbackQuery = []CallbackQuery{} }
|
|
|
|
var handlerCount int
|
|
for _, handler := range handlers {
|
|
AllPlugins.CallbackQuery = append(AllPlugins.CallbackQuery, handler)
|
|
handlerCount++
|
|
}
|
|
return handlerCount
|
|
}
|