Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM Notifications #3

Merged
merged 90 commits into from
Oct 28, 2024

Conversation

Keyrxng
Copy link
Member

@Keyrxng Keyrxng commented Oct 3, 2024

Requires #2
Resolves #13

features:

  • Private Notifications triggers: Reward, Review, Reminder, Removal
  • /register keyrxng - binds github account to telegram account
  • /subscribe & /unsubscribe - new commands to enable/disable triggers

QA: #3 (comment)

eslint.config.mjs Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/adapters/github/storage-layer.ts Outdated Show resolved Hide resolved
src/adapters/github/storage-layer.ts Outdated Show resolved Hide resolved
src/adapters/github/storage-layer.ts Outdated Show resolved Hide resolved
src/bot/mtproto-api/bot/scripts/sms-auth/auth-handler.ts Outdated Show resolved Hide resolved
src/bot/mtproto-api/bot/scripts/sms-auth/setup-env.ts Outdated Show resolved Hide resolved
src/bot/mtproto-api/workrooms/reopen-chat.ts Outdated Show resolved Hide resolved
src/bot/mtproto-api/workrooms/reopen-chat.ts Outdated Show resolved Hide resolved
src/handlers/private-notifcations/issue-comment-created.ts Outdated Show resolved Hide resolved
@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 4, 2024

Setup Guide:

First collect all of your variables needed to fill out your .env:

  • TELEGRAM_BOT_REPOSITORY_FULL_NAME

  • REPO_ADMIN_ACCESS_TOKEN

  • TELEGRAM_BOT_WEBHOOK botfather - this should be the deployment URL of the worker-deploy workflow (branch included if necessary)

  • TELEGRAM_BOT_TOKEN botfather

  • TELEGRAM_BOT_WEBHOOK_SECRET botfather

  • TELEGRAM_API_HASH https://my.telegram.org/auth

  • TELEGRAM_APP_ID https://my.telegram.org/auth

Then run yarn setup-env and copy paste them into the terminal. They'll be stored in repo secrets which the worker-deploy workflow will push to cloudflare (requires cloudflare workflow repo secrets are defined).

env-setup.mp4

Then you need to login using yarn sms-auth and you should also be logged in to that account somehow in order to receive the code.

sms-auth.mp4

Then you must:

  • change TELEGRAM_BOT_WEBHOOK env var to a smee url without any path
  • yarn worker terminal A
  • smee -u <smee url> -P "/telegram" terminal B

At this point using commands like /botid should be hitting your worker (requires the config to be pointing at the worker which it should be), which may be responding or not.

  • curl -X POST http://localhost:3000/telegram -H "Content-Type: application/json" -d '{"message": ""}' terminal C
  • Notice the console error within terminal A

At this point your bot should now be interacting with your local worker if you use commands like /botid. Remember that your local worker is pointing to smee, all others point to cloudflare.

If you have not set your own telegram ID as an env var BOT_ADMIN, setwebhook will not work.

Either use https://t.me/UbiquityOS_Beta_Bot or set up your own bot, request your ID and then re-run the yarn setup-env or manually update your local and remote secrets before deploying a new worker.

  • /setwebhook <worker url> to set the bot to the remote worker from your local instance.
  • patiently wait around 3 minutes for it to propagate, periodically invoke /botid
  • responses will cascade in once the endpoint is finished processing
e2e-usage.mp4

Note that by setting the telegram bot to interact with your local worker you will not receive GitHub events unless your ubiquibot-config.yml is pointing to localhost and your kernel is running. This guide does not require the kernel to be running as it's just the setup and bot usage.

@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 4, 2024

Workrooms QA:
ubq-testing#3
https://github.com/ubq-testing/telegram--bot/actions/runs/11173422618/job/31061478592
https://github.com/ubq-testing/telegram--bot/actions/runs/11173432131/job/31061502269
https://github.com/ubq-testing/telegram--bot/actions/runs/11173442905/job/31061527451

