private void Button3_Click(object sender, EventArgs e)
 {
     PrivateVariable.nospam        = DateTime.Now;
     PrivateVariable.Battling      = false;
     PrivateVariable.InEventScreen = false;
     PrivateVariable.InMainScreen  = false;
     PrivateVariable.InMap         = false;
     BotCore.EjectSockets();
     Variables.ScriptLog("Script Stopped!", Color.White);
     if (Width > 1280)
     {
         Width         -= 1280;
         panel3.Visible = false;
     }
     if (Variables.Proc != null)
     {
         DllImport.SetParent(Variables.Proc.MainWindowHandle, IntPtr.Zero);
         DllImport.MoveWindow(Variables.Proc.MainWindowHandle, PrivateVariable.EmuDefaultLocation.X, PrivateVariable.EmuDefaultLocation.Y, 1318, 752, true);
         Docked = false;
     }
     foreach (Control control in Debug.Controls)
     {
         control.Enabled = true;
     }
     ScriptRun.StopScript();
     btn_Start.Enabled = true;
     Controls.Remove(tp);
 }
Exemple #2
0
        private static async Task SendCommandExecutionExceptionMessage(Exception e, ReactionContext context, ReactionCommand command)
        {
            await context.Channel.SendEmbedAsync("Something went horribly wrong trying to execute your emojicommand! I have contacted my creators to help fix this issue!", true);

            ISocketMessageChannel channel = Var.client.GetChannel(SettingsModel.DebugMessageChannelId) as ISocketMessageChannel;

            if (channel != null)
            {
                EmbedBuilder embed = new EmbedBuilder();
                embed.Color = Var.ERRORCOLOR;
                embed.Title = "**__Exception__**";
                embed.AddField("Command", command.Emote);
                embed.AddField("Location", Var.Guild.GetTextChannel(context.Channel.Id).Mention);
                embed.AddField("Message", Macros.MultiLineCodeBlock(e.Message));
                string stacktrace;
                if (e.StackTrace.Length <= 500)
                {
                    stacktrace = e.StackTrace;
                }
                else
                {
                    stacktrace = e.StackTrace.Substring(0, 500);
                }
                embed.AddField("StackTrace", Macros.MultiLineCodeBlock(stacktrace));
                string     message    = string.Empty;
                SocketRole botDevRole = Var.Guild.GetRole(SettingsModel.BotDevRole);
                if (botDevRole != null)
                {
                    message = botDevRole.Mention;
                }
                await channel.SendMessageAsync(message, embed : embed.Build());
            }
            await BotCore.Logger(new LogMessage(LogSeverity.Error, "CMDSERVICE", string.Format("An Exception occured while trying to execute command `/{0}`.Message: '{1}'\nStackTrace {2}", command.Emote, e.Message, e.StackTrace)));
        }
Exemple #3
0
        /// <summary>
        /// Main Programs method running asynchronously
        /// </summary>
        /// <returns></returns>
        public static async Task MainAsync()
        {
            Console.Title = "YNB Bot v" + Var.VERSION.ToString();
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            SetupCommands();
            BotCore.OnBotVarDefaultSetup += SettingsModel.SetupSettingsUpdateListener;
            BotVarManager.OnGuildBotVarCollectionLoaded += EventLogger.SubscribeToBotVarCollection;

            EventLogger.SubscribeToDiscordEvents(BotCore.Client);
            EventLogger.SubscribeToModerationEvents();

            await GuildModerationLog.LoadModerationLogs();

            InitReactionsCommands();

            BotCore.Client.MessageReceived += PingSpamDefenceService.HandleMessage;
            SettingsModel.DebugMessage     += Logger;
            BotCore.Client.ReactionAdded   += ReactionAddedHandler;
            BotCore.Client.ReactionAdded   += InteractiveMessageService.ReactionAddedHandler;
            //BotCore.Client.ChannelUpdated += ChannelUpdatedHandler;


            await MinecraftGuildSystem.MinecraftGuildModel.Load();

            BotCore.Run(commandParser: new YNBCommandParser(), aboutEmbed: getAboutEmbed());
        }
