-
-
Notifications
You must be signed in to change notification settings - Fork 16
Aide
Jey edited this page Mar 18, 2025
·
3 revisions
Configure Aide in your build.gradle.kts
:
ktGram {
// Enable AIDE compiler extensions
aideEnabled = true
// Automatic .send() chaining (requires aideEnabled=true)
aideAutoSend = true
}
Property | Description | Default | Required |
---|---|---|---|
aideEnabled |
Enables AIDE compiler features | true |
Yes for Aide to work |
aideAutoSend |
Auto-appends .send() to action returns |
true |
No |
@CommandHandler
suspend fun handler(user: User, bot: TelegramBot) {
// With aideAutoSend=true
message {
"Auto-sent message"
} // ← Compiler adds .send(user, bot)
// Explicit control
message {
"Manual send"
}.send(user, bot) // ← No auto-add when present
}
Caution
Be aware that even if you do not use an explicit send
, you still need to have suspend
function keyword, otherwise you will get an error.
@InputHandler
fun handleInput(user: User, bot: TelegramBot) {
// Requires manual .send() - will trigger warning
val savedAction = message {
"Stored action"
}
// Valid usage with explicit send
savedAction.send(user, bot)
}
-
Auto-Send Applies When:
- Action is directly returned from handler
- No intermediate variable assignment
- No existing
.send()
call
-
Warnings Generated For:
graph LR
A[Action Assignment] --> B[Missing Send]
C[Nested Actions] --> B
D[Lambda Returns] --> B
graph TD
A[Detect Action] --> B{Simple Call?}
B -->|Yes| C{Has Send?}
B -->|No| D[No send]
C -->|No| E[Add Send]
C -->|Yes| F[Keep]
D --> G[Show Warning]
- Handler must declare parameters:
-
User
for general actions (simple action require justTelegramBot
) -
TelegramBot
for all actions
-
- Annotated with
@CommandHandler
,@InputHandler
, etc (any supported annotation).
Telegram bot Wiki © KtGram