-
Notifications
You must be signed in to change notification settings - Fork 5
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
V2 init #2
Conversation
Unused devDependencies (2)
|
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 |
I don't understand how they two items are related and why it prevented you from logging in when it never stopped me before. I will keep as a migration and properly name it.
Will do. Glad to hear you are now set up. |
It stopped me from logging in because the migration for |
Ah okay so it skipped it because you ran SB locally my bad, I assumed you'd use the UI my mistake. With the Supabase CLI I get a successful run of Since I do not ever use Supabase this way, what do you expect to see in regards to how the local SB stuff should work? The default |
I guess you are using windows if you get an error with the healthcheck. You have to opt out from the analytics in the toml and everything will be running. |
much obliged fellow hipster |
The error remained but I gathered it's OS or my sys related so I moved on. I was able to setup a local DB so it appears to be working |
@Keyrxng I think I have the full setup, I changed my configuration file and all that the kernel does when I try to use the command |
That's a telegram bot command, send that to your bot father bot on tg. Only issues.labelled | closed | reopen will trigger a workflow function. The worker should respond to any bot command in the readme, you may have to use /setcommands on the tg bot too I am not sure re: payload logging I will look into it first thing |
Should I make a task and create a setup tutorial, showing e2e functionality with videos, would that be beneficial? Should I make a task and create a test suite that covers GitHub and both TG apis and start to work on that? |
I think having the full list of steps numbered that ensure a successful setup would be enough. Sorry I'll test again the setup, working on multiple things. |
I confirm it works. I got a room chat created on issue creation: |
@gentlementlegen #3 removes the Supabase dependency completely and will be merged very soon, considering this should I still add your request? |
@Keyrxng then that is fine. |
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.
We will need to add the manifest action later on for this to have the configuration checked by the kernel.
@Keyrxng I get this error when I put a label on an issue: [2024-10-07T20:27:25.477] [INFO] - [Running gramJS version 2.24.10]
[2024-10-0[7](https://github.com/ubiquity-whilefoo/telegram-bot/actions/runs/11223403676/job/31197960956#step:6:8)T20:27:25.480] [INFO] - [Connecting to 149.154.167.91:80/TCPFull...]
[2024-10-07T20:27:25.5[8](https://github.com/ubiquity-whilefoo/telegram-bot/actions/runs/11223403676/job/31197960956#step:6:9)3] [INFO] - [Connection to 149.154.167.91:80/TCPFull complete!]
[2024-10-07T20:27:25.584] [INFO] - [Using LAYER 184 for initial connect]
› Creating chat with name:
› {
"chatName": "@ubiquibot-whilefoo-testing/testing#1",
"caller": "createChat"
}
› ↳ <anonymous> (/home/runner/work/telegram-bot/telegram-bot/src/handlers/workflow-proxy.ts:28:[9](https://github.com/ubiquity-whilefoo/telegram-bot/actions/runs/11223403676/job/31197960956#step:6:10))
⚠ Error in creating chat:
⚠ {
"er": {},
"caller": "createChat"
}
⚠ ↳ <anonymous> (/home/runner/work/telegram-bot/telegram-bot/src/handlers/workflow-proxy.ts:28:9) https://github.com/ubiquity-whilefoo/telegram-bot/actions/runs/11223403676/job/31197960956 |
77a12d5
into
ubiquity-os-marketplace:development
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.