Exemple #1
0
    def __init__(
        self,
        pollInterval=10,
        ircClient: IRC_Client = None,
        settings=None
                ):
        threading.Thread.__init__(self)
        try:
            logging.info("Memory Monitor Started!")
            self.running = True

            self.settings = settings
            if not settings:
                self.settings = Settings()

            self.pm = None
            self.baseAddress = None
            self.gameInProgress = False

            self.ircClient = ircClient
            self.pollInterval = int(pollInterval)
            self.event = threading.Event()
            self.gameData = None
            self.winLostTimer = None

        except Exception as e:
            logging.error("In FileMonitor __init__")
            logging.error(str(e))
            logging.exception("Exception : ")
    def __init__(self, ucsPath=None, settings=None) -> None:

        self.settings = settings
        if not settings:
            self.settings = Settings()

        self.ucsPath = ucsPath
        if not ucsPath:
            self.ucsPath = self.settings.data.get('cohUCSPath')
Exemple #3
0
    def __init__(self, settings=None):
        self.settings = settings
        if not settings:
            self.settings = Settings()

        # Declare instance variables for storing data
        # returned from server (nested List/Dictionary)
        self.userStatCache = None
        self.userMatchHistoryCache = None
        self.availableLeaderboards = None
Exemple #4
0
    def __init__(self, ircClient=None, settings=None):
        """Instanciates a new object of type GameData"""

        self.settings = settings
        if not settings:
            self.settings = Settings()

        # Local reference to the IRC client
        self.ircClient = ircClient

        # Pymem handle
        self.pm = None
        self.baseAddress = None
        self.cohProcessID = None

        # Replay Data Default Values
        self.playerList = []
        self.numberOfHumans = 0
        self.numberOfComputers = 0
        self.easyCPUCount = 0
        self.normalCPUCount = 0
        self.hardCPUCount = 0
        self.expertCPUCount = 0
        self.numberOfPlayers = 0
        self.slots = 0
        self.matchType = MatchType.CUSTOM
        self.cohRunning = False
        self.gameInProgress = False
        self.gameStartedDate = None

        self.randomStart = None
        self.highResources = None
        self.VPCount = None
        self.automatch = None
        self.mapName = None
        self.mapNameFull = ""
        self.modName = None
        self.mapDescription = None
        self.mapDescriptionFull = ""
        self.gameDescriptionString = ""

        # This holds a list of IRC string outputs.
        self.ircStringOutputList = []
    def __init__(
        self,
        ircClient,
        ircSocket: socket,
        queue,
        channel,
        settings=None
            ):
        Thread.__init__(self)
        self.ircClient = ircClient
        self.running = True
        self.ircSocket = ircSocket
        self.queue = queue
        self.channel = channel

        self.settings = settings
        if not settings:
            self.settings = Settings()

        self.gameData = GameData(self.ircClient, settings=self.settings)
Exemple #6
0
    def test_output(self):
        """Produces text output according to Preformat."""
        if not self.settings:
            self.settings = Settings()

        steamNumber = self.settings.data.get('steamNumber')
        statsRequest = StatsRequest(settings=self.settings)
        streamerStats = statsRequest.return_stats(str(steamNumber))
        streamerPlayer = Player(name=self.settings.data.get('channel'))
        streamerPlayer.stats = streamerStats
        if streamerPlayer.stats:
            output = (
                "Streamer Full Stat list formatted according"
                " to Custom Chat Output Preformat:"
            )
            self.ircClient.send_to_outputfield(output)
            preformat = self.settings.data.get('customStringPreFormat')
            self.ircClient.send_to_outputfield(preformat)

            for match in MatchType:
                for faction in Faction:
                    for value in streamerPlayer.stats.leaderboardData:
                        ld = streamerPlayer.stats.leaderboardData[value]
                        playerFaction = str(ld.faction)
                        if (playerFaction == str(faction)):
                            playerMatchtype = str(ld.matchType)
                            if (playerMatchtype == str(match)):
                                self.matchType = match
                                streamerPlayer.faction = faction
                                self.__produceOutput(streamerPlayer)

        else:
            output = (
                "I could not get stats from the stat server using steam# "
                f"{steamNumber} it might be down or the steam# might "
                "be invalid."
            )
            self.ircClient.send_to_outputfield(output)
