Beispiel #1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            var accessToken = AccessTokenContainer.GetToken(_corpId);

            string[] users = { "xiaobao", "orochi430", "xiaoze" };
            ChatApi.CreateChat(accessToken, "mychart", "测试会话", "orochi430", users);
        }
Beispiel #2
0
        public void CreateChatTest()
        {
            var accessToken = AccessTokenContainer.GetToken(_corpId, base._corpSecret);

            var result = ChatApi.CreateChat(accessToken, "1", "测试", "005", new[] { "002", "005", "007" });

            Assert.IsTrue(result.errcode == ReturnCode_Work.请求成功);
        }
Beispiel #3
0
        public void QuitChatTest()
        {
            var accessToken = AccessTokenContainer.GetToken(_corpId, base._corpSecret);

            var result = ChatApi.QuitChat(accessToken, "1", "007");

            Assert.IsTrue(result.errcode == ReturnCode_Work.请求成功);
        }
Beispiel #4
0
 public void Say(Client sender, string message)
 {
     if (!sender.IsAdmin())
     {
         API.sendNotificationToPlayer(sender, "~r~ERRO: ~w~Você não tem permissão.");
         return;
     }
     ChatApi.SendClientMessageToAll($"~o~* Admin {sender.name} diz: ~w~{message}", "Global");
 }
Beispiel #5
0
        public void ChatUpdateShouldCallCorrectEndpoint()
        {
            var requestHandlerMock = PathAndExecRequestMock<ChatUpdateResponse>("/chat.update?channel=foo&ts=1111.2222&text=bar");

            var subject = new ChatApi(requestHandlerMock.Object);
            var result = subject.Update("foo", "1111.2222", "bar");

            requestHandlerMock.Verify();
            Assert.NotNull(result);
        }
Beispiel #6
0
        public void SendChatMessageTest()
        {
            var accessToken = AccessTokenContainer.GetToken(_corpId);

            var result = ChatApi.SendChatMessage(accessToken, "005", Chat_Type.@single, ChatMsgType.image, "002", "1-GdQZtyp-8G8i-UwC0qh0yDQch5wqso5MTus37CLlu72PIyHEYUFvo9oHYRifvKo4hYgAc6GEA4qxP8tlJd2rA");

            ChatApi.SendChatMessage(accessToken, "005", Chat_Type.@group, ChatMsgType.text, "1", "111");

            Assert.IsTrue(result.errcode == ReturnCode_QY.请求成功);
        }
Beispiel #7
0
        public void ChatUpdateShouldCallCorrectEndpoint()
        {
            var requestHandlerMock = PathAndExecRequestMock <ChatUpdateResponse>("/chat.update?channel=foo&ts=1111.2222&text=bar");

            var subject = new ChatApi(requestHandlerMock.Object);
            var result  = subject.Update("foo", "1111.2222", "bar");

            requestHandlerMock.Verify();
            Assert.NotNull(result);
        }
Beispiel #8
0
        public void SendChatSimpleMessageTest()
        {
            var accessToken = AccessTokenContainer.GetToken(_corpId, base._corpSecret);

            var result = ChatApi.SendChatSimpleMessage(accessToken, "1", ChatMsgType.image, "1-GdQZtyp-8G8i-UwC0qh0yDQch5wqso5MTus37CLlu72PIyHEYUFvo9oHYRifvKo4hYgAc6GEA4qxP8tlJd2rA");

            ChatApi.SendChatSimpleMessage(accessToken, "1", ChatMsgType.text, "111");

            Assert.IsTrue(result.errcode == ReturnCode_Work.请求成功);
        }
Beispiel #9
0
        public void ClearChat(Client sender)
        {
            if (!sender.IsAdmin())
            {
                API.sendNotificationToPlayer(sender, "~r~ERRO: ~w~Você não tem permissão.");
                return;
            }

            ChatApi.ClearAllChat();
            API.sendNotificationToAll("O chat foi limpo por um admin");
        }
