public int AddSpoiler(Spoiler s) { File.WriteAllText($"{SPOILERDIRECTORY}/{nextId}.spoiler", JsonConvert.SerializeObject(s)); return nextId++; }
public async Task<TelegramBotReply> Step3(Message m, TelegramBot.TelegramBot bot) { switch (m.Text) { case optionYes: int id = DirectoryManager.Instance.AddSpoiler(Spoiler); await Message(Group.ID, $@"I just received a new spoiler from [{m.From}]: *{Spoiler.Description}* Would you like to see this spoiler? Click /showspoiler{id} and I'll whisper you the dirty little secret.", userMarkup: true).HandleReply(bot); return Message(m, $"Your message has been sent to the group '{Group.Title}'"); case optionNo: return Message(m, "Okay, I'll stop disturbing you now. If you want to resend a spoiler, add me to a group and use /spoiler in that group"); case optionEdit: Spoiler = new Spoiler { ChatId = Group.ID }; return Message(m, $"Okay, let's try that again then. What is the description of the spoiler, you know, the part that's publically visible!"); default: return Message(m, "Woops something went wrong, make sure you use the buttons on the keyboard!", replyMarkup: keyboard); } }
private string GetDescription(Spoiler s) { switch (s.Type) { case MessageHandlerType.Message: return s.Text; case MessageHandlerType.Sticker: return "A sticker"; case MessageHandlerType.Voice: return "Your voice message"; case MessageHandlerType.Document: return $"The file: '{s.Document.File_Name}'"; case MessageHandlerType.Audio: return $"The audio file: {s.Audio.Title}"; case MessageHandlerType.Location: return "Your supplied location"; case MessageHandlerType.Video: return "Your video file"; case MessageHandlerType.Photo: return "Your photo"; default: return "Something went wrong!"; } }
public SpoilerFlow(Chat group) { Group = group; Spoiler = new Spoiler { ChatId = group.ID }; HandlerType = ACCEPTEDTYPES; }