Exemple #7
0
    def __init__(self, filePath=None, parameters=None) -> None:

        self.parameters = parameters
        if not parameters:
            self.parameters = Settings()

        self.filePath = filePath

        self.fileVersion = None
        self.chunkyVersion = None
        self.randomStart = None
        self.highResources = None
        self.VPCount = None
        self.matchType = None
        self.localDateString = None
        self.localDate = None
        self.unknownDate = None
        self.replayName = None
        self.gameVersion = None
        self.modName = None
        self.mapName = None
        self.mapNameFull = None
        self.mapDescription = None
        self.mapDescriptionFull = None
        self.mapFileName = None
        self.mapWidth = None
        self.mapHeight = None
        self.playerList = []

        self.success = None

        self.data = None
        self.dataIndex = 0

        if filePath:
            self.load(self.filePath)
    def __init__(self, output, consoleDisplayBool, settings=None):

        threading.Thread.__init__(self)

        self.output = output

        self.displayConsoleOut = consoleDisplayBool

        self.settings = settings
        if not settings:
            self.settings = Settings()

        self.adminUserName = self.settings.privatedata.get('adminUserName')
        # This username will be able to use admin commands
        # exit the program and bypass some limits.

        # use botusername or get default if not set
        if (self.settings.data.get('botUserName') == ""):
            self.nick = self.settings.privatedata.get('IRCnick')
            # This value is the username used to connect to IRC
            # eg: "xcomreborn".
        else:
            self.nick = self.settings.data.get('botUserName')

        self.channel = "#" + self.settings.data.get('channel').lower()
        # The channel name for your channel eg: "#xcomreborn".

        # use botoauthkey or get default if not set
        if (self.settings.data.get('botOAuthKey') == ""):
            self.password = self.settings.privatedata.get('IRCpassword')
        else:
            self.password = self.settings.data.get('botOAuthKey')

        self.server = self.settings.privatedata.get('IRCserver')
        self.port = self.settings.privatedata.get('IRCport')
        rsp = self.settings.privatedata.get('relicServerProxy')
        self.relicServerProxy = rsp

        # create IRC socket
        try:
            self.ircSocket = socket.socket()
        except Exception as e:
            logging.error("A problem occurred trying to connect")
            logging.error("In IRCClient")
            logging.error(str(e))
            logging.exception("Exception : ")
            self.ircSocket.close()
            sys.exit(0)

        # irc send message buffer
        self.ircMessageBuffer = collections.deque()
        self.messageBufferTimer = None

        self.running = True

        # Start checking send buffer every 3 seconds.

        self.check_IRC_send_buffer_every_three_seconds()
        # only call this once.

        try:
            self.ircSocket.connect((self.server, self.port))
        except Exception as e:
            logging.error("A problem occurred trying to connect")
            logging.error("In IRCClient")
            logging.error(str(e))
            logging.exception("Exception : ")
            self.ircSocket.close()
            sys.exit(0)

        # sends variables for connection to twitch chat
        self.ircSocket.send(('PASS ' + self.password + '\r\n').encode("utf8"))
        self.ircSocket.send(('USER ' + self.nick + '\r\n').encode("utf8"))
        self.ircSocket.send(('NICK ' + self.nick + '\r\n').encode("utf8"))
        self.ircSocket.send(
            ('CAP REQ :twitch.tv/membership' + '\r\n').encode("utf8"))
        # sends a twitch specific request
        # necessary to recieve mode messages
        self.ircSocket.send(
            ('CAP REQ :twitch.tv/tags' + '\r\n').encode("utf8"))
        # sends a twitch specific request for extra data
        # contained in the PRIVMSG changes the way it is parsed
        self.ircSocket.send(
            ('CAP REQ :twitch.tv/commands' + '\r\n').encode("utf8"))

        # start sub thread that uses shared Queue to communicate
        # pass it irc for messaging, channel to join and queue
        self.queue = Queue()
        self.channelThread = IRC_Channel(self,
                                         self.ircSocket,
                                         self.queue,
                                         self.channel,
                                         settings=self.settings)
        self.channelThread.start()