-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add constants for chat actions #179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for your contribution! Can definitely see the value in this, so appreciate the input :)
One issue though; this isn't generating from the spec. Would it be possible to change that? Thanks in advance!
scripts/generate/consts.go
Outdated
chatActions := []string{ | ||
"typing", | ||
"upload_photo", | ||
"record_video", | ||
"upload_video", | ||
"record_voice", | ||
"upload_voice", | ||
"upload_document", | ||
"choose_sticker", | ||
"find_location", | ||
"record_video_note", | ||
"upload_video_note", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible for this list to be obtained from the type spec?
For example, by using some regexes on the sendChatAction method's "action" field description?
If the list is defined manually, then it might as well not be generated; it's just a manually written list, and any changes on telegrams side wouldn't reflect.
I know it's done this way for formatting consts, but that was intended as an exception; parsemodes aren't expected to change, and are relatively short list!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PaulSonOfLars I agree, let's try to actually generate it.
I decided not to create universal function in this case because it would require a lot of input.
func generateConstsFromMethodFieldDescription(d APIDescription, methodName string, fieldName string, regexp string) (string, error) {
...
}
Please let me know if current code sucks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff, exactly what I was thinking of!
What
Add constants for chat actions to avoid typos.
https://core.telegram.org/bots/api#sendchataction
Impact