Exemple #4
0
 public CommandContext(BotCore core, User sender, Chat chat, Message messageData)
 {
     Core        = core;
     Sender      = sender;
     Chat        = chat;
     MessageData = messageData;
 }
        public static async Task <bool> Start(BotStartupConfig config)
        {
            if (connecting || session.Connected)
            {
                return(false);
            }
            else
            {
                connecting = true;
            }
            MiraiHttpSessionOptions options = new MiraiHttpSessionOptions(config.host, config.port, config.authKey);

            try
            {
                await session.ConnectAsync(options, config.qqID);
            }
            catch
            {
                connecting = false;
                return(false);
            }
            if (session.Connected)
            {
                session.AddPlugin(new MainPlugin());
                await BotCore.Init(session, config);

                connecting = false;
                return(true);
            }
            else
            {
                connecting = false;
                return(false);
            }
        }
 private void button2_Click(object sender, EventArgs e)
 {
     if (File.Exists("OCR.png"))
     {
         var img = BotCore.Compress(Image.FromFile("OCR.png") as Bitmap);
         MessageBox.Show(OCR.OcrImage(img, "eng"));
     }
 }
Exemple #7
0
 public CommandContext(BotCore core, User sender, BaseChat chat, Message messageData, MethodInfo command)
 {
     Core        = core;
     Sender      = sender;
     Chat        = chat;
     MessageData = messageData;
     Command     = command;
 }
        private void Button1_Click(object sender, EventArgs e)
        {
            ScriptErrorHandler.errorImages.Clear();
            foreach (var f in Directory.GetFiles("Img\\Errors"))
            {
                Thread.Sleep(10);
                using (Stream bmp = File.Open(f, FileMode.Open))
                {
                    Image temp = Image.FromStream(bmp);
                    ScriptErrorHandler.errorImages.Add(new Bitmap(temp));
                }
            }
            if ((PrivateVariable.nospam - DateTime.Now).Duration() < TimeSpan.FromSeconds(4))
            {
                return;
            }
            PrivateVariable.nospam = DateTime.Now;
            Variables.ProchWnd     = panel3.Handle;
            richTextBox1.Text      = "";
            btn_Start.Enabled      = false;
            PrivateVariable.Skills.Clear();
            var files = Directory.GetFiles("Img\\Star");

            foreach (var f in files)
            {
                using (Stream bmp = File.Open(f, FileMode.Open))
                {
                    Image image = Image.FromStream(bmp);
                    PrivateVariable.Skills.Add(BotCore.Compress(image as Bitmap));
                }
            }
            if (panel3.Visible == false)
            {
                Width         += 1280;
                panel3.Visible = true;
            }
            panel3.Enabled = false;
            tp             = new TransparentPanel
            {
                Location = panel3.Location,
                Size     = panel3.Size,
                Enabled  = true,
                Visible  = true
            };
            tp.MouseDown += Tp_MouseDown;
            Controls.Add(tp);
            foreach (Control control in Debug.Controls)
            {
                if (control is Button)
                {
                    control.Enabled = false;
                }
            }
            ScriptRun.RunScript(true, (new VCBotScript() as ScriptInterface));
            Thread cap = new Thread(Capt);

            cap.Start();
        }
        public BotCoreTests()
        {
            // 設定ファイルのコピーと読み込み
            var conf = JsonMgr <Config> .Load("config.json");

            core       = new BotCore(conf);
            core.Botid = "<BOTSELFID>";
            hanshin    = new Hanshin();
        }
Exemple #10
0
        internal BotClient(BotCore core)
        {
            BootDate = DateTime.Now;
            Core     = core;

            Configuration = LoadConfiguration(DataDirectory + "/Configuration");

            Log.Write(Log.Type.BOT, "Creating bot client with token " + Configuration.Token);
        }
Exemple #11
0
        public PluginManager(BotCore core)
        {
            Core = core;
            LoadCommands(new BaseCommands());

            Permissions.Add(UserPermission.Block);
            Permissions.Add(UserPermission.None);
            Permissions.Add(UserPermission.Admin);
        }
 public static void SoulWeaponEnter()
 {
     if (UnhandledException)
     {
         Variables.ScriptLog("Unhandled exception had found in SoulWeapon event UI. Skip it! ", Color.Red);
         return;
     }
     do
     {
         VCBotScript.LocateMainScreen();
     }while (!PrivateVariable.InMainScreen);
     BotCore.SendTap(170, 630);
     BotCore.Delay(5000, false);
     for (int x = 0; x < 5; x++)
     {
         VCBotScript.image = BotCore.ImageCapture();
         Point?located = BotCore.FindImage(VCBotScript.image, Environment.CurrentDirectory + "\\Img\\LocateEventSwitch.png", true);
         if (located == null)
         {
             x -= 1;
             BotCore.Delay(1000, false);
             if (error > 10)
             {
                 ScriptErrorHandler.Reset("Unable to locate Event Switch screen! Returning main screen!");
                 error = 0;
                 return;
             }
             error++;
             ScriptErrorHandler.ErrorHandle();
             continue;
         }
         else
         {
             break;
         }
     }
     if (File.Exists("Img\\WeaponEvent.png"))
     {
         var point = BotCore.FindImage(VCBotScript.image, "Img\\WeaponEvent.png", false);
         if (point != null)
         {
             BotCore.SendTap(point.Value);
             //Enter event
             SwitchStage();
         }
         else
         {
             Variables.ScriptLog("Unable to find WeaponEvent.png at event page. Exiting function! ", Color.Red);
         }
     }
     else
     {
         Variables.ScriptLog("WeaponEvent.png not found! Exiting function! ", Color.Red);
     }
 }
        /// <summary>
        /// OCR the image. Need Prepair OCR first!
        /// </summary>
        /// <param name="source"></param>
        /// <param name="lang"></param>
        /// <returns></returns>
        public static string OcrImage(byte[] source, string lang)
        {
            if (t == null)
            {
                throw new Exception("Run PrepairOcr First!");
            }
            Image <Bgr, byte> img = new Image <Bgr, byte>(new Bitmap(BotCore.Decompress(source)));

            t.SetImage(img);
            return(t.GetUTF8Text());
        }
