Exemplo n.º 1
0
 public Module(SteamNerd steamNerd, string path)
 {
     SteamNerd = steamNerd;
     Commands  = new List <Command>();
     Path      = path;
     Global    = false;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a SteamNerd user that contains user information.
 /// </summary>
 /// <param name="steamNerd">The SteamNerd instance.</param>
 /// <param name="steamID">The user's SteamID.</param>
 /// <param name="name">The user's persona name.</param>
 /// <param name="personaState">The user's persona state.</param>
 public User(SteamNerd steamNerd, SteamID steamID, string name, EPersonaState personaState)
 {
     _steamNerd = steamNerd;
     SteamID = steamID;
     Name = name;
     PersonaState = personaState;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a SteamNerd user that contains user information.
 /// </summary>
 /// <param name="steamNerd">The SteamNerd instance.</param>
 /// <param name="steamID">The user's SteamID.</param>
 /// <param name="name">The user's persona name.</param>
 /// <param name="personaState">The user's persona state.</param>
 public User(SteamNerd steamNerd, SteamID steamID, string name, EPersonaState personaState)
 {
     _steamNerd   = steamNerd;
     SteamID      = steamID;
     Name         = name;
     PersonaState = personaState;
 }
Exemplo n.º 4
0
 public Module(SteamNerd steamNerd, string path)
 {
     SteamNerd = steamNerd;
     Commands = new List<Command>();
     Path = path;
     Global = false;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a chat room.
 /// </summary>
 /// <param name="steamNerd">The SteamNerd instance.</param>
 /// <param name="steamID">The SteamID of the chat room.</param>
 /// <param name="name">The name of the chat room.</param>
 public ChatRoom(SteamNerd steamNerd, SteamID steamID, string name)
 {
     _steamNerd = steamNerd;
     SteamID = steamID;
     Name = name;
     Users = new List<User>();
     Modules = new List<dynamic>();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a chat room.
 /// </summary>
 /// <param name="steamNerd">The SteamNerd instance.</param>
 /// <param name="steamID">The SteamID of the chat room.</param>
 /// <param name="name">The name of the chat room.</param>
 public ChatRoom(SteamNerd steamNerd, SteamID steamID, string name)
 {
     _steamNerd = steamNerd;
     SteamID    = steamID;
     Name       = name;
     Users      = new List <User>();
     Modules    = new List <dynamic>();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Creates an Admin Manager.
        /// </summary>
        /// <param name="adminListPath">The file that contains the admin list.</param>
        public UserManager(SteamNerd steamNerd, string adminListPath)
        {
            _steamNerd = steamNerd;
            _adminListPath = adminListPath;
            LoadAdminFile();

            _users = new Dictionary<SteamID, User>();
            _admins = new List<SteamID>();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates an Admin Manager.
        /// </summary>
        /// <param name="adminListPath">The file that contains the admin list.</param>
        public UserManager(SteamNerd steamNerd, string adminListPath)
        {
            _steamNerd     = steamNerd;
            _adminListPath = adminListPath;
            LoadAdminFile();

            _users  = new Dictionary <SteamID, User>();
            _admins = new List <SteamID>();
        }
Exemplo n.º 9
0
        public Login(SteamNerd steamNerd, CallbackManager manager)
        {
            _steamNerd = steamNerd;

            manager.Subscribe <SteamClient.ConnectedCallback>(OnConnect);
            manager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnect);
            manager.Subscribe <SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe <SteamUser.LoginKeyCallback>(OnLoginKey);
        }
Exemplo n.º 10
0
        public Login(SteamNerd steamNerd, CallbackManager manager)
        {
            _steamNerd = steamNerd;

            manager.Subscribe<SteamClient.ConnectedCallback>(OnConnect);
            manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnect);
            manager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            manager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe<SteamUser.LoginKeyCallback>(OnLoginKey);
        }
Exemplo n.º 11
0
        public static void Main(string[] args)
        {
            var steamNerd = new SteamNerd();

            if (args.Length >= 2)
            {
                steamNerd.Connect(args[0], args[1]);
            }
            else
            {
                steamNerd.Connect();
            }
        }
Exemplo n.º 12
0
        public static void Main(string[] args)
        {
            var steamNerd = new SteamNerd();

            if (args.Length >= 2)
            {
                steamNerd.Connect(args[0], args[1]);
            }
            else
            {
                steamNerd.Connect();
            }
        }
Exemplo n.º 13
0
        public ModuleManager(SteamNerd steamNerd)
        {
            _steamNerd        = steamNerd;
            _pyEngine         = Python.CreateEngine();
            _localModulePaths = new List <string>();
            _globalModules    = new Dictionary <string, Module>();
            _chatroomModules  = new Dictionary <SteamID, Dictionary <string, Module> >();
            _adminModules     = new Dictionary <string, Module>();

            InterpretDirectory();

            _watcher              = new FileSystemWatcher(ModulesDirectory);
            _watcher.Filter       = "*.py";
            _watcher.NotifyFilter = NotifyFilters.LastAccess |
                                    NotifyFilters.LastWrite |
                                    NotifyFilters.FileName |
                                    NotifyFilters.DirectoryName;

            _watcher.Created += OnCreated;
            _watcher.Changed += OnChanged;
            _watcher.Deleted += OnDelete;

            _watcher.EnableRaisingEvents = true;
        }
Exemplo n.º 14
0
        public ModuleManager(SteamNerd steamNerd)
        {
            _steamNerd = steamNerd;
            _pyEngine = Python.CreateEngine();
            _localModulePaths = new List<string>();
            _globalModules = new Dictionary<string, Module>();
            _chatroomModules = new Dictionary<SteamID, Dictionary<string, Module>>();
            _adminModules = new Dictionary<string, Module>();

            InterpretDirectory();

            _watcher = new FileSystemWatcher(ModulesDirectory);
            _watcher.Filter = "*.py";
            _watcher.NotifyFilter = NotifyFilters.LastAccess |
                NotifyFilters.LastWrite|
                NotifyFilters.FileName |
                NotifyFilters.DirectoryName;

            _watcher.Created += OnCreated;
            _watcher.Changed += OnChanged;
            _watcher.Deleted += OnDelete;

            _watcher.EnableRaisingEvents = true;
        }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a Chat Room Manager that handles chat rooms.
 /// </summary>
 /// <param name="steamNerd">
 /// The SteamNerd instance.
 /// </param>
 /// <param name="autoJoinPath">
 /// The file containing the auto-joined chat rooms.
 /// </param>
 public ChatRoomManager(SteamNerd steamNerd, string autoJoinPath)
 {
     _steamNerd = steamNerd;
     _autoJoinPath = autoJoinPath;
     _chatrooms = new Dictionary<SteamID, ChatRoom>();
 }
Exemplo n.º 16
0
        /// <summary>
        /// Interprets a Python file and creates a module.
        /// </summary>
        /// <param name="file">The path of the Python file.</param>
        public ScriptScope Interpret(SteamNerd steamNerd, ScriptEngine pyEngine)
        {
            Commands.Clear();
            var scope = pyEngine.CreateScope();

            SayCallback say = (message, receiver) => Say(message, receiver);

            scope.SetVariable("SteamNerd", steamNerd);
            scope.SetVariable("Module", this);
            scope.SetVariable("Say", say);

            try
            {
                // Add a "var" class to get all of the script variables.
                // And add a way to reference SteamKit2.
                pyEngine.Execute(
                    "from System import Environment\n" +
                    "import clr\n" +
                    "import sys\n" +
                    "sys.path.append(r'" + Directory.GetCurrentDirectory() + "')\n" +
                    "sys.path.append(r'" + ModuleManager.ModulesDirectory + "')\n" +
                    "for path in Environment.GetEnvironmentVariable('IRONPYTHONPATH').split(';'):\n" +
                    "   sys.path.append(path)\n" +
                    "clr.AddReference('SteamKit2.dll')\n" +
                    "class var:\n" +
                    "   pass",
                    scope
                    );
                pyEngine.ExecuteFile(Path, scope);
            }
            catch (Exception e)
            {
                ModuleManager.PrintStackFrame(e);
                return(null);
            }

            SetModuleCallbacks(scope);

            Variables = new ExpandoObject();
            //Variables = scope.GetVariable("var");

            // Add the name and description to the dynamic object, so you can
            // get that info in your script.
            Variables.Name        = Name;
            Variables.Description = Description;

            // Add any functions to Variables
            foreach (var pyVarKV in scope.GetItems())
            {
                var    name  = pyVarKV.Key;
                var    value = pyVarKV.Value;
                Action pyFunc;

                // Hide "private" variables
                if (name.StartsWith("_"))
                {
                    continue;
                }

                try
                {
                    if (scope.TryGetVariable <Action>(name, out pyFunc))
                    {
                        (Variables as IDictionary <string, object>).Add(name, value);
                    }
                }
                catch
                {
                    continue;
                }
            }

            return(scope);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Interprets a Python file and creates a module.
        /// </summary>
        /// <param name="file">The path of the Python file.</param>
        public ScriptScope Interpret(SteamNerd steamNerd, ScriptEngine pyEngine)
        {
            Commands.Clear();
            var scope = pyEngine.CreateScope();

            SayCallback say = (message, receiver) => Say(message, receiver);
            scope.SetVariable("SteamNerd", steamNerd);
            scope.SetVariable("Module", this);
            scope.SetVariable("Say", say);

            try
            {
                // Add a "var" class to get all of the script variables.
                // And add a way to reference SteamKit2.
                pyEngine.Execute(
                    "from System import Environment\n" +
                    "import clr\n" +
                    "import sys\n" +
                    "sys.path.append(r'" + Directory.GetCurrentDirectory() + "')\n" +
                    "sys.path.append(r'" + ModuleManager.ModulesDirectory + "')\n" +
                    "for path in Environment.GetEnvironmentVariable('IRONPYTHONPATH').split(';'):\n" +
                    "   sys.path.append(path)\n" +
                    "clr.AddReference('SteamKit2.dll')\n" +
                    "class var:\n" +
                    "   pass",
                    scope
                );
                pyEngine.ExecuteFile(Path, scope);
            }
            catch (Exception e)
            {
                ModuleManager.PrintStackFrame(e);
                return null;
            }

            SetModuleCallbacks(scope);

            Variables = new ExpandoObject();
            //Variables = scope.GetVariable("var");

            // Add the name and description to the dynamic object, so you can
            // get that info in your script.
            Variables.Name = Name;
            Variables.Description = Description;

            // Add any functions to Variables
            foreach (var pyVarKV in scope.GetItems())
            {
                var name = pyVarKV.Key;
                var value = pyVarKV.Value;
                Action pyFunc;

                // Hide "private" variables
                if (name.StartsWith("_")) continue;

                try
                {
                    if (scope.TryGetVariable<Action>(name, out pyFunc))
                    {
                        (Variables as IDictionary<string, object>).Add(name, value);
                    }
                }
                catch
                {
                    continue;
                }

            }

            return scope;
        }