-
Notifications
You must be signed in to change notification settings - Fork 3
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
V2 init #2
base: development
Are you sure you want to change the base?
V2 init #2
Conversation
Unused files (1)
Unused dependencies (1)
|
rfc @0x4007 @gentlementlegen @rndquu @whilefoo I'll clean up and streamline things a lot if I should continue ahead with this approach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what's going in the code, I'm guessing it's a lot of boilerplate. But the full picture I got is that when issue is created the kernel sends event to this plugin which creates a workroom and deletes it when the issue is deleted.
I also saw there is a telegram webhook, what is the purpose of that?
Let's do individual chat rooms instead of a group with topics. This is to maximize signal to noise. Also the data should not be deleted, instead, the users should be kicked when the project is closed as complete. This is to reduce clutter on one's telegram inbox and search history. If necessary they can always rejoin from the original link. |
@whilefoo sorry mate I had some commits I hadn't pushed but to sum things up so far: This worker is split into two distinct parts. A: A - We are hooked into our BotFather bot and this is the "kernel" for it. So we'll create all commands, functions etc through this worker which is separate from but able to interact with the plugin side. B - We are also hooked into the kernel as a plugin and in this PR you see the callbacks relating to the "workrooms" feature only.
Yeah still a little bit of boilerplate and a few helper commands I've added for setup idk if they'll be kept. I expected that if this PR progressed I'd need to build in basic commands and features so I haven't cleaned up completely.
This feature aside, it'll house all telegram bot chat commands and features etc. The task discussion lays out a spec to enable the opening of new group chats from a personal account vs this implementation which is using a main supergroup and opening forums (topics). I spent hours trying various libs and approaches and decided to progress everything else and either it can be tasked out or if it's a blocker more time spent on it. Here is the troubles with that so far:
|
Only saw this after posting my comment above. Agreed, no chats are deleted. I mentioned my troubles with the MTProto API so far and tried all that I could think over the weekend but had very little luck and it involved a lot of "hacks" like patching node_modules because cloudflare wants any Node module prefixed with "node:" for a start, then the methods differ etc. Anyway, I'll spend more time on it if need be but in regards to everything else, the way it communicates with the kernel and the way I have built callbacks and what that means for adding additional "plugin"-like features that respond to events, happy for me to proceed with this approach? |
Why not make some sort of GitHub actions based micro service that just opens chat rooms? It sounds to me that cloudflare is limiting this due to incompatible node modules. |
I had considered that we'd likely use the workflows and the worker in unison depending on what sort of features we add but hadn't considered it for this feature but I will attempt to do that although it probably isn't pretty.
I'll see how I get on with it and report back |
Why does the worker need to start the workflow, the kernel can directly start the workflow? Actually is there any reason why even use a worker if we move everything to the workflow? |
Eventually the bot should reply to messages on Telegram, so building for speed is important. |
The workflow is a tool that the worker will use, it is not replacing the worker instance. So it would be a workflow which handles one action: create a group chat using MTProto API. The cf worker can dispatch to it's own repo to execute functions using a different env than what cf provides, which if it works could be awesome.
So this worker would repo_dispatch to it's own repo to execute the
This is how I thought of things. If this plugin is a worker we have instant response on the telegram and github side instead of having a dedicated worker just handling telegram requests and us building plugins/features as plugins which interact with the telegram bot. While also having the benefit of dispatching workflows to it's own repo although I thought that would be much further down the line lol |
Using YAML anchors is our solution. When will this be merged @Keyrxng ? |
Merged hopefully before the beginning of next week, I'll be working on this for the rest of today.
I'm pretty sure that it was me that deleted those two comments, what's going on there any ideas? |
Just focus on this no other tasks. You have too many pulls open for weeks on end (I've seen some for months) and none get merged so nothing is getting done. |
Who is handling deployment, myself? Tried anchors and I don't think the kernel is built for them, I tried a bunch of different configurations. Altering the URL only would cause the |
This is QA-able/mergeable by the way, everything working fine for me locally and deployed to CF. |
it's not a feature of the kernel, but of YAML 1.2, which our parser supports |
Fix knip and delete the tests so you can pass CI Then merge and lets try in production Eventually we can use my https://t.me/UbiquityOS account but that will require me to set up the secrets and such which we can handle later |
This is a new thing for me but I realize that the kernel does support it and perhaps my wording was incorrect. I did attempt it's last suggestion but as I said the YAML processor pulled in the entire anchor and not just the
Cool so we'll use the |
Can you get this running in production today? |
Should be able to as I said everything is working for me. @gentlementlegen did you manage to QA and get it deployed etc? https://t.me/UbiquityOS_Beta_Bot - is currently deployed to my cloudflare, message it with |
You can do like this: plugins:
- uses:
- plugin: https://test.workers.dev
with: &with
botId: 123456
- uses:
- plugin: ubiquity-os/test
with: *with |
Ik that is what I realized but 1. It's not what we originally intended which was to just change the URL and 2. because it only has one "with" prop it felt like it was exactly the same as just pasting the plugin twice and changing only the url. If we added more settings then I guess it would make more sense to use anchors.
|
I'm not able to deploy or interact with the official workers so I won't be able to deploy to production, at best I might be able to use my worker and my workflow url installed in the official config but it's improper and I'd prefer if it was deployed officially as it caused some confusion when I did it previously for embeddings. This plugin' setup requirements are a little (I'm not sure of the word to use) sketchy so it makes me more anxious as I can't debug CF or set env vars etc the best I can do is help whoever is going to deploy it to prod (I've tried to make it as well-documented and as easy as I could) so if any questions or help is needed msg me here or on TG, thank you. It'll be smoother I think if it's deployed manually during reviewer QA that way all of the variables are already set, session is active etc and when this is merged and the |
Every repo here automatically deploys to our Cloudflare Workers on push.
|
So long as the repo secrets are set correctly the workflow pushes them when deploying so things should be okay once past the initial setup. Anyone that wants the
|
Resolves ubiquity-os/plugins-wishlist#25
Required by #1
Dual action/worker plugin serving as Telegram Bot kernel and an UbiquityOS plugin.
The worker instance runs with GrammyJS and Hono, supporting the Bot API methods and features.
The action instance runs with GramJS, supporting personal account methods and features.
Creating a workroom
Closing a workroom
Closing a workroom with rate limit handling
Reopening a workroom
Requirements
Config:
repo
scoped.api_hash
andapp_id
.yarn setup-env
: It'll run through each set of env vars, store and upload them. Enter 0 forBOT_ADMINS
for now, don't wrap input in quotes and if you need to run it more than once and you are copy pasting from.dev.vars
you should sanitize the additional\
applied to line breaks in the private key.yarn sms-auth
: It'll ask for details via the terminal, store the session and exit.smee -u <url> -P "/webhook"
in terminal Byarn worker
: should be working at this point. Speak to your bot on TG and use/setcommands
.If you have any issues at this stage let me know please.
To use the workflow functions simply create a new task in a repo and assign a price label. Check the actions tab of the
telegram-bot
repo and wait. Close, repeat. Reopen, repeat.Everything should be running smoothly. I E2E tested with new DBs etc a couple of times so hopefully there is no issues for anyone testing.
Features
Commands
/setcommands
- private, admin/chatid
- private, groups/botid
- private/myid
- privateWorkflow functions
create-chat
: Creates a workroom per task once price labeled.@org/repo#1
url schema and posts an invite link on the taskclose-chat
: Kicks everyone once the task is closed, archives the chat and snapshots userIds.reopen-chat
: Unarchives the chat, re-invites everyone previously involved.Environment helpers
setup-env
: Uses the CLI to walk through savingenv
vars locally and pushing them to repo secrets.sms-auth
: Requires the personal account holder to create a session via 2FA confirmed via a Telegram client, i.e you'll get a desktop notification from TG with the code.