Пример #1
0
    /*
     * Non-static method that starts the bot
     * Called by Program().main(args)
     */
    public void Start()
    {
        CoreBot bot = new CoreBot();

        _client = new DiscordClient(x =>
        {
            x.AppName    = "HarunaBot";
            x.LogLevel   = LogSeverity.Info;
            x.LogHandler = Log;
        });
        _client.UsingCommands(x =>
        {
            x.PrefixChar         = '!';
            x.AllowMentionPrefix = true;
            x.HelpMode           = HelpMode.Public;
        });
        commands = _client.GetService <CommandService>();

        //register commands
        RegisterCommands();

        _client.ExecuteAndWait(async() =>
        {
            try
            {
                string token = LoadJson("auth.json");
                await _client.Connect(token, TokenType.Bot);
            }
            catch (System.IO.FileNotFoundException e)
            {
                Console.WriteLine("File not found: " + e.Message);
            }
        });
    }
Пример #2
0
        public static CoreBot loadBotModule(String configName, String routeName)
        {
            CoreBot bot = null;

            Module.SaveConfigHolder configHolder = new Module.SaveConfigHolder();
            List <Waypoint>         wplist       = BotLoader.loadWaypoints(routeName, "wpr");

            byte[] configBytes = BotLoader.loadFile(configName, "cfg");
            if (configBytes.Length > 0 && wplist.Count > 0)
            {
                configHolder.parseBytes(configBytes, true);
            }


            if (configHolder.type != ConfigType.None)
            {
                if (configHolder.type == ConfigType.Fishing)
                {
                    bot = new FishingBot(configHolder.fishingConfig, wplist);
                }
                else if (configHolder.type == ConfigType.Gathering)
                {
                    bot = new GatheringBot(configHolder.gatheringConfig, wplist);
                }
                else if (configHolder.type == ConfigType.Combat)
                {
                    bot = new CombatBot(configHolder.combatConfig, wplist);
                }
            }
            return(bot);
        }
Пример #3
0
 private void startButton_Click(object sender, EventArgs e)
 {
     if (this.memory != null && this.memory.isUseable())
     {
         String currentSelecteWaypointName = (string)this.loadWaypointCombobox.SelectedItem;
         String currentSelecteConfigName   = (string)this.loadConfigCombobox.SelectedItem;
         if (currentSelecteWaypointName != null && currentSelecteWaypointName.Length > 0 && currentSelecteConfigName != null && currentSelecteConfigName.Length > 0)
         {
             if (this.bot == null)
             {
                 this.bot = BotLoader.loadBotModule(currentSelecteConfigName, currentSelecteWaypointName);
                 if (this.bot != null)
                 {
                     SetForegroundWindow(this.memory.processMainWindowHandle());
                     this.bot.setCoreObjects(this.memory);
                     this.bot.run();
                 }
             }
             else
             {
                 this.bot.stop();
                 this.bot = null;
             }
         }
     }
 }
Пример #4
0
        public static void Main()
        {
            var corebot = new CoreBot(Config.TelegramAccessToken);

            while (true)
            {
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Ask a question");
            var userText = Console.ReadLine();
            var bot      = new CoreBot();

            bot.Add("Cause your mom is gay");
            var response = bot.PickResponse(userText);

            Console.WriteLine(response);
            Console.ReadKey();
        }
Пример #6
0
        public void SkipACurse()
        {
            var bot = new CoreBot();

            bot.Add("Because you mum is gay");

            var ourLine        = "Are you doing this to me?";
            var actualResponse = bot.PickResponse(ourLine);

            var expectedResponse = "";

            Assert.AreEqual(expectedResponse, actualResponse);
        }
Пример #7
0
        /// <summary>
        /// Serves as the main entrypoint for the program.
        /// Launches the bot and then hangs until the bot is shut down.
        /// </summary>
        /// <param name="args">Command-line arguments supplied to the program.</param>
        public static void Main(string[] args)
        {
            BotInstance instance = new BotInstance();

            instance.Init();

            CoreBot         coreBot  = new CoreBot("CoreBot");
            RoleManagerBot  roleBot  = new RoleManagerBot("RoleBot");
            MessagePurgeBot purgeBot = new MessagePurgeBot("PurgeBot");

            coreBot.AttachTo(instance);
            roleBot.AttachTo(instance);
            purgeBot.AttachTo(instance);

            Task.WaitAll(instance.RunAsync());

            System.Console.WriteLine("Finished.");
        }