Example #1
0
        public Misc(Instance db, Setting settings, TelegramBotClient bot)
        {
            RandoFactGenerator.Init();
            settings.AddField(db, "ClarifaiAppId");
            var ClarifaiAppId = settings.GetString(db, "ClarifaiAppId");
            var r             = new Random();

            if (String.IsNullOrWhiteSpace(ClarifaiAppId))
            {
                //now ask for the API Key
                Console.Clear();
                Console.Write("What is your Clarifai App Id? : ");
                ClarifaiAppId = Console.ReadLine();
                settings.SetString(db, "ClarifaiAppId", ClarifaiAppId);
            }
            if (String.IsNullOrEmpty(ClarifaiAppId))
            {
                return;
            }

            settings.AddField(db, "ClarifaiAppSecret");
            var ClarifaiAppSecret = settings.GetString(db, "ClarifaiAppSecret");

            if (String.IsNullOrWhiteSpace(ClarifaiAppSecret))
            {
                //now ask for the API Key
                Console.Clear();
                Console.Write("What is your Clarifai App Secret? : ");
                ClarifaiAppSecret = Console.ReadLine();
                settings.SetString(db, "ClarifaiAppSecret", ClarifaiAppSecret);
            }
            if (String.IsNullOrEmpty(ClarifaiAppSecret))
            {
                return;
            }

            bot.OnUpdate += (sender, args) =>
            {
                try
                {
                    if (args.Update?.Message?.Type == MessageType.PhotoMessage)
                    {
                        if (args.Update.Message.Chat.Type != ChatType.Private)
                        {
                            var g    = db.GetGroupById(args.Update.Message.Chat.Id);
                            var nsfw = g.GetSetting <bool>("NSFW", db, false);
                            if (!nsfw)
                            {
                                return;
                            }
                        }
                        new Task(() =>
                        {
                            var photo   = args.Update.Message.Photo.OrderByDescending(x => x.Height).FirstOrDefault(x => x.FileId != null);
                            var pathing = bot.GetFileAsync(photo.FileId).Result;
                            var url     =
                                $"https://api.telegram.org/file/bot{settings.TelegramBotAPIKey}/{pathing.FilePath}";
                            var nsfw = GetIsNude(url, ClarifaiAppId, ClarifaiAppSecret);
                            if (nsfw > 70)
                            {
                                var responses = new[]
                                {
                                    "rrrrf",
                                    "Hot!",
                                    "OMAI",
                                    "*mounts*",
                                    "oh f**k the hell yes....",
                                    "mmf.  *excuses herself for a few minutes*",
                                    "Yes, I'll take one, to go..  to my room...",
                                    "Keep em cumming...",
                                };
                                bot.SendTextMessageAsync(args.Update.Message.Chat.Id,
                                                         responses[r.Next(responses.Length)], replyToMessageId: args.Update.Message.MessageId);

                                //download it
                                Directory.CreateDirectory("nsfw");
                                var name = "nsfw\\" + pathing.FilePath.Substring(pathing.FilePath.LastIndexOf("/") + 1);
                                new WebClient().DownloadFileAsync(new Uri(url), name);
                            }
                        }).Start();
                    }
                }
                catch
                {
                    // ignored
                }
            };
        }
Example #2
0
 public static CommandResponse RandoFact(CommandEventArgs e)
 {
     return(new CommandResponse(RandoFactGenerator.Get()));
 }