Skip to content

Commit

Permalink
chore: remove manual, capture repo during setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Sep 13, 2024
1 parent 99ac8cc commit 14edbaf
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 355 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ This bot operates in two parts:

The `TELEGRAM_BOT_ENV` is a single JSON object that encapsulates all necessary environment variables for the bot's operation. It consists of four key sections: `botSettings`, `mtProtoSettings`, `storageSettings`, and `ubiquityOsSettings`.

You can set up your environment variables in two ways using the provided utility script:
You can set up your environment variables by using the provided utility script:

1. **Guided Setup**: Run `yarn setup-env-guided`, which prompts you to enter each value via the CLI. The values will be serialized and stored both locally and in your repository secrets.
2. **Manual Setup**: Modify the values directly in the script and then run `yarn setup-env-manual` to store them locally and in your repository secrets.
- Run `yarn setup-env-guided`, which prompts you to enter each value via the CLI. The values will be serialized and stored both locally and in your repository secrets.

- **GITHUB_PAT_TOKEN**: Create a classic personal access token (PAT) with the `repo` scope. Set the expiry to 24 hours. This token will be used to generate repository secrets for the environment variables and will be removed from `.env` after the secrets are saved.
- **Account Permission**: The account in which the PAT is associated with *must* be an `admin` of the repository to be able to save secrets this way. Visit your repository settings `telegram-bot` > `Collaborators & teams` to add the account as an admin first if needed.
- **Account Permission**: The account in which the PAT is associated with _must_ be an `admin` of the repository to be able to save secrets this way. Visit your repository settings `telegram-bot` > `Collaborators & teams` to add the account as an admin first if needed.

The environment variables are stored in the following locations:

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"start": "tsx ./src/main.ts",
"deploy": "wrangler deploy --minify src/main.ts",
"sms-auth": "npx tsx src/bot/mtproto-api/bot/scripts/sms-auth/sms-auth.ts",
"setup-env-guided": "npx tsx src/bot/mtproto-api/bot/scripts/sms-auth/setup-env.ts",
"setup-env-manual": "npx tsx src/bot/mtproto-api/bot/scripts/sms-auth/setup-env.ts --manual"
"setup-env-guided": "npx tsx src/bot/mtproto-api/bot/scripts/sms-auth/setup-env.ts"
},
"keywords": [
"typescript",
Expand Down
18 changes: 0 additions & 18 deletions src/adapters/supabase/helpers/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Super } from "./supabase";
import { PluginContext } from "#root/types/plugin-context-single.js";

type Wallet = {
address: string;
Expand All @@ -21,21 +20,4 @@ export class User extends Super {

return data?.wallets?.address || null;
}

async getWalletByGitHubUsername(username: string) {
const ctx = PluginContext.getInstance().getContext();
const { octokit } = ctx;
const githubUserId = (await octokit.rest.users.getByUsername({ username })).data.id;
const { data, error } = (await this.supabase.from("users").select("wallets(*)").eq("id", githubUserId).single()) as {
data: { wallets: Wallet };
error: unknown;
};
if ((error && !data) || !data.wallets?.address) {
this.logger.error("No wallet address found", { githubUserId });
} else {
this.logger.info("Successfully fetched wallet", { githubUserId, address: data.wallets?.address });
}

return data?.wallets?.address || null;
}
}
28 changes: 0 additions & 28 deletions src/bot/features/commands/shared/wallet.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/bot/mtproto-api/bot/mtproto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { SupabaseSession } from "./session";
import { createClient, SupabaseClient } from "@supabase/supabase-js";
dotenv.config();


/**
* This class MUST ONLY be used in the context of workflow-functions as
* it requires a Node.js environment which is not available with Cloudflare Workers.
Expand Down
2 changes: 0 additions & 2 deletions src/bot/mtproto-api/bot/scripts/sms-auth/base-mtproto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { StringSession } from "telegram/sessions";
import { Context } from "#root/types/context.js";
dotenv.config();



/**
* @dev Not abstract because we need it to be instantiated for sms-auth
*
Expand Down
Loading

0 comments on commit 14edbaf

Please sign in to comment.