Exemplo n.º 1
0
 public RightsManager(MainBot bot, RightsManagerData rmd)
 {
     botParent         = bot;
     rightsManagerData = rmd;
     cachedRights      = new Cache <InvokerData, ExecuteContext>();
     registeredRights  = new HashSet <string>();
 }
Exemplo n.º 2
0
 public UserSession(MainBot bot, ClientData client)
 {
     this.client       = client;
     Bot               = bot;
     ResponseProcessor = null;
     ResponseData      = null;
 }
Exemplo n.º 3
0
 protected BotSession(MainBot bot)
 {
     Bot               = bot;
     UserResource      = null;
     ResponseProcessor = null;
     ResponseData      = null;
 }
Exemplo n.º 4
0
 public void Initialize(MainBot mainBot)
 {
     bot              = mainBot;
     lib              = mainBot.QueryConnection.GetLowLibrary <Ts3FullClient>();
     lib.OnConnected += Lib_OnConnected;
     Enabled          = true; PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
 }
Exemplo n.º 5
0
 public ExecutionInformation(MainBot bot, InvokerData invoker, string textMessage, UserSession userSession = null)
 {
     Bot         = bot;
     TextMessage = textMessage;
     InvokerData = invoker;
     Session     = userSession;
 }
Exemplo n.º 6
0
 public PluginManager(MainBot bot, PluginManagerData pmd)
 {
     mainBot           = bot ?? throw new ArgumentNullException(nameof(bot));
     pluginManagerData = pmd;
     Util.Init(ref plugins);
     Util.Init(ref usedIds);
 }
Exemplo n.º 7
0
		public Plugin(FileInfo file, MainBot parent, int id)
		{
			mainBot = parent;
			this.file = file;
			Id = id;
			status = PluginStatus.Off;
		}
Exemplo n.º 8
0
 public ResourceFactoryManager(MainBot bot)
 {
     mainBot = bot;
     Util.Init(ref allFacories);
     Util.Init(ref resFactories);
     Util.Init(ref listFactories);
 }
Exemplo n.º 9
0
 public void Initialize(MainBot mainBot)
 {
     //bot = mainBot.Bots.GetBot(0);
     bot = mainBot;
     lib = mainBot.QueryConnection.GetLowLibrary <Ts3FullClient>();
     bot.PlayManager.AfterResourceStarted += PlayManager_AfterResourceStarted;
     PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
 }
Exemplo n.º 10
0
 public void Initialize(MainBot mainBot)
 {
     bot = mainBot;
     lib = bot.QueryConnection.GetLowLibrary <Ts3FullClient>();
     mainBot.RightsManager.RegisterRights("PMRedirect.isowner");
     lib.OnTextMessageReceived += Lib_OnTextMessageReceived;
     Enabled = true; PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
 }
Exemplo n.º 11
0
 public Plugin(FileInfo pluginFile, MainBot parent, int id)
 {
     mainBot        = parent;
     PluginFile     = pluginFile;
     Id             = id;
     Status         = PluginStatus.Off;
     corePluginType = PluginType.None;
 }
Exemplo n.º 12
0
 public void Initialize(Core mainBot)
 {
     bot = mainBot.Bots.GetBot(0);
     lib = bot.QueryConnection.GetLowLibrary <Ts3FullClient>();
     mainBot.RightsManager.RegisterRights("TestPlugin.dummyperm");
     //lib.OnErrorEvent()
     PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
 }
Exemplo n.º 13
0
 //TickWorker pushUpdate;
 public SongChangedEvent(string sitePath, MainBot bot) : base(sitePath)
 {
     playMgr     = bot.PlayManager;
     audio       = bot.AudioFramework;
     playListMgr = bot.PlaylistManager;
     playMgr.AfterResourceStarted += Audio_OnResourceStarted;
     //pushUpdate = TickPool.RegisterTick(InvokeEvent, TimeSpan.FromSeconds(5), true);
 }
Exemplo n.º 14
0
 public UserSession(MainBot bot, ClientData client)
 {
     Bot               = bot;
     Client            = client;
     ResponseProcessor = null;
     ResponseData      = null;
     Token             = null;
 }
Exemplo n.º 15
0
 public void Initialize(MainBot mainBot)
 {
     bot = mainBot;
     lib = mainBot.QueryConnection.GetLowLibrary <Ts3FullClient>();
     //var PluginPath = Directory.GetCurrentDirectory();
     //Directory.CreateDirectory(Path.Combine(PluginPath, "ClientQuery"));
     PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
     StartTelnetServer(IPAddress.Parse(Settings.Default.HostAddress), Settings.Default.Port);
 }
