├── chesslisesky
├── chesslisesky
│ ├── .npmignore
│ ├── .eslintignore
│ ├── preview
│ │ └── demo.png
│ ├── .prettierrc.js
│ ├── jest.config.ts
│ ├── tsconfig.json
│ ├── .eslintrc.js
│ ├── package.json
│ ├── app.ts
│ ├── tests
│ │ └── unit
│ │ │ └── test-handler.test.ts
│ └── chesslisesky.ts
├── samconfig.toml
├── template.yaml
├── events
│ └── event.json
└── .gitignore
├── chessliseskycc
├── chesslisesky
│ ├── .npmignore
│ ├── .eslintignore
│ ├── .prettierrc.js
│ ├── jest.config.ts
│ ├── tsconfig.json
│ ├── .eslintrc.js
│ ├── package.json
│ ├── app.ts
│ ├── tests
│ │ └── unit
│ │ │ └── test-handler.test.ts
│ └── chesslisesky.ts
├── samconfig.toml
├── template.yaml
├── events
│ └── event.json
└── .gitignore
├── chesslise
├── META-INF
│ └── MANIFEST.MF
├── .gitignore
├── src
│ ├── main
│ │ └── java
│ │ │ ├── Images
│ │ │ ├── chesslise2.png
│ │ │ ├── chesslised1.png
│ │ │ └── Black Simple Geometric Discord Profile Banner.png
│ │ │ ├── abstraction
│ │ │ ├── HandleContext.java
│ │ │ ├── CommandTrigger.java
│ │ │ ├── Puzzle.java
│ │ │ ├── PuzzleView.java
│ │ │ ├── Player
│ │ │ │ ├── UserTrophy.java
│ │ │ │ └── UserObject.java
│ │ │ └── ChessUtil.java
│ │ │ ├── Game
│ │ │ ├── NoGameException.java
│ │ │ ├── GameSchema.java
│ │ │ └── GameHandler.java
│ │ │ ├── network
│ │ │ ├── challenge
│ │ │ │ ├── PairingNetworkType.java
│ │ │ │ ├── Status.java
│ │ │ │ ├── Action.java
│ │ │ │ ├── Finder.java
│ │ │ │ ├── Cancel.java
│ │ │ │ ├── Complete.java
│ │ │ │ ├── Create.java
│ │ │ │ └── View.java
│ │ │ └── user
│ │ │ │ ├── friends
│ │ │ │ ├── Request.java
│ │ │ │ ├── FriendPrefBuilder.java
│ │ │ │ ├── ViewTypeFriend.java
│ │ │ │ ├── CancelFriendRequest.java
│ │ │ │ ├── BlockFriendRequest.java
│ │ │ │ ├── RemoveFriendRequest.java
│ │ │ │ ├── SendFriendRequest.java
│ │ │ │ ├── AcceptFriendRequest.java
│ │ │ │ └── ViewFriendRequest.java
│ │ │ │ ├── PreferencePl.java
│ │ │ │ ├── PreferenceTc.java
│ │ │ │ ├── Disconnect.java
│ │ │ │ ├── PreferenceUpdate.java
│ │ │ │ ├── Connect.java
│ │ │ │ ├── PreferenceBuilder.java
│ │ │ │ └── PreferenceFr.java
│ │ │ ├── setting
│ │ │ ├── SettingSchemaModule.java
│ │ │ ├── SettingHandler.java
│ │ │ └── SettingSchema.java
│ │ │ ├── lichess
│ │ │ ├── LichessDBPuzzle.java
│ │ │ ├── UserGame.java
│ │ │ ├── FenPuzzle.java
│ │ │ ├── ThemePuzzle.java
│ │ │ ├── DailyCommand.java
│ │ │ ├── PuzzleTags.java
│ │ │ ├── UserProfile.java
│ │ │ └── Game.java
│ │ │ ├── discord
│ │ │ ├── handlermodules
│ │ │ │ ├── ButtonContextModule.java
│ │ │ │ ├── ModalContextModule.java
│ │ │ │ ├── SelectContextModule.java
│ │ │ │ ├── EntityContextModule.java
│ │ │ │ └── SlashContextModule.java
│ │ │ ├── mainhandler
│ │ │ │ ├── Thumbnail.java
│ │ │ │ ├── AntiSpam.java
│ │ │ │ ├── CommandHandler.java
│ │ │ │ └── CommandInfo.java
│ │ │ └── helpermodules
│ │ │ │ ├── EntityHelperModule.java
│ │ │ │ ├── SelectHelperModule.java
│ │ │ │ ├── PuzzleContextHelperModule.java
│ │ │ │ ├── ModalHelperModule.java
│ │ │ │ ├── NetworkHelperModule.java
│ │ │ │ └── EngineHelperModule.java
│ │ │ ├── database
│ │ │ ├── Search.java
│ │ │ └── MongoConnect.java
│ │ │ ├── chesscom
│ │ │ ├── DailyCommandCC.java
│ │ │ ├── puzzle.java
│ │ │ └── CCProfile.java
│ │ │ ├── engine
│ │ │ └── StockFish.java
│ │ │ ├── runner
│ │ │ └── Main.java
│ │ │ ├── chessdb
│ │ │ └── ChessDBQuery.java
│ │ │ └── coordinategame
│ │ │ └── Coordinategame.java
│ └── test
│ │ └── java
│ │ ├── network
│ │ └── user
│ │ │ └── LichessPuzzleSearchTest.java
│ │ └── lichess
│ │ └── PgnScrollTest.java
├── copy.env
├── .gitpod.yml
└── pom.xml
├── chesslisev3.drawio.png
├── .github
├── dependabot.yml
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── workflows
│ └── maven.yml
├── README.md
├── LICENSE
└── CONTRIBUTING.md
/chesslisesky/chesslisesky/.npmignore:
--------------------------------------------------------------------------------
1 | tests/*
2 |
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/.npmignore:
--------------------------------------------------------------------------------
1 | tests/*
2 |
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .aws-sam
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .aws-sam
--------------------------------------------------------------------------------
/chesslise/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: runner.Main
3 |
4 |
--------------------------------------------------------------------------------
/chesslisev3.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jalpp/Chesslise/HEAD/chesslisev3.drawio.png
--------------------------------------------------------------------------------
/chesslise/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 |
3 | *.class
4 |
5 | *.jar
6 |
7 | .env
8 |
9 | target/
10 | build/
11 | bin/
12 | out/
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/preview/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jalpp/Chesslise/HEAD/chesslisesky/chesslisesky/preview/demo.png
--------------------------------------------------------------------------------
/chesslise/src/main/java/Images/chesslise2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jalpp/Chesslise/HEAD/chesslise/src/main/java/Images/chesslise2.png
--------------------------------------------------------------------------------
/chesslise/src/main/java/Images/chesslised1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jalpp/Chesslise/HEAD/chesslise/src/main/java/Images/chesslised1.png
--------------------------------------------------------------------------------
/chesslise/src/main/java/abstraction/HandleContext.java:
--------------------------------------------------------------------------------
1 | package abstraction;
2 |
3 | public interface HandleContext {
4 |
5 | void handleLogic();
6 | }
7 |
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | semi: true,
3 | trailingComma: "all",
4 | singleQuote: true,
5 | printWidth: 120,
6 | tabWidth: 4
7 | };
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | semi: true,
3 | trailingComma: "all",
4 | singleQuote: true,
5 | printWidth: 120,
6 | tabWidth: 4
7 | };
--------------------------------------------------------------------------------
/chesslise/src/main/java/abstraction/CommandTrigger.java:
--------------------------------------------------------------------------------
1 | package abstraction;
2 |
3 | public interface CommandTrigger {
4 |
5 |
6 | void trigger(String commandName);
7 |
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/Images/Black Simple Geometric Discord Profile Banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jalpp/Chesslise/HEAD/chesslise/src/main/java/Images/Black Simple Geometric Discord Profile Banner.png
--------------------------------------------------------------------------------
/chesslise/src/main/java/Game/NoGameException.java:
--------------------------------------------------------------------------------
1 | package Game;
2 |
3 | public class NoGameException extends Exception {
4 |
5 | public NoGameException(String message) {
6 | super(message);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/challenge/PairingNetworkType.java:
--------------------------------------------------------------------------------
1 | package network.challenge;
2 |
3 | public enum PairingNetworkType {
4 |
5 | PAIR_NETWORK_CHALLENGE,
6 |
7 | PAIR_NETWORK_FRIEND,
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/chesslise/copy.env:
--------------------------------------------------------------------------------
1 | DISCORD_BETA_TOKEN=your_beta_token_here
2 | CONNECTION_STRING=your_mongodb_connection_string
3 | DB_NAME=your_database_name
4 | DB_PLAYER_COL=your_player_collection
5 | DB_CHALL_COL=your_challenge_collection
6 | DB_GAMES_COL=your_games_collection
7 | DB_SETTING_COL=your_settings_collection
8 | ENV_BETA=true
--------------------------------------------------------------------------------
/chesslise/src/main/java/setting/SettingSchemaModule.java:
--------------------------------------------------------------------------------
1 | package setting;
2 |
3 | public class SettingSchemaModule {
4 |
5 | private static SettingSchema schema;
6 |
7 | public SettingSchemaModule(String discorduserid) {
8 | schema = SettingHandler.getUserSetting(discorduserid);
9 | }
10 |
11 | public static SettingSchema getSettingSchema() {
12 | return schema;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chesslise/.gitpod.yml:
--------------------------------------------------------------------------------
1 | # This configuration file was automatically generated by Gitpod.
2 | # Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
3 | # and commit this file to your remote git repository to share the goodness with others.
4 |
5 | # Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
6 |
7 | tasks:
8 | - init: mvn install -DskipTests=true
9 |
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/jest.config.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * For a detailed explanation regarding each configuration property and type check, visit:
3 | * https://jestjs.io/docs/configuration
4 | */
5 |
6 | export default {
7 | transform: {
8 | '^.+\\.ts?$': 'ts-jest',
9 | },
10 | clearMocks: true,
11 | collectCoverage: true,
12 | coverageDirectory: 'coverage',
13 | coverageProvider: 'v8',
14 | testMatch: ['**/tests/unit/*.test.ts'],
15 | };
16 |
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2020",
4 | "strict": true,
5 | "preserveConstEnums": true,
6 | "noEmit": true,
7 | "sourceMap": false,
8 | "module":"es2015",
9 | "moduleResolution":"node",
10 | "esModuleInterop": true,
11 | "skipLibCheck": true,
12 | "forceConsistentCasingInFileNames": true,
13 | },
14 | "exclude": ["node_modules", "**/*.test.ts"]
15 | }
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/jest.config.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * For a detailed explanation regarding each configuration property and type check, visit:
3 | * https://jestjs.io/docs/configuration
4 | */
5 |
6 | export default {
7 | transform: {
8 | '^.+\\.ts?$': 'ts-jest',
9 | },
10 | clearMocks: true,
11 | collectCoverage: true,
12 | coverageDirectory: 'coverage',
13 | coverageProvider: 'v8',
14 | testMatch: ['**/tests/unit/*.test.ts'],
15 | };
16 |
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2020",
4 | "strict": true,
5 | "preserveConstEnums": true,
6 | "noEmit": true,
7 | "sourceMap": false,
8 | "module":"es2015",
9 | "moduleResolution":"node",
10 | "esModuleInterop": true,
11 | "skipLibCheck": true,
12 | "forceConsistentCasingInFileNames": true,
13 | },
14 | "exclude": ["node_modules", "**/*.test.ts"]
15 | }
--------------------------------------------------------------------------------
/chesslise/src/main/java/abstraction/Puzzle.java:
--------------------------------------------------------------------------------
1 | package abstraction;
2 |
3 | import net.dv8tion.jda.api.EmbedBuilder;
4 | import setting.SettingSchema;
5 |
6 | import java.awt.*;
7 |
8 | public interface Puzzle {
9 |
10 | String definePuzzleFen();
11 |
12 | EmbedBuilder defineCommandCard(SettingSchema schema);
13 |
14 | String definePuzzleLogo();
15 |
16 | String definePuzzleTitle();
17 |
18 | Color defineEmbedColor();
19 |
20 | String definePuzzleDescription();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "maven" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "weekly"
12 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/abstraction/PuzzleView.java:
--------------------------------------------------------------------------------
1 | package abstraction;
2 |
3 | import setting.SettingSchema;
4 |
5 | public class PuzzleView {
6 |
7 | private final ChessUtil util = new ChessUtil();
8 |
9 | public String renderImage(String fen, SettingSchema schema) {
10 | return util.getImageFromFEN(fen, schema.getBoardTheme(), schema.getPieceType());
11 | }
12 |
13 | public String defineSideToMove(String fen) {
14 | return util.getWhichSideToMove(fen);
15 | }
16 |
17 | public String defineAnalysisBoard(String fen) {
18 | return util.getAnalysisBoard(fen);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **Chesslise**
2 |
3 | 
4 |
5 |
6 |
7 |
8 |
9 |
10 | This repo contains source code for Chesslise App, the website source code is [here](https://github.com/jalpp/chessliseweb), contributions are also welcome, check the contributing doc [here](https://github.com/jalpp/Chesslise/blob/master/CONTRIBUTING.md). To view info on how to use the app and TOS check the website.
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/lichess/LichessDBPuzzle.java:
--------------------------------------------------------------------------------
1 | package lichess;
2 |
3 |
4 | public class LichessDBPuzzle {
5 |
6 | private final String fen;
7 | private final String rating;
8 | private final String gameURL;
9 |
10 |
11 | public LichessDBPuzzle(String fen, String rating, String gameURL) {
12 | this.fen = fen;
13 | this.rating = rating;
14 | this.gameURL = gameURL;
15 | }
16 |
17 |
18 | public String getFen() {
19 | return fen;
20 | }
21 |
22 |
23 | public String getRating() {
24 | return rating;
25 | }
26 |
27 |
28 | public String getGameURL() {
29 | return gameURL;
30 | }
31 | }
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/user/friends/Request.java:
--------------------------------------------------------------------------------
1 | package network.user.friends;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import network.challenge.Finder;
5 | import org.bson.Document;
6 |
7 | public class Request {
8 |
9 | private final MongoCollection networkPlayers;
10 | private final Finder finder;
11 |
12 | public Request(MongoCollection networkPlayers) {
13 | this.networkPlayers = networkPlayers;
14 | this.finder = new Finder(networkPlayers);
15 | }
16 |
17 | public MongoCollection getNetworkPlayers() {
18 | return networkPlayers;
19 | }
20 |
21 | public Finder getFinder() {
22 | return this.finder;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/challenge/Status.java:
--------------------------------------------------------------------------------
1 | package network.challenge;
2 |
3 | public enum Status {
4 |
5 | PENDING,
6 |
7 | ACCEPTED,
8 |
9 | CANCELLED,
10 |
11 | COMPLETED;
12 |
13 | public String toMongo() {
14 | switch (this) {
15 | case PENDING -> {
16 | return "pending";
17 | }
18 |
19 | case ACCEPTED -> {
20 | return "accepted";
21 | }
22 |
23 | case CANCELLED -> {
24 | return "cancelled";
25 | }
26 |
27 | case COMPLETED -> {
28 | return "completed";
29 | }
30 | }
31 |
32 | return null;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/handlermodules/ButtonContextModule.java:
--------------------------------------------------------------------------------
1 | package discord.handlermodules;
2 |
3 | import abstraction.HandleContext;
4 | import discord.helpermodules.ButtonHelperModule;
5 | import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
6 |
7 | public class ButtonContextModule implements HandleContext {
8 |
9 | private final ButtonInteractionEvent buttonEvent;
10 |
11 | public ButtonContextModule(ButtonInteractionEvent buttonEvent) {
12 | this.buttonEvent = buttonEvent;
13 | }
14 |
15 | @Override
16 | public void handleLogic() {
17 | ButtonHelperModule buttonTool = new ButtonHelperModule(buttonEvent);
18 | buttonTool.trigger(buttonEvent.getComponentId());
19 | }
20 |
21 |
22 | }
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/handlermodules/ModalContextModule.java:
--------------------------------------------------------------------------------
1 | package discord.handlermodules;
2 |
3 | import abstraction.HandleContext;
4 | import discord.helpermodules.ModalHelperModule;
5 | import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
6 |
7 |
8 | public class ModalContextModule implements HandleContext {
9 |
10 | private final ModalInteractionEvent eventModal;
11 |
12 | public ModalContextModule(ModalInteractionEvent eventModal) {
13 | this.eventModal = eventModal;
14 | }
15 |
16 | @Override
17 | public void handleLogic() {
18 | String name = eventModal.getModalId();
19 | ModalHelperModule modalTool = new ModalHelperModule(eventModal);
20 | modalTool.trigger(name);
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/handlermodules/SelectContextModule.java:
--------------------------------------------------------------------------------
1 | package discord.handlermodules;
2 |
3 | import abstraction.HandleContext;
4 | import discord.helpermodules.SelectHelperModule;
5 | import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
6 |
7 | public class SelectContextModule implements HandleContext {
8 |
9 | private final StringSelectInteractionEvent stringSelectEvent;
10 |
11 |
12 | public SelectContextModule(StringSelectInteractionEvent stringSelectEvent) {
13 | this.stringSelectEvent = stringSelectEvent;
14 | }
15 |
16 | @Override
17 | public void handleLogic() {
18 | SelectHelperModule selectHelperModule = new SelectHelperModule(stringSelectEvent);
19 | selectHelperModule.trigger(stringSelectEvent.getComponentId());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: "@typescript-eslint/parser",
3 | parserOptions: {
4 | ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
5 | sourceType: "module"
6 | },
7 | extends: [
8 | "plugin:@typescript-eslint/recommended", // recommended rules from the @typescript-eslint/eslint-plugin
9 | "plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
10 | ],
11 | rules: {
12 | // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
13 | // e.g. "@typescript-eslint/explicit-function-return-type": "off",
14 | }
15 | };
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: "@typescript-eslint/parser",
3 | parserOptions: {
4 | ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
5 | sourceType: "module"
6 | },
7 | extends: [
8 | "plugin:@typescript-eslint/recommended", // recommended rules from the @typescript-eslint/eslint-plugin
9 | "plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
10 | ],
11 | rules: {
12 | // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
13 | // e.g. "@typescript-eslint/explicit-function-return-type": "off",
14 | }
15 | };
--------------------------------------------------------------------------------
/chesslisesky/samconfig.toml:
--------------------------------------------------------------------------------
1 | # More information about the configuration file can be found here:
2 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
3 | version = 0.1
4 |
5 | [default.global.parameters]
6 | stack_name = "chesslisesky"
7 |
8 | [default.build.parameters]
9 | cached = true
10 | parallel = true
11 |
12 | [default.validate.parameters]
13 | lint = true
14 |
15 | [default.deploy.parameters]
16 | capabilities = "CAPABILITY_IAM"
17 | confirm_changeset = true
18 | resolve_s3 = true
19 |
20 | [default.package.parameters]
21 | resolve_s3 = true
22 |
23 | [default.sync.parameters]
24 | watch = true
25 |
26 | [default.local_start_api.parameters]
27 | warm_containers = "EAGER"
28 |
29 | [default.local_start_lambda.parameters]
30 | warm_containers = "EAGER"
31 |
--------------------------------------------------------------------------------
/chessliseskycc/samconfig.toml:
--------------------------------------------------------------------------------
1 | # More information about the configuration file can be found here:
2 | # https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
3 | version = 0.1
4 |
5 | [default.global.parameters]
6 | stack_name = "chesslisesky"
7 |
8 | [default.build.parameters]
9 | cached = true
10 | parallel = true
11 |
12 | [default.validate.parameters]
13 | lint = true
14 |
15 | [default.deploy.parameters]
16 | capabilities = "CAPABILITY_IAM"
17 | confirm_changeset = true
18 | resolve_s3 = true
19 |
20 | [default.package.parameters]
21 | resolve_s3 = true
22 |
23 | [default.sync.parameters]
24 | watch = true
25 |
26 | [default.local_start_api.parameters]
27 | warm_containers = "EAGER"
28 |
29 | [default.local_start_lambda.parameters]
30 | warm_containers = "EAGER"
31 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/handlermodules/EntityContextModule.java:
--------------------------------------------------------------------------------
1 | package discord.handlermodules;
2 |
3 | import abstraction.HandleContext;
4 | import discord.helpermodules.EntityHelperModule;
5 | import net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent;
6 |
7 | public class EntityContextModule implements HandleContext {
8 |
9 | private final EntitySelectInteractionEvent entitySelectInteractionEvent;
10 |
11 | public EntityContextModule(EntitySelectInteractionEvent entitySelectInteractionEvent) {
12 | this.entitySelectInteractionEvent = entitySelectInteractionEvent;
13 | }
14 |
15 |
16 | @Override
17 | public void handleLogic() {
18 | EntityHelperModule entityHelperModule = new EntityHelperModule(entitySelectInteractionEvent);
19 | entityHelperModule.trigger(entitySelectInteractionEvent.getComponentId());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/database/Search.java:
--------------------------------------------------------------------------------
1 | package database;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import org.bson.Document;
5 |
6 | public class Search {
7 |
8 | public String search(String targetSearch, String targetID, MongoCollection collection, String returnId) {
9 | Document query = new Document(targetSearch, targetID);
10 |
11 | Document result = collection.find(query).first();
12 |
13 | if (result != null) {
14 |
15 | return result.getString(returnId);
16 |
17 | } else {
18 | return null;
19 | }
20 | }
21 |
22 | public boolean exists(String targetSearch, String targetID, MongoCollection collection) {
23 | Document query = new Document(targetSearch, targetID);
24 |
25 | Document result = collection.find(query).first();
26 |
27 | return result != null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/challenge/Action.java:
--------------------------------------------------------------------------------
1 | package network.challenge;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import org.bson.Document;
5 |
6 | public class Action {
7 |
8 | private final MongoCollection networkChallenges;
9 | private final MongoCollection networkPlayers;
10 | private final Finder finder;
11 |
12 | public Action(MongoCollection networkChallenges, MongoCollection networkPlayers) {
13 | this.networkChallenges = networkChallenges;
14 | this.networkPlayers = networkPlayers;
15 | this.finder = new Finder(networkPlayers);
16 | }
17 |
18 | public MongoCollection getNetworkChallenges() {
19 | return networkChallenges;
20 | }
21 |
22 | public MongoCollection getNetworkPlayers() {
23 | return networkPlayers;
24 | }
25 |
26 | public Finder getFinder() {
27 | return finder;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/Game/GameSchema.java:
--------------------------------------------------------------------------------
1 | package Game;
2 |
3 | public class GameSchema {
4 |
5 | private String userid;
6 | private String fen;
7 | private Integer depth;
8 |
9 | public GameSchema(String userid, String fen, Integer depth) {
10 | this.userid = userid;
11 | this.fen = fen;
12 | this.depth = depth;
13 | }
14 |
15 | public String getUserid() {
16 | return userid;
17 | }
18 |
19 | public String getFen() {
20 | return fen;
21 | }
22 |
23 | @Override
24 | public String toString() {
25 | return "GameSchema{" +
26 | "userid='" + userid + '\'' +
27 | ", fen='" + fen + '\'' +
28 | ", depth=" + depth +
29 | '}';
30 | }
31 |
32 | public void setFen(String fen) {
33 | this.fen = fen;
34 | }
35 |
36 | public Integer getDepth() {
37 | return depth;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/user/friends/FriendPrefBuilder.java:
--------------------------------------------------------------------------------
1 | package network.user.friends;
2 |
3 | import network.user.PreferenceFr;
4 |
5 | public class FriendPrefBuilder {
6 |
7 | private final PreferenceFr player;
8 | private final PreferenceFr piece;
9 | private final PreferenceFr opening;
10 | private final PreferenceFr style;
11 |
12 | public FriendPrefBuilder(PreferenceFr player, PreferenceFr piece, PreferenceFr opening, PreferenceFr style) {
13 | this.player = player;
14 | this.piece = piece;
15 | this.opening = opening;
16 | this.style = style;
17 | }
18 |
19 | public PreferenceFr getPlayer() {
20 | return player;
21 | }
22 |
23 | public PreferenceFr getPiece() {
24 | return piece;
25 | }
26 |
27 | public PreferenceFr getOpening() {
28 | return opening;
29 | }
30 |
31 | public PreferenceFr getStyle() {
32 | return style;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/abstraction/Player/UserTrophy.java:
--------------------------------------------------------------------------------
1 | package abstraction.Player;
2 |
3 | import chariot.model.Trophy;
4 |
5 | import java.util.HashMap;
6 |
7 | public class UserTrophy {
8 |
9 | private final String trophyName;
10 |
11 | public UserTrophy(Trophy trophy) {
12 | this.trophyName = trophy.name();
13 | }
14 |
15 | public String getTrophyName() {
16 | HashMap getLink = new HashMap<>();
17 | getLink.put("Marathon Winner", "\uD83D\uDD2E");
18 | getLink.put("Marathon Top 10", "\uD83C\uDF15");
19 | getLink.put("Other", "\uD83C\uDFC6");
20 | getLink.put("Verified account", "✅");
21 | getLink.put("Lichess moderator", "\uD83D\uDC41️");
22 | getLink.put("Lichess content team", "✍️");
23 | getLink.put("Lichess developer", "\uD83D\uDEE0️");
24 |
25 | String imageLink = getLink.getOrDefault(this.trophyName, getLink.get("Other"));
26 | return imageLink + " " + this.trophyName;
27 | }
28 | }
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/challenge/Finder.java:
--------------------------------------------------------------------------------
1 | package network.challenge;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import database.Search;
5 | import org.bson.Document;
6 |
7 | public class Finder {
8 |
9 | private final MongoCollection networkPlayers;;
10 | private final Search search = new Search();
11 |
12 | public Finder(MongoCollection networkPlayers) {
13 | this.networkPlayers = networkPlayers;
14 | }
15 |
16 | public String findPreferencePl(String discordid) {
17 | return search.search("id", discordid, this.networkPlayers, "pl");
18 | }
19 |
20 | public String findPreferenceTc(String discordid) {
21 | return search.search("id", discordid, this.networkPlayers, "ptc");
22 | }
23 |
24 | public boolean findConnected(String discordid) {
25 | return !search.exists("id", discordid, this.networkPlayers);
26 | }
27 |
28 | public Document findPlayer(String discordid) {
29 | return this.networkPlayers.find(new Document("id", discordid)).first();
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/user/PreferencePl.java:
--------------------------------------------------------------------------------
1 | package network.user;
2 |
3 | import net.dv8tion.jda.api.interactions.commands.OptionType;
4 | import net.dv8tion.jda.api.interactions.commands.build.OptionData;
5 |
6 | public enum PreferencePl {
7 |
8 | LICHESS,
9 |
10 | UNAUTH_LICHESS,
11 |
12 | ALL;
13 |
14 | public String toMongo() {
15 | switch (this) {
16 | case LICHESS -> {
17 | return "lichess";
18 | }
19 |
20 | case UNAUTH_LICHESS -> {
21 | return "unauthlichess";
22 | }
23 |
24 | case ALL -> {
25 | return "allplatform";
26 | }
27 | }
28 |
29 | return null;
30 | }
31 |
32 | public static OptionData getOptionData() {
33 | return new OptionData(OptionType.STRING, "platform", "choose platform", true)
34 | .addChoice("Lichess.org Authenticated", "lichess").addChoice("Lichess.org Anon", "unauthlichess")
35 | .addChoice("All Platforms", "allplatform");
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 jalpp
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/user/friends/ViewTypeFriend.java:
--------------------------------------------------------------------------------
1 | package network.user.friends;
2 |
3 | public enum ViewTypeFriend {
4 |
5 | INCOMMING_FRIEND,
6 |
7 | OUTGOING_FRIEND,
8 |
9 | LIST_FRIEND;
10 |
11 | public String toDiscord() {
12 | switch (this) {
13 | case LIST_FRIEND -> {
14 | return "flist";
15 | }
16 | case INCOMMING_FRIEND -> {
17 | return "fin";
18 | }
19 |
20 | case OUTGOING_FRIEND -> {
21 | return "fout";
22 | }
23 | }
24 | return null;
25 | }
26 |
27 | public static ViewTypeFriend getType(String discord) {
28 | switch (discord) {
29 | case "flist" -> {
30 | return ViewTypeFriend.LIST_FRIEND;
31 | }
32 | case "fin" -> {
33 | return ViewTypeFriend.INCOMMING_FRIEND;
34 | }
35 | case "fout" -> {
36 | return ViewTypeFriend.OUTGOING_FRIEND;
37 | }
38 | }
39 | return null;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/mainhandler/Thumbnail.java:
--------------------------------------------------------------------------------
1 | package discord.mainhandler;
2 |
3 | public class Thumbnail {
4 |
5 | private static String ChessliseLogo = "https://raw.githubusercontent.com/jalpp/DojoIcons/dd7365ea7d768fe17056d9b14ee6740c2bf4e261/oldIcons/Black%20Blue%20White%20Tactical%20eSports%20Discord%20Logo.png";
6 |
7 | private static String StockfishLogo = "https://stockfishchess.org/images/logo/icon_512x512@2x.png";
8 |
9 | private static String LichessLogo = "https://upload.wikimedia.org/wikipedia/commons/4/47/Lichess_logo_2019.png";
10 |
11 | private static String ChesscomLogo = "https://static.wikia.nocookie.net/logopedia/images/4/4a/Chess.com_2019_%28App_Icon%29.png/revision/latest/scale-to-width-down/250?cb=20221006103032";
12 |
13 | public static String getChessliseLogo() {
14 | return ChessliseLogo;
15 | }
16 |
17 | public static String getStockfishLogo() {
18 | return StockfishLogo;
19 | }
20 |
21 | public static String getLichessLogo() {
22 | return LichessLogo;
23 | }
24 |
25 | public static String getChesscomLogo() {
26 | return ChesscomLogo;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/user/PreferenceTc.java:
--------------------------------------------------------------------------------
1 | package network.user;
2 |
3 | import net.dv8tion.jda.api.interactions.commands.OptionType;
4 | import net.dv8tion.jda.api.interactions.commands.build.OptionData;
5 |
6 | public enum PreferenceTc {
7 |
8 | CLASSICAL,
9 |
10 | RAPID,
11 |
12 | BLITZ,
13 |
14 | BULLET; // adding this for bullet addicts
15 |
16 | public String toMongo() {
17 | switch (this) {
18 | case CLASSICAL -> {
19 | return "classical";
20 | }
21 |
22 | case RAPID -> {
23 | return "rapid";
24 | }
25 |
26 | case BLITZ -> {
27 | return "blitz";
28 | }
29 |
30 | case BULLET -> {
31 | return "bullet";
32 | }
33 |
34 | }
35 | return null;
36 | }
37 |
38 | public static OptionData getOptionData() {
39 | return new OptionData(OptionType.STRING, "tc", "choose timecontrol", true).addChoice("classical", "classical")
40 | .addChoice("rapid", "rapid")
41 | .addChoice("blitz", "blitz").addChoice("bullet", "bullet");
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hello_world",
3 | "version": "1.0.0",
4 | "description": "hello world sample for NodeJS",
5 | "main": "app.js",
6 | "repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs",
7 | "author": "SAM CLI",
8 | "license": "MIT",
9 | "scripts": {
10 | "unit": "jest",
11 | "lint": "eslint '*.ts' --quiet --fix",
12 | "compile": "tsc",
13 | "test": "npm run compile && npm run unit"
14 | },
15 | "dependencies": {
16 | "@atproto/api": "^0.13.18",
17 | "axios": "^1.12.0",
18 | "esbuild": "^0.25.0"
19 | },
20 | "devDependencies": {
21 | "@jest/globals": "^29.2.0",
22 | "@types/aws-lambda": "^8.10.92",
23 | "@types/jest": "^29.2.0",
24 | "@types/node": "^20.5.7",
25 | "@typescript-eslint/eslint-plugin": "^5.10.2",
26 | "@typescript-eslint/parser": "^5.10.2",
27 | "eslint": "^8.8.0",
28 | "eslint-config-prettier": "^8.3.0",
29 | "eslint-plugin-prettier": "^4.0.0",
30 | "jest": "^29.2.1",
31 | "prettier": "^2.5.1",
32 | "ts-jest": "^29.0.5",
33 | "ts-node": "^10.9.1",
34 | "typescript": "^4.8.4"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hello_world",
3 | "version": "1.0.0",
4 | "description": "hello world sample for NodeJS",
5 | "main": "app.js",
6 | "repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs",
7 | "author": "SAM CLI",
8 | "license": "MIT",
9 | "scripts": {
10 | "unit": "jest",
11 | "lint": "eslint '*.ts' --quiet --fix",
12 | "compile": "tsc",
13 | "test": "npm run compile && npm run unit"
14 | },
15 | "dependencies": {
16 | "@atproto/api": "^0.13.18",
17 | "axios": "^1.12.0",
18 | "chess.js": "^1.0.0-beta.8",
19 | "esbuild": "^0.25.0"
20 | },
21 | "devDependencies": {
22 | "@jest/globals": "^29.2.0",
23 | "@types/aws-lambda": "^8.10.92",
24 | "@types/jest": "^29.2.0",
25 | "@types/node": "^20.5.7",
26 | "@typescript-eslint/eslint-plugin": "^5.10.2",
27 | "@typescript-eslint/parser": "^5.10.2",
28 | "eslint": "^8.8.0",
29 | "eslint-config-prettier": "^8.3.0",
30 | "eslint-plugin-prettier": "^4.0.0",
31 | "jest": "^29.2.1",
32 | "prettier": "^2.5.1",
33 | "ts-jest": "^29.0.5",
34 | "ts-node": "^10.9.1",
35 | "typescript": "^4.8.4"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/lichess/UserGame.java:
--------------------------------------------------------------------------------
1 | package lichess;
2 |
3 | import abstraction.Player.UserObject;
4 | import chariot.Client;
5 | import chariot.model.Game;
6 | import setting.SettingSchema;
7 |
8 | public class UserGame extends UserObject {
9 |
10 | public UserGame(Client client, String userID) {
11 | super(client, userID);
12 |
13 | }
14 |
15 | private boolean isBlack() {
16 |
17 | return this.getClient().games().currentByUserId(this.getUserID()).get().players().black().name()
18 | .equalsIgnoreCase(getUserID());
19 |
20 | }
21 |
22 | public String getUserGamesGif(SettingSchema schema) {
23 |
24 | Game getGame = this.getClient().games().currentByUserId(getUserID()).get();
25 |
26 | if (isBlack()) {
27 | return getGameGif("black", getGame.id(), schema);
28 | } else {
29 | return getGameGif("white", getGame.id(), schema);
30 | }
31 |
32 | }
33 |
34 | public static String getGameGif(String side, String gameId, SettingSchema schema) {
35 | return "https://lichess1.org/game/export/gif/" + side + "/" + gameId + ".gif?theme=" + schema.getBoardTheme()
36 | + "&piece=" + schema.getPieceType();
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/helpermodules/EntityHelperModule.java:
--------------------------------------------------------------------------------
1 | package discord.helpermodules;
2 |
3 | import abstraction.CommandTrigger;
4 | import ladders.LichessLaddersParser;
5 | import net.dv8tion.jda.api.entities.User;
6 | import net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent;
7 |
8 |
9 | import java.io.IOException;
10 | import java.util.List;
11 |
12 | public class EntityHelperModule implements CommandTrigger {
13 |
14 | private final EntitySelectInteractionEvent event;
15 |
16 | public EntityHelperModule(EntitySelectInteractionEvent event) {
17 | this.event = event;
18 | }
19 |
20 |
21 | public void sendViewPlayerLadder(){
22 | List users = event.getMentions().getUsers();
23 | event.deferReply(true).queue();
24 | try {
25 | event.getHook().sendMessage(LichessLaddersParser.getPlayerInfo(users.getFirst().getId())).queue();
26 | } catch (IOException e) {
27 | event.getHook().sendMessage("error! Something went wrong" + e.getMessage()).queue();
28 | }
29 | }
30 |
31 |
32 | @Override
33 | public void trigger(String commandName) {
34 | if(commandName.equalsIgnoreCase("ladder-player-menu")){
35 | sendViewPlayerLadder();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/abstraction/Player/UserObject.java:
--------------------------------------------------------------------------------
1 | package abstraction.Player;
2 |
3 | import chariot.Client;
4 | import io.github.sornerol.chess.pubapi.client.PlayerClient;
5 | import io.github.sornerol.chess.pubapi.domain.player.stats.PlayerStats;
6 | import io.github.sornerol.chess.pubapi.exception.ChessComPubApiException;
7 |
8 | import java.io.IOException;
9 |
10 | public class UserObject {
11 |
12 | private Client client = Client.basic();
13 | private final String userID;
14 | private final PlayerClient playerClient = new PlayerClient();
15 |
16 | public UserObject(Client client, String userParsing) {
17 | this.client = client;
18 | this.userID = userParsing.toLowerCase().trim();
19 | }
20 |
21 | public UserObject(String username) {
22 | this.userID = username.toLowerCase().trim();
23 | }
24 |
25 | public Client getClient() {
26 | return this.client;
27 | }
28 |
29 | public String getUserID() {
30 | return this.userID;
31 | }
32 |
33 | public PlayerClient getPlayerClient() {
34 | return playerClient;
35 | }
36 |
37 | public PlayerStats getChessComStats() throws ChessComPubApiException, IOException {
38 | return getPlayerClient().getStatsForPlayer(this.userID);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/handlermodules/SlashContextModule.java:
--------------------------------------------------------------------------------
1 | package discord.handlermodules;
2 |
3 | import abstraction.HandleContext;
4 | import discord.helpermodules.*;
5 | import discord.mainhandler.CommandInfo;
6 | import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
7 |
8 |
9 | public class SlashContextModule implements HandleContext {
10 |
11 | private final SlashCommandInteractionEvent slashEvent;
12 |
13 | public SlashContextModule(SlashCommandInteractionEvent slashEvent) {
14 | this.slashEvent = slashEvent;
15 | }
16 |
17 | @Override
18 | public void handleLogic() {
19 | String name = slashEvent.getName();
20 | EngineHelperModule engineTool = new EngineHelperModule(slashEvent);
21 | CommandInfo infoTool = new CommandInfo(slashEvent);
22 | ChessSlashHelperModule chessTool = new ChessSlashHelperModule(slashEvent);
23 | NetworkHelperModule networkTool = new NetworkHelperModule(slashEvent);
24 | PuzzleContextHelperModule puzzleTool = new PuzzleContextHelperModule(slashEvent);
25 |
26 | engineTool.trigger(name);
27 | infoTool.trigger(name);
28 | chessTool.trigger(name);
29 | networkTool.trigger(name);
30 | puzzleTool.trigger(name);
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Java CI with Maven
10 |
11 | permissions:
12 | contents: read
13 |
14 | on:
15 | push:
16 | branches: [ "master" ]
17 | pull_request:
18 | branches: [ "master" ]
19 |
20 | jobs:
21 | build:
22 |
23 | runs-on: ubuntu-latest
24 |
25 | steps:
26 | - uses: actions/checkout@v3
27 | - name: Set up JDK 21
28 | uses: actions/setup-java@v3
29 | with:
30 | java-version: '21'
31 | distribution: 'temurin'
32 | cache: maven
33 | - name: Build with Maven
34 | run: mvn -B package --file chesslise/pom.xml
35 |
36 | # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
37 | # - name: Update dependency graph
38 | # uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
39 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/discord/mainhandler/AntiSpam.java:
--------------------------------------------------------------------------------
1 | package discord.mainhandler;
2 |
3 | import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | public class AntiSpam {
9 |
10 | private final Map userRequestMap;
11 |
12 | private final long timeFrame;
13 | private final int maxRequests;
14 |
15 | public AntiSpam(long timeFrame, int maxRequests) {
16 | userRequestMap = new HashMap<>();
17 | this.timeFrame = timeFrame;
18 | this.maxRequests = maxRequests;
19 | }
20 |
21 | public boolean checkSpam(SlashCommandInteractionEvent event) {
22 | String userId = event.getUser().getId();
23 |
24 | Long lastRequestTime = userRequestMap.get(userId);
25 | if (lastRequestTime != null && System.currentTimeMillis() - lastRequestTime < timeFrame) {
26 | int numRequests = 0;
27 | for (long timestamp : userRequestMap.values()) {
28 | if (System.currentTimeMillis() - timestamp < timeFrame) {
29 | numRequests++;
30 | }
31 | }
32 | if (numRequests >= maxRequests) {
33 | return true;
34 | }
35 | }
36 |
37 | userRequestMap.put(userId, System.currentTimeMillis());
38 | return false;
39 | }
40 | }
--------------------------------------------------------------------------------
/chessliseskycc/chesslisesky/app.ts:
--------------------------------------------------------------------------------
1 | import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
2 | import { Chesslisesky } from './chesslisesky';
3 |
4 | /**
5 | *
6 | * Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
7 | * @param {Object} event - API Gateway Lambda Proxy Input Format
8 | *
9 | * Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
10 | * @returns {Object} object - API Gateway Lambda Proxy Output Format
11 | *
12 | */
13 |
14 | export const lambdaHandler = async (event: APIGatewayProxyEvent): Promise => {
15 | try {
16 | console.log('starting bot');
17 | const bot = new Chesslisesky();
18 | const { gifUrl, puzzleUrl, title } = await bot.fetchChessComPuzzle();
19 | const gifBase64 = await bot.fetchGifAsBase64(gifUrl);
20 | console.log('Fetched puzzle URL:', puzzleUrl);
21 | await bot.postPuzzle(puzzleUrl, gifBase64, title);
22 | console.log('ending...');
23 | return {
24 | statusCode: 200,
25 | body: JSON.stringify({
26 | message: puzzleUrl,
27 | gif: gifUrl,
28 | }),
29 | };
30 | } catch (err) {
31 | console.log(err);
32 | return {
33 | statusCode: 500,
34 | body: JSON.stringify({
35 | message: 'some error happened',
36 | }),
37 | };
38 | }
39 | };
40 |
--------------------------------------------------------------------------------
/chesslisesky/chesslisesky/app.ts:
--------------------------------------------------------------------------------
1 | import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
2 | import { Chesslisesky } from './chesslisesky';
3 |
4 | /**
5 | *
6 | * Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
7 | * @param {Object} event - API Gateway Lambda Proxy Input Format
8 | *
9 | * Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
10 | * @returns {Object} object - API Gateway Lambda Proxy Output Format
11 | *
12 | */
13 |
14 | export const lambdaHandler = async (event: APIGatewayProxyEvent): Promise => {
15 | try {
16 | console.log('starting bot');
17 | const bot = new Chesslisesky();
18 | const { gifUrl, puzzleUrl } = await bot.fetchLichessPuzzle();
19 | const gifBase64 = await bot.fetchGifAsBase64(gifUrl);
20 | console.log('Fetched puzzle URL:', puzzleUrl);
21 | await bot.postPuzzle(puzzleUrl, gifBase64);
22 | await bot.postChallengeURLs();
23 | console.log('ending...');
24 | return {
25 | statusCode: 200,
26 | body: JSON.stringify({
27 | message: puzzleUrl,
28 | gif: gifUrl,
29 | }),
30 | };
31 | } catch (err) {
32 | console.log(err);
33 | return {
34 | statusCode: 500,
35 | body: JSON.stringify({
36 | message: 'some error happened',
37 | }),
38 | };
39 | }
40 | };
41 |
--------------------------------------------------------------------------------
/chesslisesky/template.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Transform: AWS::Serverless-2016-10-31
3 | Description: >
4 | chesslisesky
5 |
6 | Sample SAM Template for chesslisesky
7 |
8 | # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
9 | Globals:
10 | Function:
11 | Timeout: 120
12 |
13 | Parameters:
14 | BlueSkyUser:
15 | Type: String
16 | Description: Username
17 | Default: chesslise.bsky.social
18 | BlueSkyUserPassword:
19 | Type: String
20 | Description: Password
21 | Default: 'enter password'
22 |
23 |
24 | Resources:
25 | ChessLiseSkyFunction:
26 | Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
27 | Properties:
28 | CodeUri: chesslisesky/
29 | Handler: app.lambdaHandler
30 | Runtime: nodejs20.x
31 | Environment:
32 | Variables:
33 | BlueSkyUser: !Ref BlueSkyUser
34 | BlueSkyUserPassword: !Ref BlueSkyUserPassword
35 | Architectures:
36 | - x86_64
37 | Events:
38 | CWSchedule:
39 | Type: ScheduleV2
40 | Properties:
41 | ScheduleExpression: 'cron(0 14 * * ? *)'
42 | Name: TestScheduleV2Function
43 | Description: Post lichess daily puzzle
44 | Metadata: # Manage esbuild properties
45 | BuildMethod: esbuild
46 | BuildProperties:
47 | Minify: true
48 | Target: "es2020"
49 | Sourcemap: true
50 | EntryPoints:
51 | - app.ts
52 |
--------------------------------------------------------------------------------
/chessliseskycc/template.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Transform: AWS::Serverless-2016-10-31
3 | Description: >
4 | chesslisesky
5 |
6 | Sample SAM Template for chesslisesky
7 |
8 | # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
9 | Globals:
10 | Function:
11 | Timeout: 120
12 |
13 | Parameters:
14 | BlueSkyUser:
15 | Type: String
16 | Description: Username
17 | Default: chesslise.bsky.social
18 | BlueSkyUserPassword:
19 | Type: String
20 | Description: Password
21 | Default: 'enter password'
22 |
23 |
24 | Resources:
25 | ChessLiseSkyCCFunction:
26 | Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
27 | Properties:
28 | CodeUri: chesslisesky/
29 | Handler: app.lambdaHandler
30 | Runtime: nodejs20.x
31 | Environment:
32 | Variables:
33 | BlueSkyUser: !Ref BlueSkyUser
34 | BlueSkyUserPassword: !Ref BlueSkyUserPassword
35 | Architectures:
36 | - x86_64
37 | Events:
38 | CWSchedule:
39 | Type: ScheduleV2
40 | Properties:
41 | ScheduleExpression: 'cron(0 15 * * ? *)'
42 | Name: TestScheduleV2Function2
43 | Description: Post Chess.com daily puzzle
44 | Metadata: # Manage esbuild properties
45 | BuildMethod: esbuild
46 | BuildProperties:
47 | Minify: true
48 | Target: "es2020"
49 | Sourcemap: true
50 | EntryPoints:
51 | - app.ts
52 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/user/Disconnect.java:
--------------------------------------------------------------------------------
1 | package network.user;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import com.mongodb.client.model.Updates;
5 | import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
6 | import network.challenge.Action;
7 |
8 | import org.bson.Document;
9 |
10 | public class Disconnect extends Action {
11 |
12 | public Disconnect(MongoCollection networkChallenges, MongoCollection networkPlayers) {
13 | super(networkChallenges, networkPlayers);
14 | }
15 |
16 | // pepesadge
17 | public void disconnect(SlashCommandInteractionEvent event) {
18 | event.deferReply(true).queue();
19 |
20 | String goOffline = goOffline(event.getUser().getId());
21 |
22 | event.getHook().sendMessage(goOffline).queue();
23 | }
24 |
25 | // sometimes you need a break, we got it
26 | public String goOffline(String discordid) {
27 |
28 | Document current = new Document("id", discordid);
29 |
30 | Document user = getNetworkPlayers().find(current).first();
31 |
32 | if (user == null) {
33 | return "You have not connected your account! Only connected users can disconnect their accounts and go offline";
34 | }
35 |
36 | if (user.getBoolean("offline")) {
37 | return "You are already in offline mode, if you want to reconnect run /connect";
38 | }
39 |
40 | this.getNetworkPlayers().updateOne(user, Updates.set("offline", true));
41 |
42 | return "Successfully made your account offline! You won't see any challenges or friend pairings, to go online please run /connect";
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/lichess/FenPuzzle.java:
--------------------------------------------------------------------------------
1 |
2 | package lichess;
3 |
4 | import abstraction.Puzzle;
5 | import abstraction.PuzzleView;
6 | import discord.mainhandler.Thumbnail;
7 | import net.dv8tion.jda.api.EmbedBuilder;
8 | import setting.SettingSchema;
9 | import com.github.bhlangonijr.chesslib.Board;
10 |
11 | import java.awt.*;
12 |
13 | public class FenPuzzle extends PuzzleView implements Puzzle {
14 |
15 | private final String fen;
16 |
17 | public FenPuzzle(String fen) {
18 | this.fen = fen;
19 | }
20 |
21 | @Override
22 | public String definePuzzleFen() {
23 | return this.fen;
24 | }
25 |
26 | public boolean isValidFen() {
27 | try {
28 | Board board = new Board();
29 | board.loadFromFen(this.fen);
30 | return true;
31 | } catch (Exception e) {
32 | return false;
33 | }
34 | }
35 |
36 | @Override
37 | public EmbedBuilder defineCommandCard(SettingSchema schema) {
38 | return new EmbedBuilder().setDescription(definePuzzleDescription()).setColor(defineEmbedColor())
39 | .setTitle(definePuzzleTitle()).setImage(renderImage(definePuzzleFen(), schema))
40 | .setThumbnail(definePuzzleLogo());
41 | }
42 |
43 | @Override
44 | public String definePuzzleLogo() {
45 | return Thumbnail.getChessliseLogo();
46 | }
47 |
48 | @Override
49 | public String definePuzzleTitle() {
50 | return "View Position";
51 | }
52 |
53 | @Override
54 | public Color defineEmbedColor() {
55 | return Color.orange;
56 | }
57 |
58 | @Override
59 | public String definePuzzleDescription() {
60 | return this.defineSideToMove(this.fen);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/challenge/Cancel.java:
--------------------------------------------------------------------------------
1 | package network.challenge;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import com.mongodb.client.model.Updates;
5 | import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
6 | import org.bson.Document;
7 |
8 | public class Cancel extends Action {
9 |
10 | public Cancel(MongoCollection networkChallenges, MongoCollection networkPlayers) {
11 | super(networkChallenges, networkPlayers);
12 | }
13 |
14 | public void cancel(SlashCommandInteractionEvent event) {
15 | event.deferReply(true).queue();
16 |
17 | if (this.getFinder().findConnected(event.getUser().getId())) {
18 | event.getHook().sendMessage(
19 | "You must connect your account before canceling a challenge! Run /connect to connect your account!")
20 | .queue();
21 | }
22 |
23 | event.getHook().sendMessage(this.cancelChallenge(event.getOption("challid").getAsString())).queue();
24 | }
25 |
26 | public String cancelChallenge(String challengeid) {
27 | Document query = new Document("challengeId", challengeid);
28 | Document finder = this.getNetworkChallenges().find(query).first();
29 |
30 | if (finder != null) {
31 | String status = finder.getString("status");
32 | if (status.equalsIgnoreCase("completed")) {
33 | return "Can not cancel completed challenge!";
34 | }
35 | this.getNetworkChallenges().updateOne(finder, Updates.set("status", "cancel"));
36 | return "Successfully canceled the challenge!";
37 | }
38 |
39 | return "Invalid challenge id, view challenges in /mychallenges!";
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/chesscom/DailyCommandCC.java:
--------------------------------------------------------------------------------
1 | package chesscom;
2 |
3 | import abstraction.*;
4 | import abstraction.Puzzle;
5 | import discord.mainhandler.Thumbnail;
6 | import io.github.sornerol.chess.pubapi.client.DailyPuzzleClient;
7 | import io.github.sornerol.chess.pubapi.exception.ChessComPubApiException;
8 | import net.dv8tion.jda.api.EmbedBuilder;
9 | import setting.SettingSchema;
10 |
11 | import java.awt.*;
12 | import java.io.IOException;
13 |
14 | public class DailyCommandCC extends PuzzleView implements Puzzle {
15 |
16 | private final DailyPuzzleClient puzzleClient = new DailyPuzzleClient();
17 |
18 | public DailyCommandCC() {
19 | super();
20 | }
21 |
22 | @Override
23 | public String definePuzzleFen() {
24 | try {
25 | return puzzleClient.getTodaysDailyPuzzle().getFen();
26 | } catch (IOException | ChessComPubApiException e) {
27 | return "invalid fen";
28 | }
29 | }
30 |
31 | @Override
32 | public String definePuzzleLogo() {
33 | return Thumbnail.getChesscomLogo();
34 | }
35 |
36 | @Override
37 | public String definePuzzleTitle() {
38 | return "Chess.com Daily Puzzle";
39 | }
40 |
41 | @Override
42 | public Color defineEmbedColor() {
43 | return Color.GREEN;
44 | }
45 |
46 | @Override
47 | public String definePuzzleDescription() {
48 | String fen = definePuzzleFen();
49 | return "**Turn: **" + defineSideToMove(fen) + "\n **FEN: **" + fen;
50 | }
51 |
52 | @Override
53 | public EmbedBuilder defineCommandCard(SettingSchema schema) {
54 | return new EmbedBuilder().setColor(defineEmbedColor()).setTitle(definePuzzleTitle())
55 | .setThumbnail(definePuzzleLogo()).setDescription(definePuzzleDescription())
56 | .setImage(renderImage(definePuzzleFen(), schema));
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/challenge/Complete.java:
--------------------------------------------------------------------------------
1 | package network.challenge;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import com.mongodb.client.model.Updates;
5 | import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
6 | import org.bson.Document;
7 |
8 | public class Complete extends Action {
9 |
10 | public Complete(MongoCollection networkChallenges, MongoCollection networkPlayers) {
11 | super(networkChallenges, networkPlayers);
12 | }
13 |
14 | public void complete(SlashCommandInteractionEvent event) {
15 | event.deferReply(true).queue();
16 |
17 | if (getFinder().findConnected(event.getUser().getId())) {
18 | event.getHook().sendMessage(
19 | "You must connect your account before canceling a challenge! Run /connect to connect your account!")
20 | .queue();
21 | }
22 |
23 | event.getHook().sendMessage(this.completeChallenge(event.getOption("cchallid").getAsString())).queue();
24 | }
25 |
26 | public String completeChallenge(String challengeid) {
27 | Document query = new Document("challengeId", challengeid);
28 |
29 | Document finder = this.getNetworkChallenges().find(query).first();
30 | if (finder != null) {
31 | String status = finder.getString("status");
32 | if (status.equalsIgnoreCase("accepted")) {
33 | this.getNetworkChallenges().updateOne(query, Updates.set("status", "completed"));
34 | return "Successfully completed the challenge!";
35 | } else {
36 | return "Can not complete challenge status of " + status
37 | + "complete! Only accepted challenges can be completed!";
38 | }
39 |
40 | }
41 |
42 | return "Invalid challenge id, view challenges in /mychallenges!";
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/chesslise/src/main/java/network/user/friends/CancelFriendRequest.java:
--------------------------------------------------------------------------------
1 | package network.user.friends;
2 |
3 | import com.mongodb.client.MongoCollection;
4 | import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
5 | import org.bson.Document;
6 |
7 | public class CancelFriendRequest extends Request {
8 |
9 | public CancelFriendRequest(MongoCollection players) {
10 | super(players);
11 |
12 | }
13 |
14 | public void cancelFriendRequest(SlashCommandInteractionEvent event) {
15 | event.deferReply(true).queue();
16 |
17 | String cancelFked = cancelFriend(event.getUser().getId(), event.getOption("cancelid").getAsString());
18 |
19 | event.getHook().sendMessage(cancelFked).queue();
20 | }
21 |
22 | // no one should cancel a friend but oh well sh*t happens
23 | public String cancelFriend(String discordid, String incommingFriendRequest) {
24 | Document current = this.getNetworkPlayers().find(new Document("id", discordid)).first();
25 | Document cancel = this.getNetworkPlayers().find(new Document("id", incommingFriendRequest)).first();
26 |
27 | if (current == null) {
28 | return "You must connect your account before canceling a friend request! Run /connect to connect your account!";
29 | }
30 |
31 | if (cancel == null) {
32 | return "The given discord id is not valid! Make sure its valid by viewing the requests in /viewfriends