示例#1
0
        public bool OnInput(string command, string[] args)
        {
            var woorden = GetVerbodenWoordCollection().Find(x => true).OrderBy(x => x.CreationDate).ToList();

            foreach (var w in woorden)
            {
                var str = string.Join(", ", w.Woorden);
                Console.WriteLine($"- {w.ID} : {TimeService.AsReadableTimespan(DateTime.UtcNow - w.CreationDate)} oud van {w.OwnerName} [#{w.OwnerUserId}]");
                Console.WriteLine($"  Woorden: {str}");
                Console.WriteLine($"  Reply: {w.ReplyChatID} {w.ReplyMessageID}");
            }
            return(true);
        }
示例#2
0
        private void InsultUserForCopyPasting(PublicMessageEventArgs e, MessageHash hashRecord)
        {
            string[] allReplies = System.IO.File.ReadAllLines("taunts.duplicate.txt").Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
            string   replyFmt   = allReplies[_rnd.Next(allReplies.Length)];
            string   replyStr   = String.Format(replyFmt,
                                                MessageUtils.HtmlEscape(hashRecord.User.ShortName()),                 // {0}
                                                TimeService.AsReadableTimespan(DateTime.UtcNow - hashRecord.UtcWhen), // {1}
                                                MessageUtils.HtmlEscape(e.Message.From.ShortName()),                  // {2}
                                                hashRecord.MessageID,                                                 // {3}
                                                hashRecord.ChatID                                                     // {4}
                                                );

            _log.Info($"{e.Message.From.ShortName()} just duplicated {hashRecord.User.ShortName()}'s message and got abused with reply {replyStr}");
            Client.SendMessageToChat(e.Message.Chat.ID, replyStr, "HTML", true, false, e.Message.MessageID);
        }
        private void CalculateParticipationBlock(RaidParticipation raid, StringBuilder sb, out string tps)
        {
            var           userSettingsCollection = DB.GetCollection <UserSettings>();
            List <string> tpsElements            = new List <string>();

            tps = String.Empty;
            int counter = 0;

            foreach (Team team in raid.Participants.Keys.OrderBy(x => x))
            {
                var participants = raid.Participants[team];
                if (participants.Count > 0)
                {
                    sb.AppendLine();
                    sb.AppendLine($"<b>{team.AsReadableString()} ({participants.Select(x => 1 + x.Extra).Sum()}):</b>");

                    foreach (UserParticipation userParticipation in participants.OrderBy(p => p.User.ShortName()))
                    {
                        string       name       = userParticipation.User.ShortName().TrimStart('@');
                        UserSettings userRecord = userSettingsCollection.Find(x => x.User.ID == userParticipation.User.ID).FirstOrDefault();

                        if (!String.IsNullOrWhiteSpace(userRecord?.Alias))
                        {
                            name = userRecord.Alias;
                        }

                        if (userRecord?.Level > 0)
                        {
                            name += $" (" + this._HTML_(I18N.GetString("level")) + $" {userRecord?.Level})";
                        }

                        sb.Append($" - {MessageUtils.HtmlEscape(name)}");

                        if (userParticipation.Extra > 0)
                        {
                            counter += userParticipation.Extra;
                            sb.Append($" +{userParticipation.Extra}");
                        }

                        if (userParticipation.UtcArrived != default)
                        {
                            // Text and plural text are the same in this case.
                            string arrivedAtString = this._HTML_(I18N.GetPluralString("there for {0}", "there for {0}", userParticipation.Extra + 1,
                                                                                      TimeService.AsReadableTimespan(DateTime.UtcNow - userParticipation.UtcArrived)));

                            sb.Append($" [{arrivedAtString}]");
                        }
                        else if (userParticipation.UtcWhen != default)
                        {
                            sb.Append($" [{TimeService.AsShortTime(userParticipation.UtcWhen)}]");
                        }

                        if (userParticipation.Type != default)
                        {
                            sb.Append($" {this.GetParticipationTypeTitle(userParticipation.Type)}");
                        }

                        sb.AppendLine();
                    }
                }
                tpsElements.Add($"{participants.Sum(x => 1 + x.Extra)}{team.AsIcon()}");
                counter += participants.Count;
            }

            var tpsSub = string.Join(" ", tpsElements);

            tps = $"{counter} ({tpsSub})";
        }
示例#4
0
        private void TriggerRandomMatchingRecord(PublicMessageEventArgs e, DbSet <VerbodenWoordData> verbodenWoordCollection, List <VerbodenWoordData> matchingRecords)
        {
            var selectedIndex = _rnd.Next(matchingRecords.Count);
            var match         = matchingRecords[selectedIndex];

            verbodenWoordCollection.Delete(x => x.UniqueID == match.UniqueID);

            var    age     = DateTime.UtcNow - match.CreationDate;
            string message = $"Een verboden woord [{string.Join(", ", match.Woorden.Select(w => MessageUtils.HtmlEscape(w)))}] is geraden door {MessageUtils.HtmlEscape(e.Message.From.DisplayName())}. Dit woord was {TimeService.AsReadableTimespan(age)} geleden aangewezen door {MessageUtils.HtmlEscape(match.OwnerName)}.";

            Client.SendMessageToChat(e.Message.Chat.ID, message, "HTML", true, false);
            Client.SendMessageToChat(match.OwnerUserId, message, "HTML", true, false);
            Client.ForwardMessageToChat(e.Message.Chat.ID, match.ReplyChatID, match.ReplyMessageID);

            _log.Info($"Selected match with ID {match.ID} - {message}");

            var geradenWoord = new GeradenWoord
            {
                GuessedByUserId            = e.Message.From.ID,
                GuessedByUserName          = e.Message.From.UsernameOrName(),
                GuessedByUserNameLowerCase = e.Message.From.UsernameOrName().ToLower(),
                Message                = e.Message,
                OwnerUserId            = match.OwnerUserId,
                OwnerUserName          = match.OwnerName,
                OwnerUserNameLowerCase = match.OwnerName?.ToLower(),
                VerbodenWoord          = match,
                When = DateTime.UtcNow
            };

            GetGeradenWoordCollection().Insert(geradenWoord);
        }