Exemple #14
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Core = new BotCore();
     user = Core.getNickName();
     Core.onMessageReceived += Core_onMessageReceived;
     Core.onCallReceived    += Core_onCallReceived;
     Console.Title           = "Debug Log";
     Console.WriteLine("Program correctly initialized...");
     openFileDialog1.CheckFileExists = true;
     openFileDialog1.CheckPathExists = true;
 }
 /// <summary>
 /// Check if the android directory is exist
 /// </summary>
 /// <param name="androidpath">The path to check</param>
 /// <returns></returns>
 public static bool AndroidDirectoryExist(string androidpath)
 {
     if (BotCore.AdbCommand("ls " + androidpath + " > /dev/null 2>&1 && echo \"exists\" || echo \"not exists\"").Contains("exist"))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /// <summary>
 /// Method for resizing emulators using Variables.EmulatorWidth, Variables.EmulatorHeight, Variables.EmulatorDpi
 /// </summary>
 public static void ResizeEmulator()
 {
     if (!ScriptRun.Run)
     {
         return;
     }
     CloseEmulator();
     BotCore.Delay(3000);
     Variables.emulator.SetResolution(Variables.EmulatorWidth, Variables.EmulatorHeight, Variables.EmulatorDpi);
     Variables.ScriptLog("Restarting Emulator after setting size", Color.Lime);
     StartEmulator();
 }
 public CallbackController(BotCore core)
 {
     try
     {
         Core       = core;
         _secretKey = Core.Configuration.GetValue <string>("Config:SecretKey", null);
     }
     catch (Exception e)
     {
         Core.Log.Error(e.ToString());
     }
 }
Exemple #18
0
        public static void Main(string[] args)
        {
            Console.CancelKeyPress += OnProcessExit;
            LoadSettings();

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Is(Enum.Parse <LogEventLevel>(_settings.Options.LogLevel))
                         .WriteTo.Console()
                         .CreateLogger();

            var core = new BotCore(_settings);

            core.EnableCaching <LevelCache>();
            core.EnableAssemblyLocalization();

            core.RegisterController <TelegramController>();
            core.RegisterController <VkController>();
            core.RegisterController <DiscordController>();

            var commands = core.RegisterModule <CommandsModule>();

            commands.RegisterConverter <UserConverter>();
            commands.RegisterConverter <ChatConverter>();
            commands.RegisterConverter <RouteConverter>();

            var router = core.Router;

            router.AddHandler <PrimaryMiddleware>();
            router.AddHandler <UsersMiddleware>();
            router.AddHandler <ReplicatingMiddleware>();

            router.AddHandler <TestCommand>();
            router.AddHandler <SudoCommand>();
            router.AddHandler <ChatsCommand>();
            router.AddHandler <UsersCommand>();
            router.AddHandler <RoutesCommand>();
            router.AddHandler <HelpCommand>();

            HelpMessage.Init(commands.GetCommands());
            core.Start();
            Core = core;

            CreateAdmins();

            if (Options.Changelog)
            {
                BroadcastChangelog();
            }

            Log.Information("Replica started");

            Thread.Sleep(Timeout.Infinite);
        }
Exemple #19
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedItem != null && comboBox2.SelectedItem != null)
     {
         BotCore.AdbCommand("backup -noapk com.nubee.valkyriecrusade", devices[comboBox1.SelectedIndex]);
         BotCore.AdbCommand("restore backup.ab", devices[comboBox2.SelectedIndex]);
     }
     else
     {
         MessageBox.Show("Please select the devices for transfering data!");
     }
 }
