static void Main(string[] args) { string communityToken = getValueFromFile("communityToken"); string serviceToken = getValueFromFile("serviceToken"); VkConnection.Initialize(communityToken, serviceToken); var groupId = "191672477"; var topicIdList = new List <string> { "44630960" }; var topicList = topicIdList.Select(topicId => new VkTopic(groupId, topicId)).ToList(); while (true) { NudgeGMs(topicList); System.Threading.Thread.Sleep(60000); } }
public HashSet <string> GetPosterIds() { var posterIds = new HashSet <string>(); var currentLastCommentId = VkConnection.GetLastCommentId(_groupId, _topicId); if (currentLastCommentId == _lastCommentId) { return(posterIds); } var recentCommentList = VkConnection.GetLastComments(_groupId, _topicId, _lastCommentId); System.Console.WriteLine(JsonConvert.SerializeObject(recentCommentList)); foreach (var comment in recentCommentList) { //System.Console.WriteLine(JsonConvert.SerializeObject(comment)); posterIds.Add(comment.FromId.ToString()); } _lastCommentId = currentLastCommentId; return(posterIds); }
static void NudgeGMs(List <VkTopic> topicList) { var playerMasterPairs = new Dictionary <string, string> { { "36344454", "77486691" }, }; foreach (var topic in topicList) { var posterIds = topic.GetPosterIds(); foreach (var posterId in posterIds) { if (playerMasterPairs.ContainsKey(posterId)) { var masterId = playerMasterPairs[posterId]; var messageText = $"Слыш, там это, твой игрок напостил\n{topic.GenerateLink()}"; VkConnection.SendMessage(masterId, messageText); } } } }
public VkTopic(string groupId, string topicId) { _groupId = groupId; _topicId = topicId; _lastCommentId = VkConnection.GetLastCommentId(_groupId, _topicId); }