Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2e001dd
added to settings.go
poipoi555 Jan 14, 2025
d962f59
Initial commit
josh1248 Jan 27, 2025
22e02fd
Update README.md
josh1248 Jan 27, 2025
51ce42c
initialize :)
josh1248 Jan 27, 2025
25ac342
vite base template testing
josh1248 Jan 27, 2025
d2b81f1
set vite to relative directory
josh1248 Jan 27, 2025
e916998
Test React + TS template from @szelingtan
josh1248 Apr 9, 2025
545e2fb
test addition of env variables for digitalocean
josh1248 Apr 9, 2025
4ff461c
remove https header from host name (https://stackoverflow.com/questio…
josh1248 Apr 9, 2025
7949f26
change env variable capture to vite style
josh1248 Apr 9, 2025
03e333e
increase flexibility of port use
josh1248 Apr 9, 2025
85425d4
change host to 0.0.0.0 for testing
josh1248 Apr 9, 2025
32b88f1
limit test deployment
josh1248 Apr 9, 2025
1a15101
remove junk configs
josh1248 Apr 9, 2025
b6de3cc
whitelist cloud deployment website in secret env
josh1248 Apr 9, 2025
6244280
removed refs to Lovable
josh1248 Apr 9, 2025
c5454cc
handling another config issue for cloud
josh1248 Apr 9, 2025
1017310
fix relative importing directory
josh1248 Apr 9, 2025
e8438ec
replace final relative import
josh1248 Apr 9, 2025
837d51e
revert check
josh1248 Apr 9, 2025
a497fd4
one more rogue @/
josh1248 Apr 9, 2025
a9de153
specify node version
josh1248 Apr 9, 2025
3318d0f
re-generate package lock
josh1248 Apr 9, 2025
5c33085
engine fields in package.json
josh1248 Apr 9, 2025
c855386
fix node/npm version due to "dangerous semver" issues
josh1248 Apr 9, 2025
83ff2d1
sync package lock (again)
josh1248 Apr 9, 2025
312d6a7
i am confusion
josh1248 Apr 9, 2025
6e14f04
set new version of node
josh1248 Apr 9, 2025
a3cb7d1
update postcss config
josh1248 Apr 9, 2025
c044f70
refresh package lock
josh1248 Apr 9, 2025
d8da64e
update fetching of user data
josh1248 Apr 9, 2025
1a87649
? for un-initialized initData at the start
josh1248 Apr 9, 2025
f8384d2
wrap data fetching in useEffect
josh1248 Apr 9, 2025
a528bdf
Merge pull request #1 from josh1248/reactTsTemplate
josh1248 Apr 9, 2025
fa742d2
Merge branch 'josh1248:main' into main
poipoi555 Apr 14, 2025
0f57191
.
poipoi555 Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .envTemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://vite.dev/guide/env-and-mode
# Vite environment variables are to be prefixed with "VITE_" before it is visible.
# 0.0.0.0 to allow all hosts to send requests to it.
VITE_HOST=0.0.0.0

# cloud deployment - determines which requests sent are allowed (in this case, the cloud domain)
VITE_CLOUD_HOST=
46 changes: 24 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
node_modules
dist
dist-ssr
*.local

# Dependency directories (remove the comment below to include it)
# vendor/
# secrets
.env

# Go workspace file
go.work
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Telegram bot token
*.env

# Mac items
.DS_Store
54 changes: 15 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,24 @@
# nusc-queue-bot
Implements a Telegram bot for small to medium-scale events that involve queueing, such as for photobooths. Meant for NUSC events, but can be used in any other queue setting.
# nusc-queuebot-miniapp
The repository to hold the NUSC Telegram queuebot project as a native Telegram mini app in React + TypeScript. Previously written in Golang + Postgres at https://github.com/josh1248/telegram-queue-bot .

Inspired by deprecated queue bot counterparts written in Python here:
https://github.com/kwokyto/usp-queue-bot
The API of choice to communicate with Telegram is via @vkruglikov/react-telegram-web-app.

(Note: The queuebot is in the processing of being ported over to a native Telegram mini app at https://github.com/josh1248/nusc-queuebot-miniapp - no more feature commits will be made.)

# how to set up
## environment variables
The required environment variables are written within the `.envTemplate` file. The actual strings have been hidden for security reasons.

## :warning: A cautionary note
- Local server setup in this repo will require your API keys and passwords to be placed within a .env file. Unless you modify this code to use secret manager applications instead (or other means), you should not locally host this bot if your computer is shared!.
- This is obviously a hobby project with ssl-mode off and no passwords required - security is not considered since my database storage is low-value.

## Clone this repo
```sh
# Step 1: Clone the repository using the project's Git URL.
git clone <YOUR_GIT_URL>

## Register Your Bot on Telegram
*Accurate as of Apr 2024*
https://core.telegram.org/bots/tutorial
- Find @BotFather through Telegram global search
- Set up a bot with a desired name
- Obtain your top-secret API key from BotFather to control your bot by
- Test that you have established a link to your bot using this link, replacing "YOUR_BOT_TOKEN" with the API key
`https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getMe`
- If you are un-successful, you will receive a 404 response. Check that you have entered the correct bot API token provided by BotFather, which should be in the form "XXXXX:YYYY", where X are numbers only and Y are alphanumeric.

![404 reponse!](./images/setup_unsuccessfulAPItoken.png)
# Step 2: Navigate to the project directory.
cd <YOUR_PROJECT_NAME>

- If you are successful, you will receive an OK response with some basic information about your bot in JSON.

![200 OK reponse!](./images/setup_successfulAPItoken.png)
# Step 3: Install the necessary dependencies.
npm i

- :warning: **Important:** Duplicate the .envSETUP key in this folder. Rename this file to ".env", and place in your API token after "BOT_TOKEN". This ".env" file is ignored (by Git) and not committed to GitHub to keep your API secret. (Don't pass this key around, or else people can control your bot!)
# Step 4: Start the development server with auto-reloading and an instant preview.
npm run dev
```

## Local deployment - Install Go (what version) and Postgres (what version)

Install the Go parser at https://go.dev/doc/install
Install a relatively up-to-date PostgreSQL runner at https://www.postgresql.org/download/windows/. For Mac users, I use https://postgresapp.com/, which may be considered.
Within your coding environment (e.g. VSCode), run `go run cmd/server/main.go`. If any errors result, do check that you have updated your `.env` file appropriately (instructions above), that you have Postgres running, and that your bot token is valid.

## Remote deployment - Heroku


# running the server (local)
Cook your computer and keep it running

# running the server (remote)
Heroku or AWS or other services? not sure yet.
Binary file added bun.lockb
Binary file not shown.
13 changes: 13 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
}
}
29 changes: 29 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/no-unused-vars": "off",
},
}
);
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>nusc-queuebot-miniapp</title>

<meta property="og:title" content="nusc-queuebot-miniapp" />
<meta property="og:type" content="website" />
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion internal/botaccess/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const (

nonCommandFeedback string = "Please input a command which starts with '/', like /start"

invalidCommandFeedback string = "Sorry, I don't recognize your command :("
invalidCommandFeedback string = "Sorry, I don't recognize your command :( Please try again!"

joinQueueAlreadyJoined string = "You have already joined this queue!"
joinQueueSuccess string = "Joined the queue. (Check the queue with /howlong.)"
Expand Down
Loading