Exemple #20
0
 /// <summary>
 /// The emulator path that is installed at PC with outputing the emulator enum
 /// </summary>
 public static void EmulatorPath()
 {
     BotCore.LoadEmulatorInterface();
     if (emulator == null)
     {
         throw new FileNotFoundException("No supported emulators detected!");
     }
     if (Instance == "")
     {
         Instance = emulator.EmulatorName();
     }
     BotCore.profilePath = Instance;
 }
Exemple #21
0
        public Parser(BotCore core)
        {
            Core = core;

            LexList = new List <ALex>();

            Atom = (new LexAtom(this));
            LexList.Add(new LexMeta(this));
            LexList.Add(new LexIdentity(this));
            LexList.Add(new LexReminder(this));
            LexList.Add(new LexTime(this));

            this.Syna = new Syna();
        }
Exemple #22
0
 public void UnUnBotify()
 {
     try
     {
         //Remove 4 files which detect by Unbotify
         BotCore.AdbCommand("rm -f /system/bin/microvirtd", Variables.Controlled_Device);
         BotCore.AdbCommand("rm -f /system/etc/init.microvirt.sh", Variables.Controlled_Device);
         BotCore.AdbCommand("rm -f /system/bin/memud", Variables.Controlled_Device);
         BotCore.AdbCommand("rm -f /system/lib/memuguest.ko", Variables.Controlled_Device);
     }
     catch
     {
     }
 }
        public bool LoadEmulatorSettings()
        {
            RegistryKey reg;

            if (BotCore.Is64BitOperatingSystem())
            {
                reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Nemu");
            }
            else
            {
                reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Nemu");
            }
            var installpath = reg.GetValue("DisplayIcon").ToString();

            return(false);
        }
        /// <summary>
        /// Check some error message that need to restart the game
        /// </summary>
        public static bool ErrorHandle()
        {
            if (Variables.Proc != null)
            {
                try
                {
                    if (BotCore.RGBComparer(new Point(145, 170), Color.Black, 2, VCBotScript.image) && BotCore.RGBComparer(new Point(1000, 355), Color.Black, 2, VCBotScript.image))
                    {
                        if (BotCore.RGBComparer(new Point(410, 285), Color.FromArgb(25, 44, 58), 10, VCBotScript.image) && BotCore.RGBComparer(new Point(400, 430), Color.FromArgb(56, 98, 128), 10, VCBotScript.image))
                        {
                            //Error Messagebox found
                            BotCore.KillGame("com.nubee.valkyriecrusade");
                            Reset("Error message found!");
                            return(true);
                        }
                    }
                }
                catch
                {
                }
                return(false);

                /*try
                 * {
                 *  var crop = Screenshot.CropImage(VCBotScript.image, new Point(350, 180), new Point(980, 515));
                 *  foreach(var error in errorImages)
                 *  {
                 *      BotCore.Delay(100);
                 *      Point? p = BotCore.FindImage(crop, error, false);
                 *      if (p != null)
                 *      {
                 *          BotCore.SendTap(p.Value);
                 *          BotCore.KillGame("com.nubee.valkyriecrusade");
                 *          Reset("Error message found!");
                 *      }
                 *  }
                 * }
                 * catch
                 * {
                 *
                 * }*/
            }
            return(true);
        }
Exemple #25
0
        public void Start()
        {
            Core = new BotCore();
            var client = new DiscordClient();

            Core.Initialize(client);
            var token = Core.Token;

            Parser = new Parser(Core);


            client.MessageReceived += Answer;
            client.MessageReceived += Logs.Log;

            client.ExecuteAndWait(async() =>
            {
                await client.Connect(token, TokenType.Bot);
            });
        }
Exemple #26
0
 private static void _RunScript(bool KeepRunning, ScriptInterface script)
 {
     if (script != null)
     {
         do
         {
             try
             {
                 script.Script();
                 errornum = 0;
             }
             catch (Exception ex)
             {
                 script.ResetScript();
                 if (ex is SocketException || ex is DeviceNotFoundException || ex is AdbException)
                 {
                     BotCore.server.RestartServer();
                     if (!CheckDeviceOnline())
                     {
                         BotCore.RestartEmulator();
                     }
                     BotCore.Delay(10000);
                     BotCore.ConnectAndroidEmulator();
                     continue;
                 }
                 else if (ex is ThreadAbortException) //Bot stopped
                 {
                 }
                 else
                 {
                     ThrowException(ex);
                     continue;
                 }
             }
         }while (KeepRunning && Run);
     }
     else
     {
         throw new Exception("No script dll found!");
     }
     Run = false;
 }
