-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* JRTB-4: added ability to send notifications about new articles
* JRTB-8: added ability to set inactive telegram user * JRTB-9: added ability to set active user and/or start using it.
- Loading branch information
Showing
30 changed files
with
447 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...java/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/JavaRushPostClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient; | ||
|
||
import com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto.PostInfo; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Client for Javarush Open API corresponds to Posts. | ||
*/ | ||
public interface JavaRushPostClient { | ||
|
||
/** | ||
* Find new posts since lastPostId in provided group. | ||
* | ||
* @param groupId provided group ID. | ||
* @param lastPostId provided last post ID. | ||
* @return the collection of the new {@link PostInfo}. | ||
*/ | ||
List<PostInfo> findNewPosts(Integer groupId, Integer lastPostId); | ||
} |
37 changes: 37 additions & 0 deletions
37
.../com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/JavaRushPostClientImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient; | ||
import kong.unirest.GenericType; | ||
import com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto.PostInfo; | ||
import kong.unirest.Unirest; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
public class JavaRushPostClientImpl implements JavaRushPostClient { | ||
|
||
private final String javarushApiPostPath; | ||
|
||
public JavaRushPostClientImpl(@Value("${javarush.api.path}") String javarushApi) { | ||
this.javarushApiPostPath = javarushApi + "/posts"; | ||
} | ||
|
||
@Override | ||
public List<PostInfo> findNewPosts(Integer groupId, Integer lastPostId) { | ||
List<PostInfo> lastPostsByGroup = Unirest.get(javarushApiPostPath) | ||
.queryString("order", "NEW") | ||
.queryString("groupKid", groupId) | ||
.queryString("limit", 15) | ||
.asObject(new GenericType<List<PostInfo>>() { | ||
}).getBody(); | ||
List<PostInfo> newPosts = new ArrayList<>(); | ||
for (PostInfo post : lastPostsByGroup) { | ||
if (lastPostId.equals(post.getId())) { | ||
return newPosts; | ||
} | ||
newPosts.add(post); | ||
} | ||
return newPosts; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...n/java/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/BaseUserInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
|
||
import lombok.Data; | ||
|
||
/** | ||
* DTO, which represents base user information. | ||
*/ | ||
@Data | ||
public class BaseUserInfo { | ||
private String city; | ||
private String country; | ||
private String displayName; | ||
private Integer id; | ||
private String job; | ||
private String key; | ||
private Integer level; | ||
private String pictureUrl; | ||
private String position; | ||
private UserPublicStatus publicStatus; | ||
private String publicStatusMessage; | ||
private Integer rating; | ||
private Integer userId; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/Language.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
/** | ||
* DTO, which represents languages. | ||
*/ | ||
public enum Language { | ||
UNKNOWN, | ||
ENGLISH, | ||
GERMAN, | ||
SPANISH, | ||
HINDI, | ||
FRENCH, | ||
PORTUGUESE, | ||
POLISH, | ||
BENGALI, | ||
PUNJABI, | ||
CHINESE, | ||
ITALIAN, | ||
INDONESIAN, | ||
MARATHI, | ||
TAMIL, | ||
TELUGU, | ||
JAPANESE, | ||
KOREAN, | ||
URDU, | ||
TAIWANESE, | ||
NETHERLANDS, | ||
RUSSIAN, | ||
UKRAINIAN | ||
} |
34 changes: 34 additions & 0 deletions
34
...ain/java/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/LikeStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
/** | ||
* DTO, which represents like's status. | ||
*/ | ||
public enum LikeStatus { | ||
|
||
UNKNOWN, | ||
LIKE, | ||
HOT, | ||
FOLLOW, | ||
FAVORITE, | ||
SOLUTION, | ||
HELPFUL, | ||
ARTICLE, | ||
OSCAR, | ||
DISLIKE, | ||
WRONG, | ||
SPAM, | ||
ABUSE, | ||
FOUL, | ||
TROLLING, | ||
OFFTOPIC, | ||
DUPLICATE, | ||
DIRTY, | ||
OUTDATED, | ||
BORING, | ||
UNCLEAR, | ||
HARD, | ||
EASY, | ||
FAKE, | ||
SHAM, | ||
AWFUL | ||
} |
10 changes: 10 additions & 0 deletions
10
...main/java/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/LikesInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
/** | ||
* DTO, which represents like's information. | ||
*/ | ||
public class LikesInfo { | ||
|
||
private Integer count; | ||
private LikeStatus status; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/PostInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
|
||
import lombok.Data; | ||
|
||
/** | ||
* DTO, which represents post information. | ||
*/ | ||
@Data | ||
public class PostInfo { | ||
|
||
private BaseUserInfo authorInfo; | ||
private Integer commentsCount; | ||
private String content; | ||
private Long createdTime; | ||
private String description; | ||
private GroupInfo groupInfo; | ||
private Integer id; | ||
private String key; | ||
private Language language; | ||
private LikesInfo likesInfo; | ||
private GroupInfo originalGroupInfo; | ||
private String pictureUrl; | ||
private Double rating; | ||
private Integer ratingCount; | ||
private String title; | ||
private PostType type; | ||
private Long updatedTime; | ||
private UserDiscussionInfo userDiscussionInfo; | ||
private Integer views; | ||
private VisibilityStatus visibilityStatus; | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/PostType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
/** | ||
* DTO, which represents post types. | ||
*/ | ||
public enum PostType { | ||
UNKNOWN, USUAL, INNER_LINK, OUTER_LINK | ||
} |
17 changes: 17 additions & 0 deletions
17
...va/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/UserPublicStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
/** | ||
* DTO, which represents user public status. | ||
*/ | ||
public enum UserPublicStatus { | ||
UNKNOWN, | ||
BEGINNER, | ||
ACTIVE, | ||
STRONG, | ||
GRADUATED, | ||
INTERNSHIP_IN_PROGRESS, | ||
INTERNSHIP_COMPLETED, | ||
RESUME_COMPLETED, | ||
LOOKING_FOR_JOB, | ||
HAVE_JOB; | ||
} |
14 changes: 14 additions & 0 deletions
14
...va/com/github/JBolivarLi/javarushtelegrambot/bot/javarushclient/dto/VisibilityStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.JBolivarLi.javarushtelegrambot.bot.javarushclient.dto; | ||
|
||
/** | ||
* DTO, which represents visibility status. | ||
*/ | ||
public enum VisibilityStatus { | ||
UNKNOWN, | ||
RESTRICTED, | ||
PUBLIC, | ||
PROTECTED, | ||
PRIVATE, | ||
DISABLED, | ||
DELETED | ||
} |
Oops, something went wrong.