Skip to content

Commit

Permalink
Documentation improvements and fix Azure (#157)
Browse files Browse the repository at this point in the history
* Fix config javadoc

* Improve docs, add examples for static content and ordering

* Fix fields requiring a signed 64-bit integer

or double-precision float type in the api docs

* Headers are in lowercase, and response needs to be encoded

* Case-insensitive map and remove jsonassert

* Roll back to v1.0.0-SNAPSHOT
  • Loading branch information
timyates authored Nov 29, 2023
1 parent 96ed50e commit 6ec9e65
Show file tree
Hide file tree
Showing 58 changed files with 800 additions and 128 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 original authors
* Copyright 2017-2023 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,13 +19,14 @@
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.util.StringUtils;

import jakarta.validation.constraints.NotBlank;

import java.util.Arrays;
import java.util.List;

/**
* {@link ConfigurationProperties} implementation of {@link ChatbotsConfiguration}.
*
* @author Sergio del Amo
* @since 1.0.0
*/
Expand All @@ -51,25 +52,11 @@ public class ChatbotsConfigurationProperties implements ChatbotsConfiguration {
@Nullable
private List<FileExtension> possibleStaticCommandExtensions = Arrays.asList(FileExtension.values());

/**
* enabled getter.
*
* @return boolean flag indicating whether the chatbots features are enabled.
*/
@Override
public boolean isEnabled() {
return this.enabled;
}

/**
* @return The Bot Commands' folder where views should be searched for. By default {@value #DEFAULT_FOLDER}
*/
@Override
@NonNull
public String getFolder() {
return folder;
}

/**
* Whether chatbots is enabled. Default value ({@value #DEFAULT_ENABLED}).
*
Expand All @@ -79,6 +66,12 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

@Override
@NonNull
public String getFolder() {
return folder;
}

/**
* The folder to look for bot commands.
*
Expand All @@ -97,7 +90,8 @@ public List<FileExtension> getPossibleStaticCommandExtensions() {
}

/**
* Possible static command file extensions. Default values MARKDOWN HTML TXT
* Possible static command file extensions. Default values MARKDOWN, HTML, TXT
*
* @param possibleStaticCommandExtensions Possible static command file extensions.
*/
public void setPossibleStaticCommandExtensions(@Nullable List<FileExtension> possibleStaticCommandExtensions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class Animation extends AbstractFileWithDimensions {
*/
@Nullable
@JsonProperty("file_size")
private Integer fileSize;
private Long fileSize;

/**
*
Expand Down Expand Up @@ -139,15 +139,15 @@ public void setMimeType(@Nullable String mimeType) {
* @return File size.
*/
@Nullable
public Integer getFileSize() {
public Long getFileSize() {
return fileSize;
}

/**
*
* @param fileSize File size.
*/
public void setFileSize(@Nullable Integer fileSize) {
public void setFileSize(@Nullable Long fileSize) {
this.fileSize = fileSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class Audio extends AbstractFile {

@Nullable
@JsonProperty("file_size")
private Integer fileSize;
private Long fileSize;

/**
* Thumbnail of the album cover to which the music file belongs.
Expand Down Expand Up @@ -145,15 +145,15 @@ public void setMimeType(@Nullable String mimeType) {
* @return File size
*/
@Nullable
public Integer getFileSize() {
public Long getFileSize() {
return fileSize;
}

/**
*
* @param fileSize File size
*/
public void setFileSize(@Nullable Integer fileSize) {
public void setFileSize(@Nullable Long fileSize) {
this.fileSize = fileSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Chat {
*/
@NonNull
@NotNull
private Integer id;
private Long id;

/**
* Type of chat, can be either “private”, “group”, “supergroup” or “channel”.
Expand Down Expand Up @@ -192,15 +192,15 @@ public class Chat {
* @return Unique identifier for this chat.
*/
@NonNull
public Integer getId() {
public Long getId() {
return id;
}

/**
*
* @param id Unique identifier for this chat.
*/
public void setId(@NonNull Integer id) {
public void setId(@NonNull Long id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Contact {
*/
@Nullable
@JsonProperty("user_id")
private Integer userId;
private Long userId;

/**
* Additional data about the contact in the form of a vCard.
Expand Down Expand Up @@ -123,15 +123,15 @@ public void setLastName(@Nullable String lastName) {
* @return Contact's user identifier in Telegram
*/
@Nullable
public Integer getUserId() {
public Long getUserId() {
return userId;
}

/**
*
* @param userId Contact's user identifier in Telegram
*/
public void setUserId(@Nullable Integer userId) {
public void setUserId(@Nullable Long userId) {
this.userId = userId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class Document extends AbstractFile {
*/
@JsonProperty("file_size")
@Nullable
private Integer fileSize;
private Long fileSize;

/**
*
Expand Down Expand Up @@ -110,15 +110,15 @@ public void setMimeType(@Nullable String mimeType) {
* @return File size.
*/
@Nullable
public Integer getFileSize() {
public Long getFileSize() {
return fileSize;
}

/**
*
* @param fileSize File size.
*/
public void setFileSize(@Nullable Integer fileSize) {
public void setFileSize(@Nullable Long fileSize) {
this.fileSize = fileSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class File extends AbstractFile {
*/
@JsonProperty("file_size")
@Nullable
private Integer fileSize;
private Long fileSize;

/**
* File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
Expand All @@ -44,15 +44,15 @@ public class File extends AbstractFile {
* @return File size, if known.
*/
@Nullable
public Integer getFileSize() {
public Long getFileSize() {
return fileSize;
}

/**
*
* @param fileSize File size, if known.
*/
public void setFileSize(@Nullable Integer fileSize) {
public void setFileSize(@Nullable Long fileSize) {
this.fileSize = fileSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,14 @@ public class Message {
*/
@JsonProperty("migrate_to_chat_id")
@Nullable
private Integer migrateToChatId;
private Long migrateToChatId;

/**
* The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
*/
@Nullable
@JsonProperty("migrate_from_chat_id")
private Integer migrateFromChatId;
private Long migrateFromChatId;

/**
* Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
Expand Down Expand Up @@ -1096,15 +1096,15 @@ public void setChannelChatCreated(@Nullable Boolean channelChatCreated) {
* @return The group has been migrated to a supergroup with the specified identifier.
*/
@Nullable
public Integer getMigrateToChatId() {
public Long getMigrateToChatId() {
return migrateToChatId;
}

/**
*
* @param migrateToChatId The group has been migrated to a supergroup with the specified identifier.
*/
public void setMigrateToChatId(@Nullable Integer migrateToChatId) {
public void setMigrateToChatId(@Nullable Long migrateToChatId) {
this.migrateToChatId = migrateToChatId;
}

Expand All @@ -1113,15 +1113,15 @@ public void setMigrateToChatId(@Nullable Integer migrateToChatId) {
* @return The supergroup has been migrated from a group with the specified identifier.
*/
@Nullable
public Integer getMigrateFromChatId() {
public Long getMigrateFromChatId() {
return migrateFromChatId;
}

/**
*
* @param migrateFromChatId The supergroup has been migrated from a group with the specified identifier.
*/
public void setMigrateFromChatId(@Nullable Integer migrateFromChatId) {
public void setMigrateFromChatId(@Nullable Long migrateFromChatId) {
this.migrateFromChatId = migrateFromChatId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ResponseParameters {
*/
@Nullable
@JsonProperty("migrate_to_chat_id")
private Integer migrateToChatId;
private Long migrateToChatId;

/**
* In case of exceeding flood control, the number of seconds left to wait before the request can be repeated.
Expand All @@ -44,15 +44,15 @@ public class ResponseParameters {
* @return The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
*/
@Nullable
public Integer getMigrateToChatId() {
public Long getMigrateToChatId() {
return migrateToChatId;
}

/**
*
* @param migrateToChatId The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
*/
public void setMigrateToChatId(@Nullable Integer migrateToChatId) {
public void setMigrateToChatId(@Nullable Long migrateToChatId) {
this.migrateToChatId = migrateToChatId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class User {
*/
@NonNull
@NotNull
private Integer id;
private Long id;

/**
* True, if this user is a bot.
Expand Down Expand Up @@ -116,15 +116,15 @@ public class User {
* @return Unique identifier for this user or bot.
*/
@NonNull
public Integer getId() {
public Long getId() {
return id;
}

/**
*
* @param id Unique identifier for this user or bot.
*/
public void setId(@NonNull Integer id) {
public void setId(@NonNull Long id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Voice extends AbstractFile {
*/
@Nullable
@JsonProperty("file_size")
private Integer fileSize;
private Long fileSize;

/**
*
Expand Down Expand Up @@ -87,15 +87,15 @@ public void setMimeType(@Nullable String mimeType) {
* @return File size.
*/
@Nullable
public Integer getFileSize() {
public Long getFileSize() {
return fileSize;
}

/**
*
* @param fileSize File size.
*/
public void setFileSize(@Nullable Integer fileSize) {
public void setFileSize(@Nullable Long fileSize) {
this.fileSize = fileSize;
}

Expand Down
1 change: 1 addition & 0 deletions chatbots-telegram-azure-function/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ plugins {
dependencies {
implementation(mnSerde.micronaut.serde.jackson)
api(projects.micronautChatbotsTelegramCore)
testImplementation(libs.groovy.json)
testRuntimeOnly(mn.snakeyaml)
}
Loading

0 comments on commit 6ec9e65

Please sign in to comment.