{"id":16326600,"url":"https://github.com/icelam/leetcode-daily-question-telegram-bot","last_synced_at":"2025-10-25T20:32:05.333Z","repository":{"id":110261059,"uuid":"437318406","full_name":"icelam/leetcode-daily-question-telegram-bot","owner":"icelam","description":"Fetch question of today from Leetcode's GraphQL API and send it to Telegram channel @LeetcodeQustionOfToday","archived":false,"fork":false,"pushed_at":"2024-03-12T10:04:12.000Z","size":4913,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-01-31T10:25:57.621Z","etag":null,"topics":["aws-lambda","aws-lambda-python","serverless-framework","telegram-bot","telegram-python","telegram-python-bot","telegram-scheduled-message"],"latest_commit_sha":null,"homepage":"https://t.me/LeetcodeQustionOfToday","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icelam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-12-11T15:28:24.000Z","updated_at":"2023-12-14T01:21:34.000Z","dependencies_parsed_at":"2023-12-05T06:39:21.211Z","dependency_job_id":null,"html_url":"https://github.com/icelam/leetcode-daily-question-telegram-bot","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelam%2Fleetcode-daily-question-telegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelam%2Fleetcode-daily-question-telegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelam%2Fleetcode-daily-question-telegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icelam%2Fleetcode-daily-question-telegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icelam","download_url":"https://codeload.github.com/icelam/leetcode-daily-question-telegram-bot/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238207648,"owners_count":19434095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","aws-lambda-python","serverless-framework","telegram-bot","telegram-python","telegram-python-bot","telegram-scheduled-message"],"created_at":"2024-10-10T23:08:55.624Z","updated_at":"2025-10-25T20:32:04.784Z","avatar_url":"https://github.com/icelam.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Leetcode Daily Question Telegram Bot\n\n\u003e **Warning**  \n\u003e End of Maintenance Notice (2023-10-29):  \n\u003e Visit [https://t.me/LeetcodeQustionOfToday/720](https://t.me/LeetcodeQustionOfToday/720) for more information.\n\nFetch question of today from Leetcode's GraphQL API and send it to Telegram channel.\n\n![Mockup](./docs/mockup.png)\n\n## Development Notes\n\n### Tech Stack\n* Python 3\n* [Serverless](https://www.npmjs.com/package/serverless)\n* AWS Lambda\n* AWS CloudFormation - Used by Serverless when doing deployment\n* AWS CloudWatch - Automatically Setup by Serverless when doing deployment\n* AWS S3 - Used by Serverless when doing deployment\n\n\u003e **Note:**  \n\u003e Both Lambda, CloudWatch, and CloudFormation has free tier provided. However for AWS S3, it has only has free tier for limited time.\n\u003e \n\u003e To check the tier limit, head to [https://aws.amazon.com/free/](https://aws.amazon.com/free/). It is recommended to setup a billing alert by following the documentation on [https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/tracking-free-tier-usage.html](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/tracking-free-tier-usage.html). \n\n### Development Setup\n\n#### Prerequisites\n* Node.js 14 installed\n* Python 3 installed\n* `virtualenv` installed\n\n#### Prepare `serverless` environment\n\n##### NPM\n\n```bash\nnpm install serverless@3 --global\nnpm install\n```\n\n##### Yarn\n\n```bash\nyarn global add serverless@3\nyarn\n```\n\n#### Setup Python Virtual Environments\n\n```bash\n# Create a new virtual environment\nvirtualenv venv --python=python3\n\n# Activate virtual environment created\n. venv/bin/activate\n\n# Install dependencies listed in requirements.txt\npip install -r requirements.txt\n```\n\n#### Setup Bot to send message\n\nSave a copy of `.env`  and name it as `.env.local`, place your Telegram bot token and Telegram Chat ID in the configuration file.\n\n\u003e **Note:**\n\u003e Environment variables are used instead of `ConfigParser` provided by Python since [by default AWS Lambda will encrypt environment variables using KMS](https://docs.aws.amazon.com/whitepapers/latest/kms-best-practices/encrypting-lambda-environment-variables.html), and we don't want to store tokens using plain text.\n\n##### 1. How to get a Telegram bot token\n\n1. In Telegram, search for the user `@BotFather`.\n2. Use the command `\\newbot` and choose a name and username for your bot.\n3. `@BotFather` will return you the token of the bot created. Remember to keep it safe!\n\n##### 2. How to get a Telegram chat ID\n\n1. Send a `/start` command to the telegram bot created in the previous step\n2. Visit `https://api.telegram.org/bot\u003cBOT_TOKEN\u003e/getUpdates`\n3. Look at the API response, `result[0]['message']['chat']['id']` should contains ID of the chat. Remember to copy the `-` prefix if exists.\n\n##### 3. Test if Bot token and Chat ID is correct or not\n\nOpen Terminal, run the following command. You will need to replace `\u003cBOT_TOKEN\u003e` and `\u003cCHAT_ID\u003e` with the one you get in previous steps.\n\n```bash\ncurl -X POST \"https://api.telegram.org/bot\u003cBOT_TOKEN\u003e/sendMessage\" -d \"chat_id=\u003cCHAT_ID\u003e\u0026text=Hello World\"\n```\n\n#### Deployment\n\n##### Create named AWS profile (for first time deployment)\n\n1. Create new user on AWS, with \"Programmatic access\"\n2. Assign permission to user by \"Attaching existing policies directly\"\n    * In the official Serverless blog, they have introduced [serverless-policy generator](https://github.com/dancrumb/generator-serverless-policy) to help you generate IAM policies.\n3. Configure new AWS credientials to use newly created user\n    ```bash\n    aws configure --profile \u003cPROFILE_NAME\u003e\n    ```\n\n##### Deploy to Lambda\n\n```bash\n# Load environment variables\n. load-environment-variables.sh\n\n# Deploy to AWS Lambda using serverless cli\nserverless deploy --aws-profile \u003cPROFILE_NAME\u003e\n```\n\n#### Settings\n\n##### Add / Edit bot messages\nAll messages are stored in `app/messages.txt`, and will be randomly picked when handler is triggered. To update the message sets, simply edit and save the file. Re-deployment is needed for changes to take effect.\n\n##### Add / Edit stickers\nAll sticker IDs are stored in `app/stickers.txt`, and will be randomly picked when handler is triggered. To update the sticker sets, you will need to get the sticker ID by sending stickers to the created bot. Visit `https://api.telegram.org/bot\u003cBOT_TOKEN\u003e/getUpdates`, stickers ID can be found in the API reponse node `result[n]['message']['sticker']['file_id']`. Re-deployment is needed for changes to take effect.\n\n##### Edit bot schedule\n\nOpen `serverless.yml`, edit `functions['cron']['schedule']`. Syntax reference: [https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html](https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html)\n\n#### Test\n\n##### Testing the handler\n\nRun the following command inside virtual environment:\n```bash\n# Load environment variables\n. load-environment-variables.sh\n\n# Execute handler\nserverless invoke local -f cron\n```\n\n#### Others\n\n##### Delete deployed Lambda function\n\n```bash\nserverless remove --aws-profile \u003cPROFILE_NAME\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficelam%2Fleetcode-daily-question-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficelam%2Fleetcode-daily-question-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficelam%2Fleetcode-daily-question-telegram-bot/lists"}