Beispiel #10
0
        public static void sendChatAction(this Client player, string action, int style = 0)
        {
            var msg     = (style == 0) ? $"~p~* {player.name} {action}" : $"~p~* {action} (({player.name}))";
            var players = API.shared.getPlayersInRadiusOfPlayer(15f, player);

            foreach (var p in players)
            {
                if (p.dimension != player.dimension)
                {
                    continue;
                }
                ChatApi.SendClientMessage(p, msg, "Local");
            }
        }
Beispiel #11
0
        public void ChatPostMessageShouldCallCorrectEndpoint()
        {
            var requestHandlerMock = ExecRequestMock <MessageResponse>("/chat.postMessage", new MessageResponse {
                Ok = true
            });
            var responseParserMock = new Mock <IResponseParser>();

            responseParserMock.Setup(r => r.RemapMessageToConcreteType(It.IsAny <MessageBase>()))
            .Returns(new MessageBase())
            .Verifiable();

            requestHandlerMock.Setup(r => r.ResponseParser)
            .Returns(responseParserMock.Object)
            .Verifiable();

            var request = new PostMessageRequest
            {
                Channel     = "foo",
                Parse       = ParseMode.Full,
                Attachments = new List <Attachment>
                {
                    new Attachment
                    {
                        Text   = "Attach1",
                        Fields = new List <Field>
                        {
                            new Field {
                                Title = "F1", Value = "V1"
                            },
                            new Field {
                                Title = "F2", Value = "V2"
                            },
                        }
                    }
                }
            };

            requestHandlerMock.Setup(r => r.BuildRequestParams(request))
            .Returns <Dictionary <string, string> >(null)
            .Verifiable();

            var subject = new ChatApi(requestHandlerMock.Object);
            var result  = subject.PostMessage(request);

            requestHandlerMock.Verify();
            responseParserMock.Verify();
            Assert.NotNull(result);
        }
Beispiel #12
0
        public void PrivateMessage(Client sender, Client target, string message)
        {
            if (!sender.IsAdmin())
            {
                API.sendNotificationToPlayer(sender, "~r~ERRO: ~w~Você não tem permissão.");
                return;
            }

            else if (!target.isLogged())
            {
                API.sendNotificationToPlayer(sender, "~r~ERRO: ~w~O jogador não está conectado.");
            }
            else
            {
                ChatApi.SendClientMessage(target, $"~y~PM de {target.name}: {message}", "Admin");
                ChatApi.SendClientMessage(sender, $"~y~PM para {target.name}: {message}", "Admin");
            }
        }
Beispiel #13
0
        public void ChatPostMessageShouldCallCorrectEndpoint()
        {
            var requestHandlerMock = ExecRequestMock<MessageResponse>("/chat.postMessage", new MessageResponse { Ok = true });
            var responseParserMock = new Mock<IResponseParser>();

            responseParserMock.Setup(r => r.RemapMessageToConcreteType(It.IsAny<MessageBase>()))
                              .Returns(new MessageBase())
                              .Verifiable();

            requestHandlerMock.Setup(r => r.ResponseParser)
                              .Returns(responseParserMock.Object)
                              .Verifiable();

            var request = new PostMessageRequest
            {
                Channel = "foo",
                Parse = ParseMode.Full,
                Attachments = new List<Attachment>
                {
                    new Attachment
                    {
                        Text = "Attach1",
                        Fields = new List<Field>
                        {
                            new Field { Title = "F1", Value = "V1" },
                            new Field { Title = "F2", Value = "V2" },
                        }
                    }
                }
            };

            requestHandlerMock.Setup(r => r.BuildRequestParams(request))
                              .Returns<Dictionary<string, string>>(null)
                              .Verifiable();

            var subject = new ChatApi(requestHandlerMock.Object);
            var result = subject.PostMessage(request);

            requestHandlerMock.Verify();
            responseParserMock.Verify();
            Assert.NotNull(result);
        }
