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

refactor and more chat types #1

Closed
wants to merge 2 commits into from
Closed

refactor and more chat types #1

wants to merge 2 commits into from

Conversation

dcdunkan
Copy link
Owner

@dcdunkan dcdunkan commented Sep 21, 2022

BREAKING changes to everything, new chat types, proper API responses (fully dynamic 🔥) and re-write of the entire library.

For the biggest changes, see src/chats.ts.

This pull request will be inactive for a few months due to my unavailability. Expecting to continue working on this about April 2023. If someone is interested in finishing the rest of the work, feel free to do so. (You can PR to this branch - refine - as well)

notes

Had to change the whole environment abstraction a few times to end up with the current one. I think this is the perfect one. It has a environment, the bot and its test user/chat type lives in. All bot responses (methods called to the Bot API server) are handled globally in the environment. But chat type related update senders are defined in the chat types themselves.

A few of the TODO items. For more lists, just search "TODO" in the code, I've left a few in several places; few of the important ones can also be found on the src/chats.ts file.

  • Refactor User type
  • Sync invite links, etc
  • Payload (type) validation
  • Expiry, until_date value checker.
  • Simulate the limits of both bot and users.

Hopefully, I could make the following syntax possible in this library. I see a way for it, so it should be possible.

import { bot } from "./bot.ts";
const chats = new Chats<MyContext>(bot); // Can have options
const user = chats.newUser({ /* */ }); // Registers a new user

// FEW METHODS I'D LIKE TO ADD
// chat types created by an user. makes them
// owner of the chat type.
const group0 = user.createGroup(); // also, channel, supergroup
const channel0 = user.createChannel();
// chat types can also be created like:
chats.newGroup(); chats.newSupergroup(); chats.newChannel();

user.in(group)
  .as(channel)
  .sendMessage("Message");

const userAsChannel = user.as(channel);
const userInGroup = user.in(group);
userInGroup.sendMessage("Hi everyone");

A /cc to @KnorpelSenf if you're interested.

@dcdunkan dcdunkan self-assigned this Sep 21, 2022
@dcdunkan dcdunkan changed the title refactor: Everything and more chat types refactor everything and introduce more chat types Sep 25, 2022
@dcdunkan dcdunkan changed the title refactor everything and introduce more chat types refactor * and introduce more chat types Sep 25, 2022
@dcdunkan dcdunkan changed the title refactor * and introduce more chat types refactor and more chat types Oct 4, 2022
@dcdunkan dcdunkan mentioned this pull request Mar 13, 2023
@dcdunkan
Copy link
Owner Author

Closing in favor of #2. Not deleting the branch right now, because it should exist for reference and as an example of a failed design.

@dcdunkan dcdunkan closed this Mar 13, 2023
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.

None yet

1 participant