Exemplo n.º 16
0
 public void Initialize(MainBot mainBot)
 {
     bot = mainBot;
     lib = mainBot.QueryConnection.GetLowLibrary <Ts3FullClient>();
     lib.OnClientMoved += Lib_OnClientMoved;
     lib.OnConnected   += Lib_OnConnected;
     Timer              = TickPool.RegisterTick(Tick, TimeSpan.FromSeconds(1), false);
     Enabled            = true; PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
 }
        public Goal_Achievement_Control()
        {
            InitializeComponent();

            BaseBot bot = new MainBot();        //композиция


            this.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
        }
Exemplo n.º 18
0
 public void Initialize(MainBot mainBot)
 {
     bot = mainBot;
     mainBot.RightsManager.RegisterRights("TestPlugin.dummyperm");
     lib = mainBot.QueryConnection.GetLowLibrary <Ts3FullClient>();
     mainBot.QueryConnection.OnClientConnect    += QueryConnection_OnClientConnect;
     mainBot.QueryConnection.OnClientDisconnect += QueryConnection_OnClientDisconnect;
     mainBot.QueryConnection.OnMessageReceived  += QueryConnection_OnMessageReceived;
     mainBot.PlayManager.AfterResourceStarted   += PlayManager_AfterResourceStarted;
     PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
 }
Exemplo n.º 19
0
        public WebDisplay(MainBot bot) : base(bot)
        {
            var baseDir = new DirectoryInfo(Path.Combine("..", "..", "Web", "Interface"));
            var dir     = new FolderProvider(baseDir);

            map.Map("/", dir);
            map.Map("/site/", dir);

            Site404 = map.TryGetSite(new Uri("http://localhost/404.html"));
            map.Map("/", map.TryGetSite(new Uri("http://localhost/index.html")));
        }
Exemplo n.º 20
0
        public BotCommandTests()
        {
            bot = new MainBot();
            var prop = typeof(MainBot).GetProperty(nameof(MainBot.CommandManager));

            if (prop != null)
            {
                prop.SetValue(bot, new CommandManager());
            }
            bot.CommandManager.RegisterMain(bot);
        }
Exemplo n.º 21
0
        public WebManager(MainBot mainBot, WebData webd)
        {
            webData     = webd;
            webListener = new HttpListener
            {
                AuthenticationSchemes = AuthenticationSchemes.Anonymous | AuthenticationSchemes.Basic,
                Realm = WebRealm,
            };
            webListener.AuthenticationSchemeSelectorDelegate = AuthenticationSchemeSelector;

            InitializeSubcomponents(mainBot);
        }
Exemplo n.º 22
0
        public void RegisterMain(MainBot main)
        {
            if (baseCommands.Count > 0)
            {
                throw new InvalidOperationException("Operation can only be executed once.");
            }

            foreach (var com in GetBotCommands(GetCommandMethods(main)))
            {
                LoadCommand(com);
                baseCommands.Add(com);
            }
        }
Exemplo n.º 23
0
        public void Initialize(MainBot mainBot)
        {
            bot = mainBot;
            //var pluginPath = mainBot.ConfigManager.GetDataStruct<PluginManagerData>("PluginManager", true).PluginPath;
            var pluginPath = "Plugins";

            cfgfile = Path.Combine(pluginPath, $"{PluginInfo.Name}.cfg");
            try {
                if (File.Exists(cfgfile))
                {
                    var parser = new FileIniDataParser();
                    cfg = parser.ReadFile(cfgfile);
                    PluginLog(Log.Level.Debug, $"cfgfile = {cfgfile}");
                    if (cfg["Ignore"]["uids"].Contains(','))
                    {
                        whitelistUID = cfg["Ignore"]["uids"].Split(',').ToList();
                    }
                    else
                    {
                        whitelistUID.Add(cfg["Ignore"]["uids"]);
                    }
                    if (cfg["Ignore"]["sgids"].Contains(','))
                    {
                        var _whitelistSGID = cfg["Ignore"]["sgids"].Split(',');
                        foreach (var wsgid in _whitelistSGID)
                        {
                            whitelistSGID.Add(ServerGroupIdT.Parse(wsgid));
                        }
                    }
                    else
                    {
                        whitelistSGID.Add(ServerGroupIdT.Parse(cfg["Ignore"]["sgids"]));
                    }
                }
            } catch (Exception ex) {
                throw new Exception($"{PluginInfo.Name} Can't load \"{cfgfile}\"! Error:\n{ex}");
                cfg = new IniData();
                //while (!Setup()) { }
            }
            ispfile = Path.Combine(pluginPath, "ISPs.txt");
            PluginLog(Log.Level.Debug, $"ispfile = {ispfile}");
            if (File.Exists(ispfile))
            {
                isps = File.ReadAllLines(ispfile).ToList();
            }
            lib = mainBot.QueryConnection.GetLowLibrary <Ts3FullClient>();
            lib.OnClientEnterView += Lib_OnClientEnterView;
            lib.OnConnected       += Lib_OnConnected;
            ClearCache             = TickPool.RegisterTick(Tick, TimeSpan.FromMinutes(UInt64.Parse(cfg["General"]["clearcache"])), false);
            Enabled = true; PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
        }