/register + /subscribe + /wallet QA:

These can be live tested on my TG bot right now for the next day until my token expires. Obv you won't receive notifys but the rest should work let me know if it doesn't

image

I feel like the notification message should be prettified like the rest of the messages from our bot but I lack the finesse and imagination I think.

Storage QA:
image


@0x4007 For this storage approach should I be storing each of our org's data separate in their own config repo? Or combining somehow into one and having this as a feature so partners can do the same?

Copy link
Contributor

github-actions bot commented Oct 4, 2024

Unused devDependencies (1)

Filename devDependencies
package.json tsc-watch

@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 4, 2024

I just had a thought.

Admin privileges can be granted on a per repo basis, if I'm made admin of this repo only I should be able to set env vars etc and I'll manage this plugin or at least getting it setup and running.

@0x4007
Copy link
Member

0x4007 commented Oct 4, 2024

You're admin now

@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 4, 2024

You're admin now

Ty, I've just wound down but I'll get it up first thing

@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 27, 2024

@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 27, 2024

Okay this can be merged into production and I can address setting it up or following any pending reviews I can do this. I can only test with my two accounts and both are working fine. A task will need created to address the monster of a test suite that'll be needed for this codebase pretty soon.

There is still some unknowns surrounding setting the webhook and the exact process it goes through when we try. This is something that I'll need more time working on things/reading docs (this aspect surprisingly has very little details) it's unclear if it's CF or TG related but there's a delays and inconsistent outcomes which isn't ideal.

I'll do the merging as I don't think I'll be doing it tonight likely tomorrow.

@Keyrxng Keyrxng changed the title GitHub Storage and DM Notifications DM Notifications Oct 27, 2024
src/adapters/supabase/supabase.ts Outdated Show resolved Hide resolved
src/bot/features/admin/set-webhook.ts Outdated Show resolved Hide resolved
src/bot/features/admin/set-webhook.ts Outdated Show resolved Hide resolved
src/bot/helpers/grammy-context.ts Outdated Show resolved Hide resolved
src/bot/mtproto-api/bot/scripts/sms-auth/auth-handler.ts Outdated Show resolved Hide resolved
src/bot/setcommands.ts Show resolved Hide resolved
src/constants.ts Show resolved Hide resolved
src/types/env.ts Outdated Show resolved Hide resolved
src/types/storage.ts Show resolved Hide resolved
@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 28, 2024

Left it a bit for any other reviews. Going to install this now.

  1. Just realized the details for the storage app I was given are missing one var I need, I've dm'd you @gentlementlegen.
  2. I'm using my Supabase (which is inline with plugin devs running there own but this will move to our github later)
  3. I just ran a fresh set of QA and everything is working well still

Try this. APP_ID and APP_PRIVATE_KEY have now been added to the https://github.com/ubiquity-os-marketplace org secrets.

I'll try just using these instead now that we are allowed to use them, we'll see how it goes.

@Keyrxng Keyrxng merged commit ac855de into ubiquity-os-marketplace:development Oct 28, 2024
1 of 2 checks passed
@0x4007
Copy link
Member

0x4007 commented Oct 30, 2024

Normally the pull should only fix a single issue but since this codebase is young we will let it slide.

@ubiquity-os-beta ubiquity-os-beta bot mentioned this pull request Oct 30, 2024
@Keyrxng
Copy link
Member Author

Keyrxng commented Oct 30, 2024

Normally the pull should only fix a single issue but since this codebase is young we will let it slide.

Pulls will be focused from here on out as we have the foundations sorted

In this repo only I'm going to be merging as I have been the last couple days. I'll request at least one round of reviews and give it time and then go ahead with the merge to keep momentum as well as this is a test-in-prod situation right now.

Can I be made a CODEOWNER on this repo?

@0x4007
Copy link
Member

0x4007 commented Oct 30, 2024

Yes you're admin I think just push to dev to test in prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DM notifications
3 participants