protected virtual ContentParts GetContent(Strings strings, string apikey = null, bool noApproximation = true, bool channel = false, int?offset = null, bool moderatePane = false) { List <int> pollVotesCount = CountVotes(out int peopleCount); ContentParts output; if (moderatePane) { output = GetModeratePane(strings); } else { Strings.Langs oldLang = strings.CurrentLang; strings.SetLanguage(lang); output = GetPollOutput(strings, peopleCount, pollVotesCount, noApproximation, channel: channel); strings.SetLanguage(oldLang); } return(output); }
public PVote(int chatId, int pollId, string pollText, string pollDescription, EAnony anony, bool closed, PercentageBars.Bars percentageBar, bool appendable, bool sorted, bool archived, Dictionary <string, List <User> > pollVotes, List <MessageID> messageIds, DBHandler dBHandler, Strings.Langs lang) : base(chatId, pollId, pollText, pollDescription, anony, closed, percentageBar, appendable, sorted, archived, dBHandler, pollVotes, messageIds, lang, EPolls.vote) { }
public PVote(int chatId, int pollId, string pollText, EAnony anony, DBHandler dBHandler, Strings.Langs lang) : base(chatId, pollId, pollText, null, anony, false, PercentageBars.Bars.none, false, false, false, dBHandler, new Dictionary <string, List <User> >(), new List <MessageID>(), lang, EPolls.vote) { }
public Board(int chatId, int pollId, string pollText, string pollDescription, EAnony anony, bool closed, bool archived, DBHandler dBHandler, Dictionary <int, BoardVote> pollVotes, List <MessageID> messageIds, Strings.Langs lang) : base(chatId, pollId, pollText, pollDescription, anony, closed, PercentageBars.Bars.none, false, false, archived, dBHandler, null, messageIds, lang, EPolls.board) { this.pollType = EPolls.board; this.pollVotes = pollVotes; }
protected ContentParts GetPollOutputOld(Strings strings, int peopleCount, List <int> pollVotesCount, bool noApproximation, bool channel = false) { Strings.Langs oldLang = strings.CurrentLang; strings.SetLanguage(lang); string text; string inlineTitle = this.pollText; //TODO Make this pretty string inlineDescription; InlineKeyboardMarkup inlineKeyboard = new InlineKeyboardMarkup(); inlineKeyboard.InlineKeyboard = new List <List <InlineKeyboardButton> >(); //if (offset == null) { if (!closed) { inlineKeyboard.InlineKeyboard.Add(new List <InlineKeyboardButton>() { InlineKeyboardButton.Create(strings.GetString(Strings.StringsList.buttonVote), url: $"https://telegram.me/{ Globals.GlobalOptions.Botname }?start={ Cryptography.Encrypt($"board:{ ChatId.ToString() }:{ PollId.ToString() }") }") }); } inlineDescription = StringEdit.CurrentCulture.TextInfo.ToTitleCase(anony.ToString()) + " " + pollType + ": " + pollText + ": "; text = "\ud83d\udcdd <b>" + HtmlSpecialChars.Encode(pollText).UnmarkupUsernames() + "</b>" + (!string.IsNullOrEmpty(pollDescription) ? ("\n" + HtmlSpecialChars.Encode(pollDescription) + "\n") : "\n"); foreach (KeyValuePair <int, BoardVote> x in pollVotes) { string toAdd = (anony == EAnony.personal ? "\n\u200E<b>" + HtmlSpecialChars.Encode(x.Value.Name.Replace("\u200F", "").Replace("\u202B", "").Replace("\u202E", "").Truncate(25)) + ": </b>" : "\n\ud83d\udc64 ") + HtmlSpecialChars.Encode(x.Value.Text) + "\n"; if (text.Length + toAdd.Length <= 4000) { text += toAdd; inlineDescription += x.Value.Text + ", "; } else { text += "\n▶️ <a href=\"https://telegram.me/" + Globals.GlobalOptions.Botname + "?start=" + Cryptography.Encrypt("pag:" + chatId + ":" + pollId + ":0") + "\">" + strings.GetString(Strings.StringsList.boardShowMore) + "</a>\n"; break; } } if (delete || closed) { inlineKeyboard = null; } inlineDescription = inlineDescription.Substring(0, inlineDescription.Length - 2); text += "\n" + string.Format(strings.GetString(pollVotes.Count == 0 ? Strings.StringsList.rendererZeroVotedSoFar : (pollVotes.Count == 1 ? Strings.StringsList.rendererSingleVotedSoFar : Strings.StringsList.rendererMultiVotedSoFar)), pollVotes.Count); if (closed) { text += "\n" + strings.GetString(Strings.StringsList.pollClosed); } /*} else { * inlineDescription = ""; * if (offset < pollVotes.Count) { * int difference = (int)offset - (pollVotes.Count - 1); * text = ""; * for (int i = (int)offset; i < offset + 5; i++) { * try { * var x = pollVotes.ElementAt(i); * text += (anony == EAnony.personal ? "\u200E<b>" + HtmlSpecialChars.Encode(x.Value.Name.Replace("\u200F", "").Replace("\u202B", "").Replace("\u202E", "").Truncate(25)) + ": </b>" : "\ud83d\udc64 ") + HtmlSpecialChars.Encode(x.Value.Text) + "\n\n"; * } catch (ArgumentOutOfRangeException){ * break; * } * } * inlineKeyboard.InlineKeyboard.Add(new List<InlineKeyboardButton> { * InlineKeyboardButton.Create("<<", callbackData:"comm:pag:" + chatId + ":" + pollId + ":" + (offset - 5 >= 0 ? (offset - 5) : 0)), * InlineKeyboardButton.Create(">>", callbackData:"comm:pag:" + chatId + ":" + pollId + ":" + (offset + 5 < pollVotes.Count ? (offset + 5) : pollVotes.Count - 1)) * }); * text += string.Format(strings.GetString(Strings.StringsList.boardPagBottomLine), (offset + 1), (pollVotes.Count - offset < 5 ? pollVotes.Count - (offset - 5) : (offset + 5)),pollVotes.Count); * } else { * text = strings.GetString(Strings.StringsList.boardPagCantFind); * } * }*/ strings.SetLanguage(oldLang); return(new ContentParts(text, inlineKeyboard, inlineTitle, inlineDescription)); }
public Board(int chatId, int pollId, string pollText, EAnony anony, DBHandler dBHandler, Strings.Langs lang) : this(chatId, pollId, pollText, null, anony, false, false, dBHandler, new Dictionary <int, BoardVote>(), new List <MessageID>(), lang) { this.pollType = EPolls.board; }
public Pointer(int chatId, EPolls pollType, ENeedle needle, EAnony anony, int?boardChatId, int?boardPollId, int lastPollId, Strings.Langs lang, List <DateTime> lastRequests) { this.ChatId = chatId; this.PollType = pollType; this.Needle = needle; this.Anony = anony; this.BoardChatId = boardChatId; this.BoardPollId = boardPollId; this.LastPollId = lastPollId; this.Lang = lang; this.LastRequests = lastRequests; }
public Doodle(int chatId, int pollId, string pollText, EAnony anony, DBHandler dBHandler, Strings.Langs lang) : this(chatId, pollId, pollText, null, anony, false, PercentageBars.Bars.none, false, false, false, new Dictionary <string, List <User> >(), new List <MessageID>(), new List <User>(), dBHandler, lang) { }
protected Poll(int chatId, int pollId, string pollText, string pollDescription, EAnony anony, bool closed, PercentageBars.Bars percentageBar, bool appendable, bool sorted, bool archived, DBHandler dBHandler, Dictionary <string, List <User> > pollVotes, List <MessageID> messageIds, Strings.Langs lang, EPolls pollType = EPolls.vote) { this.chatId = chatId; this.pollId = pollId; this.pollText = pollText; this.pollDescription = pollDescription; this.anony = anony; this.pollVotes = pollVotes; this.messageIds = messageIds; this.closed = closed; this.archived = archived; this.dBHandler = dBHandler; this.pollType = pollType; this.lang = lang; this.PercentageBar = percentageBar; this.Appendable = appendable; this.Sorted = sorted; }
public LimitedDoodle(int chatId, int pollId, string pollText, string pollDescription, EAnony anony, bool closed, PercentageBars.Bars percentageBar, bool appendable, bool sorted, bool archived, Dictionary <string, List <User> > pollVotes, List <MessageID> messageIds, List <User> people, int maxVotes, DBHandler dBHandler, Strings.Langs lang) : base(chatId, pollId, pollText, pollDescription, anony, closed, percentageBar, appendable, sorted, archived, pollVotes, messageIds, people, dBHandler, lang) { this.pollType = EPolls.limitedDoodle; this.MaxVotes = maxVotes; }
public LimitedDoodle(int chatId, int pollId, string pollText, EAnony anony, DBHandler dBHandler, Strings.Langs lang) : base(chatId, pollId, pollText, anony, dBHandler, lang) { this.pollType = EPolls.limitedDoodle; }