private void PlayerHandler(object sender, IrcEventArgs e) { var sendto = (string.IsNullOrEmpty(e.Data.Channel)) ? e.Data.Nick : e.Data.Channel; if (e.Data.MessageArray.Length < 2) { return; } RecordValue[][] values; // *** hard coded query *** const bool cacheFlag = false; var ownerIds = new ArrayOfInt(); var queryFields = new ArrayOfString { "row", "Nick", "Pure_PlayerDM_ELO", "Pure_PlayerDM_EVENT_KILLS", "Pure_PlayerDM_EVENT_DEATHS" }; const int surrounding = 0; const int limit = 0; const int offset = 0; const string targetFilter = ""; const string orderBy = "Pure_PlayerDM_ELO desc"; var filter = "Nick LIKE '" + e.Data.MessageArray[1] + "'"; // *** end hard coded query *** EnsureTicket(); try { var searchForRecordsRequest = new SearchForRecordsRequest(new SearchForRecordsRequestBody(Ut3GameId, ticket, StatsTable, queryFields, filter, orderBy, offset, limit, targetFilter, surrounding, ownerIds, cacheFlag)); var recordsResponse = gsStorage.SearchForRecords(searchForRecordsRequest); values = recordsResponse.Body.values; if (recordsResponse.Body.SearchForRecordsResult == Result.Success) { Log.Instance.Log("Webservice returned '" + recordsResponse + "' instead of success.", Level.Fail); return; } } catch (Exception exception) { Log.Instance.Log(exception); return; } foreach (string msg in values.Select(perPlayerValues => RecordValueToString(perPlayerValues[0]) + ". " + RecordValueToString(perPlayerValues[1]) + " ELO: " + RecordValueToString(perPlayerValues[2]) + " Kills: " + RecordValueToString(perPlayerValues[3]) + " Deaths: " + RecordValueToString(perPlayerValues[4]))) { BotMethods.SendMessage(SendType.Notice, sendto, msg); } }
public void SearchForRecords() { var request = new SearchForRecordsRequest(RawRequests.SearchForRecords); request.Parse(); Assert.Equal("0", request.GameId.ToString()); Assert.Equal("XXXXXX", request.SecretKey); Assert.Equal("xxxxxxxx_YYYYYYYYYY__", request.LoginTicket); Assert.Equal("scores", request.TableId); Assert.Equal("", request.Filter); Assert.Equal("", request.Sort); Assert.Equal("0", request.Offset); Assert.Equal("3", request.Max); Assert.Equal("0", request.Surrounding); Assert.Equal("", request.OwnerIds); Assert.Equal("0", request.CacheFlag); Assert.Equal("score", request.Fields[0].FieldName); Assert.Equal("string", request.Fields[0].FiledType); Assert.Equal("recordid", request.Fields[1].FieldName); Assert.Equal("string", request.Fields[1].FiledType); }
private void TopTenHandler(object sender, IrcEventArgs e) { string sendto = (string.IsNullOrEmpty(e.Data.Channel)) ? e.Data.Nick : e.Data.Channel; RecordValue[][] values; // *** hard coded query *** const bool cacheFlag = false; var ownerIds = new ArrayOfInt(); var queryFields = new ArrayOfString { "row", "Nick", "Pure_PlayerDM_ELO", "Pure_PlayerDM_EVENT_KILLS", "Pure_PlayerDM_EVENT_DEATHS" }; const int surrounding = 0; const int limit = 10; const int offset = 0; const string targetFilter = ""; const string orderBy = "Pure_PlayerDM_ELO desc"; const string filter = "NUM_Pure_PlayerDM > 0"; // *** end hard coded query *** EnsureTicket(); try { var searchForRecordsRequest = new SearchForRecordsRequest(new SearchForRecordsRequestBody(Ut3GameId, ticket, StatsTable, queryFields, filter, orderBy, offset, limit, targetFilter, surrounding, ownerIds, cacheFlag)); var recordsResponse = gsStorage.SearchForRecords(searchForRecordsRequest); values = recordsResponse.Body.values; if (recordsResponse.Body.SearchForRecordsResult == Result.Success) { Log.Instance.Log("Webservice returned '" + recordsResponse.Body.SearchForRecordsResult + "' instead of success."); return; } } catch (Exception exception) { Log.Instance.Log(exception); return; } foreach (var msg in values.Select(perPlayerValues => RecordValueToString(perPlayerValues[0]) + ". " + RecordValueToString(perPlayerValues[1]) + " ELO: " + RecordValueToString(perPlayerValues[2]) + " Kills: " + RecordValueToString(perPlayerValues[3]) + " Deaths: " + RecordValueToString(perPlayerValues[4]))) { BotMethods.SendMessage(SendType.Notice, sendto, msg); } }