Beispiel #14
0
        public static ChannelUi CreateChannelUi(ChatApi chatApi,GameObject gameObject, string channelName, string uiType)
        {
            DestroyChannelUi (channelName);

            GameObject uiObject = new GameObject (channelName);
            ChannelUi ui = uiObject.AddComponent<ChannelUi> () as ChannelUi;
            ui.chatApi = chatApi;
            ui.windowId = nextWindowId;
            nextWindowId += 1;
            ui.name = channelName;
            ui.channelName = channelName;
            ui.uiType = uiType;
            ui.title = uiType;
            ui.buttonName = "Leave " + ui.uiType;
            channelUis [channelName] = ui;
            ui.InvokeRepeating ("UpdateMembers", 0.01f, 1.0F);
            chatApi.ChannelWindowOpened();

            return ui;
        }
Beispiel #15
0
        public LeagueClientApi()
        {
            HttpClient = new LeagueHttpClient();

            Assets         = new AssetsApi(HttpClient);
            ChampSelect    = new ChampSelectApi(HttpClient);
            Chat           = new ChatApi(HttpClient);
            DataStore      = new DataStoreApi(HttpClient);
            GameData       = new GameDataApi(HttpClient);
            Inventory      = new InventoryApi(HttpClient);
            ItemSets       = new ItemSetsApi(HttpClient);
            Login          = new LoginApi(HttpClient);
            Matchmaking    = new MatchmakingApi(HttpClient);
            Missions       = new MissionsApi(HttpClient);
            Performance    = new PerformanceApi(HttpClient);
            Perks          = new PerksApi(HttpClient);
            PlayerBehavior = new PlayerBehaviorApi(HttpClient);
            RiotClient     = new RiotClientApi(HttpClient);
            Summoner       = new SummonerApi(HttpClient);
            System         = new SystemApi(HttpClient);
        }
Beispiel #16
0
 public void Init()
 {
     instance = new ChatApi();
 }
Beispiel #17
0
 public void SetChatApi(ChatApi chatApi)
 {
     this.chatApi = chatApi;
     groupName = "priv_" + chatApi.ChatUser() + "_group";
 }
Beispiel #18
0
        public static Uri GetProxyAddress(ServiceContext context)
        {
            Uri serviceName = ChatApi.GetChatDataServiceName(context);

            return(GetProxyAddress(serviceName));
        }
Beispiel #19
0
        public async static Task <ServicePartitionList> GetAllPartitions(ServiceContext context, FabricClient fabricClient)
        {
            Uri serviceName = ChatApi.GetChatDataServiceName(context);

            return(await fabricClient.QueryManager.GetPartitionListAsync(serviceName));
        }
Beispiel #20
0
 public static ChatManagerOld Create(GameObject go, ChatApi chatApi)
 {
     ChatManagerOld chatManager = go.AddComponent<ChatManagerOld>();
     chatManager.Init(chatApi);
     return chatManager;
 }
Beispiel #21
0
        public void Init(ChatApi chatApi)
        {
            this.chatApi = chatApi;
            // Gui component.
            chatbox = this.gameObject.AddComponent<Chatbox>() as Chatbox;
            chatbox.CloseChatWindow();

            // The messaging actor
            messenger = ActorSystem.instance.Find("Messenger") as Messenger;

            // Parses the chat language used by the gui and calls messenger
            // Feel free to provide your own implementation, this is mostly a starting point.
            // Supported syntax is documented in the source
            chatCommands = new ChatCommands(messenger, chatbox);
            chatCommands.SetChatApi(chatApi);

            // Setup callacks so we get notified when we join/leave channels and receive messages
            Messenger.ChannelJoined channelCallback = ChannelJoined;
            messenger.OnChannelJoined(channelCallback);

            Messenger.ChannelLeft channelLeftCallback = ChannelLeft;
            messenger.OnChannelLeft(channelLeftCallback);

            Messenger.MessageReceived messageCallback = MessageReceived;
            messenger.OnMessageReceived(messageCallback);

            Messenger.InviteReceived inviteCallback = InviteReceived;
            messenger.OnInviteReceived(inviteCallback);

            // Send this whenever you want a list of subscribed channels, and the optional
            // subscriber list if you have set the subscribers flag.  We do it on an interval
            // so that you get notified when new players join a group you are in.
            // For matchmaking you probably want this value lower so it appears more
            // responsive.  For mmo type games it could be somewhat higher.
            InvokeRepeating("UpdateChatStatus", 0.01f, 5.0F);
        }