Пример #1
0
        public async Task <ChannelInformations> ChannelInformations(string displayname)
        {
            if (string.IsNullOrWhiteSpace(displayname))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(displayname));
            }

            GraphQL.GraphQLClient.GraphQLQueryResult obj = await DLive.GraphQL.QueryAsync(_accessKey,
                                                                                          Querys.LivestreamPage,
                                                                                          new Dictionary <object, object>
            {
                { "displayname", displayname },
                { "add", false },
                { "isLoggedIn", true }
            });

            if (obj.GetData() == null)
            {
                throw new InvalidOperationException("Unable to read the result from ChannelInformations");
            }

            string data = obj.GetData().ToString();

            return(Classes.ChannelInformations.FromJson(data));
        }
Пример #2
0
        public async Task <SendMessage> SendMessageToChannel(string displayname, string message)
        {
            if (string.IsNullOrWhiteSpace(displayname))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(displayname));
            }
            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(message));
            }

            GraphQL.GraphQLClient.GraphQLQueryResult obj = await DLive.GraphQL.QueryAsync(_accessKey,
                                                                                          Querys.SendStreamchatMessage,
                                                                                          new Dictionary <object, object>
            {
                {
                    "input", new Dictionary <object, object>
                    {
                        {
                            "streamer",
                            new Util(_displayname, _accessKey).GetBlockchainNameFromDisplayName(displayname).Result
                        },
                        { "message", message },
                        { "roomRole", "Owner" },
                        { "subscribing", true }
                    }
                }
            });

            if (obj.GetData() == null)
            {
                throw new InvalidOperationException("Unable to read the result from SendMessage");
            }

            var data = obj.GetData();

            if (data.err != null)
            {
                return new SendMessage
                       {
                           Success = false,
                           Error   = data.err.ToString()
                       }
            }
            ;

            return(new SendMessage {
                Success = true, Id = data.sendStreamchatMessage.message.id
            });
        }
    }
Пример #3
0
        internal async Task <string> GetChannelName()
        {
            GraphQL.GraphQLClient.GraphQLQueryResult obj = await DLive.GraphQL.QueryAsync(_accessKey,
                                                                                          Querys.LivestreamPage,
                                                                                          new Dictionary <object, object>
            {
                { "displayname", _displayname },
                { "add", false },
                { "isLoggedIn", true }
            });

            if (obj.GetData() == null)
            {
                throw new InvalidOperationException("Unable to read the result from ChannelInformations");
            }

            string data = obj.GetData().ToString();

            return(Classes.ChannelInformations.FromJson(data).UserByDisplayName.Displayname);
        }
Пример #4
0
        public async Task <ChatDelete> DeleteChatMessage(string displayname, string messageId)
        {
            if (string.IsNullOrWhiteSpace(displayname))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(displayname));
            }
            if (string.IsNullOrWhiteSpace(messageId))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(messageId));
            }

            GraphQL.GraphQLClient.GraphQLQueryResult obj =
                await DLive.GraphQL.QueryAsync(_accessKey, Querys.DeleteChat,
                                               new
            {
                streamer = new Util(_displayname, _accessKey).GetBlockchainNameFromDisplayName(displayname)
                           .Result,
                id = messageId
            });

            if (obj.GetData() == null)
            {
                throw new InvalidOperationException("Unable to read the result from DeleteChatMessage");
            }

            var data = obj.GetData();

            if (data.err != null)
            {
                return new ChatDelete
                       {
                           Success = false,
                           Error   = data.err.message.ToString()
                       }
            }
            ;
            return(new ChatDelete {
                Success = true
            });
        }
    }
Пример #5
0
        public async Task <Unfollow> UnfollowUser(string displayname)
        {
            if (string.IsNullOrWhiteSpace(displayname))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(displayname));
            }

            GraphQL.GraphQLClient.GraphQLQueryResult obj = await DLive.GraphQL.QueryAsync(_accessKey,
                                                                                          Querys.UnfollowUser,
                                                                                          new Dictionary <object, object>
            {
                {
                    "input", new Dictionary <object, object>
                    {
                        { "streamer", new Util(_displayname, _accessKey).GetBlockchainNameFromDisplayName(displayname).Result }
                    }
                }
            });

            if (obj.GetData() != null)
            {
                var data = obj.GetData();
                if (data.err != null)
                {
                    return new Unfollow
                           {
                               Success = false,
                               Error   = data.err.ToString()
                           }
                }
                ;
                return(new Unfollow {
                    Success = true
                });
            }

            throw new InvalidOperationException("Unable to read the result from UnfollowUser");
        }
    }