Exemplo n.º 24
0
 private void InitializeSubcomponents(MainBot mainBot)
 {
     startWebServer = false;
     if (webData.EnableApi)
     {
         Api            = new Api.WebApi(mainBot);
         startWebServer = true;
     }
     if (webData.EnableWebinterface)
     {
         Display        = new Interface.WebDisplay(mainBot);
         startWebServer = true;
     }
 }
Exemplo n.º 25
0
        public static void Main(string[] args)
        {
            IWebHost webHost = CreateWebHostBuilder(args).Build();

            MainBot KpBot = new MainBot(webHost.Services);
            Task    t1    = KpBot.KeepAlive();

            //try
            //{
            //    Task t2 = KpBot.MainAsync();
            //}
            //catch
            //{

            //}
            webHost.Run();
        }
Exemplo n.º 26
0
        public void RegisterMain(MainBot main)
        {
            if (BaseCommands != null)
            {
                throw new InvalidOperationException("Operation can only be executed once.");
            }

            var comList = new List <BotCommand>();

            foreach (var com in GetBotCommands(GetCommandMethods(main)))
            {
                LoadCommand(com);
                comList.Add(com);
            }

            BaseCommands = comList.AsReadOnly();
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            const bool writeSubCommands = false;

            var bot = new MainBot();

            typeof(MainBot).GetProperty(nameof(MainBot.CommandManager)).SetValue(bot, new CommandManager());
            bot.CommandManager.RegisterMain(bot);

            var lines = new List <string>();

            foreach (var com in bot.CommandManager.AllCommands)
            {
                if (!writeSubCommands && com.InvokeName.Contains(" "))
                {
                    continue;
                }

                string description;
                if (string.IsNullOrEmpty(com.Description))
                {
                    description = " - no description yet -";
                }
                else
                {
                    description = com.Description;
                }
                lines.Add($"* *{com.InvokeName}*: {description}");
            }

            // adding commands which only have subcommands
            lines.Add("* *history*: Shows recently played songs.");

            lines.Sort();

            string final = string.Join("\n", lines);

            Console.WriteLine(final);
            File.WriteAllText("docs.txt", final);

            Console.ReadLine();
        }
Exemplo n.º 28
0
        public UserSession CreateSession(MainBot bot, ClientData client)
        {
            if (bot == null)
            {
                throw new ArgumentNullException(nameof(bot));
            }

            lock (openSessions)
            {
                if (openSessions.TryGetValue(client.ClientId, out var session))
                {
                    return(session);
                }

                Log.Write(Log.Level.Debug, "SM User {0} created session with the bot", client.NickName);
                session = new UserSession(bot, client);
                openSessions.Add(client.ClientId, session);
                return(session);
            }
        }
Exemplo n.º 29
0
        public void Initialize(MainBot mainBot)
        {
            var dbpath     = Path.Combine(Directory.GetCurrentDirectory(), "RegistriertChannel.db");
            var firstStart = File.Exists(dbpath);

            if (firstStart)
            {
                SQLiteConnection.CreateFile(dbpath);
            }
            db = new SQLiteConnection("Data Source=" + dbpath + ";Version=3;");
            db.Open();
            if (firstStart)
            {
                new SQLiteCommand("create table optout (uid varchar(28))", db).ExecuteNonQuery();
            }

            bot = mainBot;
            lib = mainBot.QueryConnection.GetLowLibrary <Ts3FullClient>();
            lib.OnClientMoved         += Lib_OnClientMoved;
            lib.OnTextMessageReceived += Lib_OnTextMessageReceived;
            Enabled = true; PluginLog(Log.Level.Debug, "Plugin " + PluginInfo.Name + " v" + PluginInfo.Version + " by " + PluginInfo.Author + " loaded.");
        }
Exemplo n.º 30
0
        public BotSession CreateSession(MainBot bot, ushort invokerId)
        {
            if (bot == null)
            {
                throw new ArgumentNullException(nameof(bot));
            }

            if (ExistsSession(invokerId))
            {
                return(GetSession(MessageTarget.Private, invokerId));
            }
            ClientData client = bot.QueryConnection.GetClientById(invokerId);

            if (client == null)
            {
                throw new SessionManagerException("Could not find the requested client.");
            }
            var newSession = new PrivateSession(bot, client);

            openSessions.Add(newSession);
            return(newSession);
        }
Exemplo n.º 31
0
 public int AddToRobotsDict(MainBot robot)
 {
     robots.Add (robot);
     return robots.Count - 1;
 }
Exemplo n.º 32
0
        public void RegisterMain(MainBot main)
        {
            if (BaseCommands != null)
                throw new InvalidOperationException("Operation can only be executed once.");

            var comList = new List<BotCommand>();
            foreach (var com in GetBotCommands(GetCommandMethods(main)))
            {
                LoadCommand(com);
                comList.Add(com);
            }

            BaseCommands = comList.AsReadOnly();
        }