Exemple #27
0
        static void Main(string[] args)
        {
            BotCore.OnBotVarDefaultSetup += WebRequestService.OnBotVarSetup;
            BotCore.OnBotVarDefaultSetup += StoredMessagesService.OnBotVarSetup;
            CommandCollection elitecollection = new CommandCollection("Elite", "Commands to retrieve info on Elite:Dangerous");

            new SystemCommand("system", elitecollection);
            new CmdrCommand("cmdr", elitecollection);
            new DistanceCommand("distance", elitecollection);
            //new BaseCommand("base", elitecollection);
            CommandCollection quotecollection = new CommandCollection("Quotes", "Commands for adding and viewing quotes");

            new AddQuoteCommand("quote-add", quotecollection);
            new GetQuotecommand("quote", quotecollection);
            CommandCollection macrocollection = new CommandCollection("Macros", "Commands for adding and listing macros");

            new SetMacroCommand("macro", macrocollection);
            new ListMacrosCommand("macro-list", macrocollection);

            BotCore.Client.MessageReceived += StoredMessagesService.Client_MessageReceived;

            EmbedBuilder aboutEmbed = new EmbedBuilder()
            {
                Author = new EmbedAuthorBuilder()
                {
                    Name    = "OrcaBot V1.0",
                    IconUrl = "https://cdn.discordapp.com/attachments/475335264068173824/620998619574829056/thepod2.jpg",
                },
                Color       = new Color(80, 127, 160),
                Description = $"**Programming**\n" +
                              $"\u23F5 BrainProtest#1394 (<@117260771200598019>)" +
                              $"\n" +
                              $"\n" +
                              $"**External Tools and Dependencies**\n" +
                              $"\u23F5 [Discord.NET](https://github.com/discord-net/Discord.Net) Discord API Wrapper\n" +
                              $"\u23F5 [EDSM API](https://www.edsm.net/en/api-v1) for Elite:Dangerous data network access\n" +
                              $"\u23F5 [Inara API](https://inara.cz/inara-api/) for Elite:Dangerous data network access" +
                              $"\u23F5 [EDAssets](https://edassets.org/#/) for Station Icons"
            };

            BotCore.Run(Environment.CurrentDirectory + "/BotCore/", new CustomCommandParser(), aboutEmbed: aboutEmbed);
        }
Exemple #28
0
        private Task Client_Ready(ReadyEventArgs e)
        {
            e.Client.DebugLogger.LogMessage(LogLevel.Info, "ZAYN", "Cliente está pronto para processar eventos.", DateTime.Now);
#if DEBUG
            string projetoRaiz = Path.GetFullPath(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\..\")) + "BotCore.json";
#else
            string projetoRaiz = Path.GetFullPath(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"../../../../")) + "BotCore.json";
#endif
            Bot = BotCore.LoadFromFile(projetoRaiz);
            if (Bot == null)
            {
                Bot = new BotCore();
            }
#if DEBUG
            Bot.VersaoRevisao++;
            Bot.SaveToFile(projetoRaiz);
#endif
            Client.UpdateStatusAsync(new DiscordActivity($"z!ajuda", ActivityType.Playing), UserStatus.Online);
            return(Task.CompletedTask);
        }
Exemple #29
0
 /// <summary>
 /// If time delay is true, means the android is now delaying over 30 seconds!
 /// </summary>
 /// <returns></returns>
 private static bool TimeDelay(out double delay)
 {
     try
     {
         delay = (DateTime.Parse(BotCore.AdbCommand("date").Remove(11).Remove(9)) - DateTime.Now.TimeOfDay).TimeOfDay.TotalSeconds;
         if (delay > 30)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         delay = 0;
         return(false);
     }
 }
 public static void CheckWalkEnergy()
 {
     try
     {
         var temp     = OCR.OcrImage(BotCore.CropImage(VCBotScript.image, new Point(65, 54), new Point(166, 78)), "eng");
         var temp_arr = temp.Split('/');
         FullWalkEnergy    = Convert.ToInt32(temp_arr[1]);
         CurrentWalkEnergy = Convert.ToInt32(temp_arr[0]);
         error             = 0;
         Variables.ScriptLog("Current walk energy is " + CurrentWalkEnergy, Color.White);
     }
     catch
     {
         if (FullWalkEnergy == 0)
         {
             CurrentWalkEnergy = 999;
             FullWalkEnergy    = 999;
         }
         error++;
     }
 }