fbchat icon indicating copy to clipboard operation
fbchat copied to clipboard

Consolidate listen events, fetchable events and return types from thread actions

Open madsmtm opened this issue 4 years ago • 0 comments

This is a list of things that happen in threads, that we could parse and return in fetch_messages, that we could return from the relevant methods, and that we could return when listening.

This is mostly here to help myself get an overview of this, because it's something I want to fix for v2.

My idea is that we could make something like this work:

import fbchat
session = fbchat.Session.login('<email>', '<password>')
user = fbchat.User(session=session, id=session.user_id)

# Wave to the user
wave = user.send_wave()
assert isinstance(wave, fbchat.Wave)

# Fetch the latest event in the thread (which would be a wave)
(wave,) = user.fetch_events(limit=1)
assert isinstance(wave, fbchat.Wave)

# Listen to incoming waves
listener = fbchat.Listener(session=session)
@listener.register
def on_wave(wave: fbchat.Wave):
    assert isinstance(wave, fbchat.Wave)
listener.listen()

Possible:

  • [ ] ThreadABC.wave
  • [ ] ThreadABC.send_text
  • [ ] ThreadABC.send_emoji
  • [ ] ThreadABC.send_sticker
  • [ ] ThreadABC.send_location
  • [ ] ThreadABC.send_pinned_location
  • [ ] ThreadABC.send_files
  • [x] ThreadABC.set_nickname
  • [x] ThreadABC.set_color
  • [x] ThreadABC.set_emoji
  • [ ] ThreadABC.create_plan - We won't get an ID after sending
  • [ ] ThreadABC.create_poll
  • [x] Group.add_participants - Though if admin approval is on, it's a little wierd
  • [x] Group.remove_participant
  • [ ] Group.add_admins
  • [ ] Group.remove_admins
  • [x] Group.set_title
  • [ ] Group.set_image - Uses ForcedFetch
  • [ ] Group.set_approval_mode

Impossible in fetch_messages, possible while listening:

  • [x] ThreadABC.start_typing
  • [x] ThreadABC.stop_typing
  • [ ] ThreadABC.mute
  • [ ] ThreadABC.unmute
  • [ ] ThreadABC.mute_reactions
  • [ ] ThreadABC.unmute_reactions
  • [ ] ThreadABC.mute_mentions
  • [ ] ThreadABC.unmute_mentions
  • [ ] Group.deny_users
  • [ ] ThreadABC.mark_as_spam
  • [ ] User.confirm_friend_request
  • [ ] User.block
  • [ ] User.unblock

Fully impossible:

  • [ ] Group.accept_users - Gives the same output as .add_participants
  • [ ] ThreadABC.forward_attachment - You can detect whether the message was forwarded or not, but you can't see the source!
  • [ ] User.remove_friend

madsmtm avatar Jan 20 '20 10:01 madsmtm