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

Get messages from channel. #10

Open
shmueldw opened this issue Nov 26, 2019 · 2 comments
Open

Get messages from channel. #10

shmueldw opened this issue Nov 26, 2019 · 2 comments

Comments

@shmueldw
Copy link

shmueldw commented Nov 26, 2019

Hi, Thank you a lot for your library

I created Coordinator with my API_ID and API_HASH
let coordinator = Coordinator(client: TDJsonClient(), apiId: myAppId, apiHash: myApiHash)
I want to listening for new messages for one of my channels and perform some job base on this message.
Can you please give me some example code to start. (I read the documentation, but it still not so clear for me. )

Thanks

@leoMehlig
Copy link
Owner

You can subscribe to the Coordinator.updateStream and wait for newMessage events to come in. There you get a message. You can probably figure out if this is a new message from your channel. Let me know if you have any more questions...

@shmueldw
Copy link
Author

My Code:

let coordinator = Coordinator(client: TDJsonClient(), apiId: 119..., apiHash: "e874...")
        coordinator.updateStream.subscribe(on: .global()) { data in
            print("data: \(data)")
        }

Output:
data: Optional(TDLib.Update.authorizationState(authorizationState: TDLib.AuthorizationState.waitTdlibParameters))
data: Optional(TDLib.Update.option(name: "test_mode", value: TDLib.OptionValue.boolean(value: false)))
data: Optional(TDLib.Update.option(name: "calls_enabled", value: TDLib.OptionValue.boolean(value: false)))
data: Optional(TDLib.Update.option(name: "t_me_url", value: TDLib.OptionValue.string(value: "https://t.me/")))
data: Optional(TDLib.Update.option(name: "message_caption_length_max", value: TDLib.OptionValue.integer(value: 1024)))
data: Optional(TDLib.Update.option(name: "pinned_chat_count_max", value: TDLib.OptionValue.integer(value: 5)))
data: Optional(TDLib.Update.option(name: "favorite_stickers_limit", value: TDLib.OptionValue.integer(value: 5)))
data: Optional(TDLib.Update.option(name: "venue_search_bot_username", value: TDLib.OptionValue.string(value: "foursquare")))
data: Optional(TDLib.Update.option(name: "photo_search_bot_username", value: TDLib.OptionValue.string(value: "bing")))
data: Optional(TDLib.Update.authorizationState(authorizationState: TDLib.AuthorizationState.waitEncryptionKey(isEncrypted: true)))
data: Optional(TDLib.Update.option(name: "supergroup_size_max", value: TDLib.OptionValue.integer(value: 200000)))
data: Optional(TDLib.Update.option(name: "call_packet_timeout_ms", value: TDLib.OptionValue.integer(value: 10000)))
data: Optional(TDLib.Update.option(name: "call_connect_timeout_ms", value: TDLib.OptionValue.integer(value: 30000)))
data: Optional(TDLib.Update.option(name: "animation_search_bot_username", value: TDLib.OptionValue.string(value: "gif")))
data: Optional(TDLib.Update.option(name: "forwarded_message_count_max", value: TDLib.OptionValue.integer(value: 100)))
data: Optional(TDLib.Update.authorizationState(authorizationState: TDLib.AuthorizationState.waitPhoneNumber))
data: Optional(TDLib.Update.selectedBackground(forDarkTheme: false, background: nil))
data: Optional(TDLib.Update.selectedBackground(forDarkTheme: true, background: nil))
data: Optional(TDLib.Update.option(name: "message_text_length_max", value: TDLib.OptionValue.integer(value: 4096)))
data: Optional(TDLib.Update.option(name: "basic_group_size_max", value: TDLib.OptionValue.integer(value: 200)))
data: Optional(TDLib.Update.option(name: "expect_blocking", value: TDLib.OptionValue.boolean(value: false)))
data: Optional(TDLib.Update.connectionState(state: TDLib.ConnectionState.connecting))

I don't have any messages in updateStream. Please help. Have I set the phone number using some method?

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

No branches or pull requests

2 participants