Пример #1
0
    def __init__(self):
        self.logged_on_once = False
        self.logon_details = {}

        self.steam = client = SteamClient()
        client.set_credential_location(".")

        @client.on("error")
        def handle_error(result):
            LOG.info("Logon result: %s", repr(result))

        @client.on("channel_secured")
        def send_login():
            if client.relogin_available:
                client.relogin()
            else:
                client.login(**self.logon_details)
                self.logon_details.pop('auth_code', None)
                self.logon_details.pop('two_factor_code', None)

        @client.on("connected")
        def handle_connected():
            LOG.info("Connected to %s", client.current_server_addr)

        @client.on("reconnect")
        def handle_reconnect(delay):
            LOG.info("Reconnect in %ds...", delay)

        @client.on("disconnected")
        def handle_disconnect():
            LOG.info("Disconnected.")

            if self.logged_on_once:
                LOG.info("Reconnecting...")
                client.reconnect(maxdelay=30)

        @client.on("auth_code_required")
        def auth_code_prompt(is_2fa, mismatch):
            if mismatch:
                LOG.info("Previous code was incorrect")

            if is_2fa:
                code = raw_input("Enter 2FA Code: ")
                self.logon_details['two_factor_code'] = code
            else:
                code = raw_input("Enter Email Code: ")
                self.logon_details['auth_code'] = code

            client.connect()

        @client.on("logged_on")
        def handle_after_logon():
            self.logged_on_once = True

            LOG.info("-" * 30)
            LOG.info("Logged on as: %s", client.user.name)
            LOG.info("Community profile: %s", client.steam_id.community_url)
            LOG.info("Last logon: %s", client.user.last_logon)
            LOG.info("Last logoff: %s", client.user.last_logoff)
            LOG.info("-" * 30)
Пример #2
0
 def __init__(self, username, password, guardCode, twoFactorCode):
     #Declare class variables
     self.client = SteamClient()
     self.guardCode = guardCode
     self.loginResult = "Not logged in"
     self.twoFactorCode = twoFactorCode
     self.username, self.password = username, password
Пример #3
0
def Start():
    url = input("Market url: ")
    count = int(input("Number of items to load: "))
    wanted = float(input("Which float are you aiming for? "))
    specificity = float(
        input("How much above float are you willing to show? "))
    inspect_price_list = getMarketItems(url, count)
    inspect_list = inspect_price_list[0]
    price_list = inspect_price_list[1]

    print("")
    ready = False
    while (ready == False):
        try:
            print("Try to log in")
            client = SteamClient()
            cs = CSGOClient(client)

            @client.on('logged_on')
            def start_csgo():
                cs.launch()

            @cs.on('ready')
            def gc_ready():
                pass

            client.cli_login()
            ready = True
        except:
            print("There was an error, try again")
    print("Waiting 10 seconds for CSGO to start")
    print("")
    gevent.sleep(10)

    Get_Item_Data(inspect_list, price_list, cs, wanted, specificity)
Пример #4
0
def invite(steam_ids, bot_account, lobby_name):
    client = SteamClient()
    dota = Dota2Client(client)

    steam_ids = [int(steamid) for steamid in steam_ids]
    yielded = set()

    @client.on('connected')
    def log_in():
        client.login(username=bot_account.login, password=bot_account.password)

    @client.on('logged_on')
    def start_dota():
        dota.launch()

    @dota.once('ready')
    def create_a_lobby():
        dota.create_practice_lobby(password=token_hex(16), options={
            'game_name': lobby_name,
        })

    @dota.once('lobby_new')
    def setup_and_invite_all(lobby):
        client.emit('info', 'lobby_created', random.choice(steam_ids))
        for steam_id in steam_ids:
            dota.invite_to_lobby(steam_id)

    @dota.on('lobby_changed')
    def handle_change(lobby):
        in_lobby = {member.id for member in lobby.members if member.id in steam_ids}
        pending = {steamid for steamid in lobby.pending_invites if steamid in steam_ids}
        leavers = set(steam_ids) - (in_lobby | pending)

        nonlocal yielded
        to_yield = in_lobby - yielded
        for steam_id in to_yield:
            yielded.add(steam_id)
            client.emit('info', 'in_lobby', steam_id)

        if len(in_lobby) == len(steam_ids):
            dota.leave_practice_lobby()

        if leavers:
            leaver_id = list(leavers)[0]
            dota.destroy_lobby()
            client.emit('info', 'leaver', leaver_id)

    @dota.on('lobby_removed')
    def finish_cycle(lobby):
        client.emit('info', 'cycle_finished')

    connect_with_retry(client)
    while True:
        args = client.wait_event('info')
        if args[0] == 'cycle_finished':
            return
        else:
            assert len(args) == 2
            yield args
def Start():
    once = 0
    while True:
        if (once == 0):
            client = SteamClient()
            cs = CSGOClient(client)
            @client.on('logged_on')
            def start_csgo():
                cs.launch()
            @cs.on('ready')
            def gc_ready():
                pass
            client.cli_login()
            print("Waiting 10 seconds for CSGO to start")
            print("")
            gevent.sleep(10)
        once += 1
            
        db = sqlite3.connect('database.db')
        c = db.cursor()
        c.execute('CREATE TABLE IF NOT EXISTS inspectsTable(inspects TEXT)')
        c.execute('SELECT * FROM inspectsTable')
        alreadyHave = []
        for row in c.fetchall():
            inspectlink = row[0]
            alreadyHave.append(inspectlink)
        inspect_list = []
        price_list = []
        n = 0
        fail = 0
        while(n < len(externalLists.marketIndex)):
            cs.launch()
            current_market_link = externalLists.marketIndex[n] 
            inspect_price_temp = Get_Inspects(current_market_link, alreadyHave, db, c, fail)
            if (len(inspect_price_temp) == 2 or inspect_price_temp[0] == 'none'):
                if (inspect_price_temp[0] == 'none'):
                    n += 1
                else:
                    inspect_list = inspect_list + inspect_price_temp[0]
                    price_list = price_list + inspect_price_temp[1]
                    n += 1
            if (inspect_price_temp[0] == 'fail'):
                print("Retrying %s waiting 30 seconds..." % current_market_link)
                gevent.sleep(30)
                
        c.close()
        db.close()

        print("")
        
        
        bg = sqlite3.connect('bluegem.db')
        d = bg.cursor()
        d.execute('CREATE TABLE IF NOT EXISTS bluegemTable(info TEXT)')
        
        Get_Item_Data(inspect_list, price_list, cs, bg, d)
            
        d.close()
        bg.close()
Пример #6
0
def last_build(game_id):
    """Retrieves the timestamp of the last update to the public branch in steam"""
    sc = SteamClient()
    sc.anonymous_login()
    info = sc.get_product_info(apps=[game_id])
    fact = info['apps'][game_id]['depots']['branches']
    last_updated = int(fact['public']['timeupdated'])
    last_dt = datetime.datetime.fromtimestamp(last_updated)
    return last_dt
Пример #7
0
    def __init__(self, worker_manager, credential, job):
        """Initialize the Dota bot thread for a unique job process.

        Args:
            worker_manager: `DazzarWorkerManager` this bot is linked to.
            credential: `Credential` used to connect to steam.
            job: `Job` to process by the bot.
        """
        Greenlet.__init__(self)

        self.credential = credential
        self.worker_manager = worker_manager
        self.job = job

        self.client = SteamClient()
        self.dota = dota2.Dota2Client(self.client)
        self.app = self.worker_manager.app

        self.job_started = False
        self.game_creation_call = False
        self.job_finished = False

        self.match = None
        self.players = None

        self.game_status = None
        self.lobby_channel_id = None
        self.invite_timer = None
        self.missing_players = None
        self.missing_players_count = None
        self.wrong_team_players = None
        self.wrong_team_players_count = None

        # Prepare all event handlers
        # - Steam client events
        # - Dota client events
        # - Dazzar bot events
        self.client.on('connected', self.steam_connected)
        self.client.on('logged_on', self.steam_logged)

        self.dota.on('ready', self.dota_ready)
        self.dota.on('notready', self.closed_dota)

        self.dota.on('profile_card', self.scan_profile_result)
        self.dota.on('player_info', self.scan_player_info)
        self.dota.on(dota2.features.Lobby.EVENT_LOBBY_NEW,
                     self.vip_game_created)
        self.dota.on(dota2.features.Lobby.EVENT_LOBBY_CHANGED,
                     self.game_update)
        self.dota.on(dota2.features.Chat.EVENT_CHANNEL_JOIN, self.channel_join)
        self.dota.on(dota2.features.Chat.EVENT_CHANNEL_MESSAGE,
                     self.channel_message)
Пример #8
0
def connect_to_steam():
    client = SteamClient()

    while True:
        result = client.anonymous_login()

        if result == EResult.OK:
            break
        else:
            print('{} Error while logging, retrying in 10 seconds...'.format(
                Consts.LOG_PREFIX))
            time.sleep(10)

    return client
Пример #9
0
def send_friend_request(steam_id, bot_account):
    client = SteamClient()
    steam_id = int(steam_id)

    @client.on('connected')
    def log_in():
        client.login(username=bot_account.login, password=bot_account.password)

    @client.friends.on('ready')
    def send_request():
        client.friends.add(steam_id)

    connect_with_retry(client)
    eresult, steam_id = client.friends.wait_event(client.friends.EVENT_FRIEND_ADD_RESULT)
    return eresult == EResult.OK, eresult
Пример #10
0
    def run(self):
        logging.basicConfig(format="%(asctime)s | %(message)s",
                            level=logging.INFO)
        LOG = logging.getLogger()
        global client
        client = SteamClient()
        client.set_credential_location(
            ".")  # where to store sentry files and other stuff

        @client.on("error")
        def handle_error(result):
            LOG.info("Logon result: %s", repr(result))
            if result == EResult.RateLimitExceeded:
                self.loginInfo.emit(996, '')
                self.needlogin = False

        @client.on("channel_secured")
        def send_login():
            if client.relogin_available:
                client.relogin()

        @client.on("connected")
        def handle_connected():
            LOG.info("Connected to %s", client.current_server_addr)

        @client.on("reconnect")
        def handle_reconnect(delay):
            LOG.info("Reconnect in %ds...", delay)

        @client.on("disconnected")
        def handle_disconnect():
            LOG.info("Disconnected.")
            if client.relogin_available:
                LOG.info("Reconnecting...")
                client.reconnect(maxdelay=30)

        # main bit
        LOG.info("Persistent logon recipe")
        LOG.info("-" * 30)
        while True:
            self.msleep(10)
            self.run_num = 0
            if self.needlogin:
                self.login()
            if self.needlogout:
                self.logout()
            if self.needredeem:
                self.redeem()
Пример #11
0
def send_chat_message(steam_id, bot_account, message):
    client = SteamClient()
    steam_id = int(steam_id)

    @client.on('connected')
    def log_in():
        client.login(username=bot_account.login, password=bot_account.password)

    @client.on('logged_on')
    def send_message():
        recipient = client.get_user(steam_id, fetch_persona_state=False)
        recipient.send_message(message)
        client.emit('cycle_finished')

    connect_with_retry(client)
    client.wait_event('cycle_finished')
Пример #12
0
    def __init__(self):
        self.logged_on_once = False

        self.steam = client = SteamClient()
        client.set_credential_location(".")

        @client.on("error")
        def handle_error(result):
            LOG.info("Logon result: %s", repr(result))

        @client.on("connected")
        def handle_connected():
            LOG.info("Connected to %s", client.current_server_addr)

        @client.on("channel_secured")
        def send_login():
            if self.logged_on_once and self.steam.relogin_available:
                self.steam.relogin()

        @client.on("logged_on")
        def handle_after_logon():
            self.logged_on_once = True

            LOG.info("-"*30)
            LOG.info("Logged on as: %s", client.user.name)
            LOG.info("Community profile: %s", client.steam_id.community_url)
            LOG.info("Last logon: %s", client.user.last_logon)
            LOG.info("Last logoff: %s", client.user.last_logoff)
            LOG.info("-"*30)

        @client.on("disconnected")
        def handle_disconnect():
            LOG.info("Disconnected.")

            if self.logged_on_once:
                LOG.info("Reconnecting...")
                client.reconnect(maxdelay=30)

        @client.on("reconnect")
        def handle_reconnect(delay):
            LOG.info("Reconnect in %ds...", delay)
Пример #13
0
def wait_for_friend_request_answer(steam_id, bot_account, block=True):
    client = SteamClient()
    steam_id = int(steam_id)

    @client.on('connected')
    def log_in():
        client.login(username=bot_account.login, password=bot_account.password)

    @client.friends.on('ready')
    @client.friends.on('friend_new')
    def check_friends(*args):
        nonlocal client
        friends = {
            int(friend.steam_id)
            for friend in client.friends if friend.relationship == EFriendRelationship.Friend
        }
        if steam_id in friends:
            client.emit('cycle_finished', True)
        elif not block:
            client.emit('cycle_finished', False)

    connect_with_retry(client)
    in_friends = client.wait_event('cycle_finished')[0]
    return in_friends
def main(dirname):
    client = SteamClient()

    print("Steam Cards Wallpaper Downloader")
    print("-" * 20)

    try:
        result = client.cli_login()
    except (EOFError, KeyboardInterrupt):
        _user_aborted()
        raise SystemExit

    if result != EResult.OK:
        print("Failed to login: %s" % repr(result))
        raise SystemExit
    print("-" * 20)
    print("Logged on as:", client.user.name)

    try:
        scraper.scrape(client, dirname)
    except KeyboardInterrupt:
        _user_aborted()
    finally:
        client.logout()
Пример #15
0
 def boost(self, db):
     try:
         self.clients[db.username] = SteamClient()
         if db.authcode == '' or db.authcode is None:
             self.error(db)
             return
         authCodes = decode(BOOST_ENCRYPTION_KEY, db.authcode).split('-')
         authcode = authCodes[0]
         del authCodes[0]
         db.authcode = encode(BOOST_ENCRYPTION_KEY, '-'.join(authCodes))
         db.save()
         try:
             resp = self.clients[db.username].login(
                 db.username,
                 decode(BOOST_ENCRYPTION_KEY, db.password),
                 two_factor_code=authcode)
             if resp != EResult.OK:
                 raise Exception('login failed')
         except:
             self.error(
                 db,
                 message=
                 '[Hour Boost - %s] კოდი %s არასწორი იყო, ბუსტი გაგრძელდება დარჩენილი Backup კოდებით (თუ არსებობს)'
                 % (db.username, authcode))
             return
         print(
             colored(
                 '[Hour Boost] %s (%s) was started by %s Boosting %s Minutes ⌇ %s'
                 % (db.username, self.clients[db.username].user.steam_id,
                    db.user, db.target_time, db.games), 'cyan'))
         db.steam64id = str(self.clients[db.username].user.steam_id)
         db.save()
         count = 0
         while True:
             print(
                 colored(
                     '[Hour Boost] %s ⌇ %s/%s ⌇ %s' %
                     (db.username, db.boosted_time, db.target_time,
                      db.games), 'green'))
             if not self.clients[db.username].logged_on:
                 self.clients[db.username].relogin()
                 if not self.clients[
                         db.username].logged_on:  # if couldn't login
                     client.reconnect(maxdelay=30)
                     if not self.clients[
                             db.username].logged_on:  # if couldn't login
                         raise Exception('disconnected')
             self.clients[db.username].games_played(db.games.split('-'),
                                                    free=db.free)
             self.clients[db.username].sleep(1)
             count += 1
             if db.boosted_time >= db.target_time:
                 print(
                     colored(
                         '[Hour Boost] %s Finished Boosting %s Minutes ⌇ %s'
                         % (db.username, db.target_time, db.games), 'cyan'))
                 notify(User.objects.get(username=db.user),
                        '[Hour Boost - %s] ბუსტი დასრულდა' % db.username)
                 db.delete()
                 return
             # check if it's still in database (dynamic account removal)
             if not Hour_queue.objects.filter(id=db.id,
                                              finished=False).exists():
                 print(
                     colored(
                         '[Hour Boost] %s was cancelled ⌇ %s/%s ⌇ %s' %
                         (db.username, db.boosted_time, db.target_time,
                          db.games), 'cyan'))
                 del self.clients[db.username]
                 notify(User.objects.get(username=db.user),
                        '[Hour Boost - %s] ბუსტი გამოირთო' % db.username)
                 user.seen = False
                 user.save()
                 return
             if count >= 40:
                 count = 0
                 db.refresh_from_db()
                 db.boosted_time += 0.01
                 db.log = '%s/%s' % (db.boosted_time, db.target_time)
                 db.save()
     except:
         self.error(db)
Пример #16
0
    def __init__(self, parent, colorDic):
        #Declare class variables
        self.activeSecrets = None
        self.client = SteamClient()
        self.colorDic = colorDic
        self.conn = dataBase()
        self.apiKey = self.conn.get_api_key()
        self.apiController = api(self.apiKey)
        self.parent = parent
        self.guiControl = guiController(self.parent, self.colorDic)
        self.steamGuardController = None
        self.steamName = ""
        self.updateProgressBarID = None
        #Initialize window's frame
        Frame.__init__(self, self.parent)
        #Everything below is created in order from top of application to the bottom
        #Menu bar
        self.menuBar = Menu(self.parent, border=0)
        self.menuBar.config(bg=self.colorDic["menuBarBackground"],
                            fg=self.colorDic["menuBarForeground"])
        self.accountMenu = Menu(self.menuBar, tearoff=0)
        #New account and Import account button
        self.accountMenu.add_command(label="New Steam Guard",
                                     command=self.new_account_window)
        self.accountMenu.add_command(label="Delete Steam Guard",
                                     command=self.delete_steam_guard)
        #Seperator makes it look fabulous
        self.accountMenu.add_separator()
        self.accountMenu.add_command(label="Import Steam Guard")
        self.menuBar.add_cascade(label="Guard", menu=self.accountMenu)
        self.accountMenu.config(bg=self.colorDic["menuBarBackground"],
                                fg=self.colorDic["menuBarForeground"])
        self.editMenu = Menu(self.menuBar, tearoff=0)
        #Security preferences and color scheme button
        self.editMenu.add_command(label="Security Preferences")
        self.editMenu.add_command(label="Color Scheme")
        self.menuBar.add_cascade(label="Edit", menu=self.editMenu)
        self.editMenu.config(bg=self.colorDic["menuBarBackground"],
                             fg=self.colorDic["menuBarForeground"])
        #Window Title
        self.windowTitle = Label(self.parent, text="Steam Guard")
        self.windowTitle.configure(font=("Segoe UI", 12),
                                   bg=self.colorDic["windowTitleBackground"],
                                   fg=self.colorDic["windowTitleForeground"],
                                   width="350",
                                   pady=10)
        self.windowTitle.pack()
        #Guard codes and Steam name frame
        self.guardCodeHolder = Frame(self.parent,
                                     bg=self.colorDic["guardCodeBackground"])
        self.guardCodeHolder.pack()
        #Generated Steam Guard text
        self.guardLabel = Label(self.guardCodeHolder, text="...")
        self.guardLabel.configure(font=("Segoe UI", 30),
                                  bg=self.colorDic["guardCodeBackground"],
                                  fg=self.colorDic["guardCodeForeground"],
                                  width="350",
                                  pady=15)
        self.guardLabel.pack()
        #Styling for progress bar
        self.barStyle = ttk.Style()
        self.barStyle.theme_use('alt')
        self.barStyle.configure(
            "blue.Horizontal.TProgressbar",
            troughrelief="flat",
            troughcolor=self.colorDic["progressBarBackground"],
            background=self.colorDic["progressBarForeground"],
            relief="flat")
        #Progress bar
        self.progressBar = ttk.Progressbar(
            self.guardCodeHolder,
            style="blue.Horizontal.TProgressbar",
            orient="horizontal",
            length=250,
            mode="determinate")
        self.progressBar.pack()
        self.progressBar["maximum"] = 58
        #Steam name text
        self.steamNameLabel = Label(self.guardCodeHolder, text=self.steamName)
        self.steamNameLabel.configure(font=("Segoe UI", 10),
                                      bg=self.colorDic["guardCodeBackground"],
                                      fg=self.colorDic["steamNameForeground"],
                                      width="350",
                                      pady=5)
        self.steamNameLabel.pack()
        #Special buttons frame
        self.specialButtonsHolder = Frame(
            self.parent, bg=self.colorDic["specialButtonBackground"])
        self.specialButtonsHolder.pack(side="top", expand=True, fill="y")
        self.specialButtonsBackground = Frame(self.specialButtonsHolder,
                                              bg=self.colorDic["hrColor"],
                                              width="350",
                                              height="241")
        self.specialButtonsBackground.pack()
        self.specialButtonsBackground.pack_propagate(0)
        #"Confirmations" button frame
        self.confirmationHolder = Frame(
            self.specialButtonsBackground,
            bg=self.colorDic["specialButtonBackground"],
            width="350",
            height="79",
            cursor="hand2")
        self.confirmationHolder.pack(pady="1")
        self.confirmationLabel = Label(
            self.confirmationHolder,
            text="Confirmations",
            font=("Segoe UI", 15),
            bg=self.colorDic["specialButtonBackground"],
            fg=self.colorDic["specialButtonForeground"],
            cursor="hand2")
        self.confirmationLabel.pack(side="left", pady="15", padx="20")
        self.confirmationHolder.pack_propagate(0)
        self.confirmationHolder.bind("<Enter>",
                                     self.guiControl.special_button_hover)
        self.confirmationHolder.bind("<Leave>",
                                     self.guiControl.special_button_leave)
        self.confirmationHolder.bind("<Button-1>", self.confirmations_window)
        self.confirmationLabel.bind("<Button-1>", self.confirmations_window)
        #"Revocation" button frame
        self.revocationCodeHolder = Frame(
            self.specialButtonsBackground,
            bg=self.colorDic["specialButtonBackground"],
            width="350",
            height="79",
            cursor="hand2")
        self.revocationCodeLabel = Label(
            self.revocationCodeHolder,
            text="Revocation Code",
            font=("Segoe UI", 15),
            bg=self.colorDic["specialButtonBackground"],
            fg=self.colorDic["specialButtonForeground"],
            cursor="hand2")
        self.revocationCodeLabel.pack(side="left", pady="15", padx="20")
        self.revocationCodeHolder.pack()
        self.revocationCodeHolder.pack_propagate(0)
        self.revocationCodeHolder.bind("<Enter>",
                                       self.guiControl.special_button_hover)
        self.revocationCodeHolder.bind("<Leave>",
                                       self.guiControl.special_button_leave)
        self.revocationCodeHolder.bind("<Button-1>",
                                       self.revocation_code_window)
        self.revocationCodeLabel.bind("<Button-1>",
                                      self.revocation_code_window)
        #"Switch Account" button frame
        self.switchAccountHolder = Frame(
            self.specialButtonsBackground,
            bg=self.colorDic["specialButtonBackground"],
            width="350",
            height="79",
            cursor="hand2")
        self.switchAccountLabel = Label(
            self.switchAccountHolder,
            text="Switch Accounts",
            font=("Segoe UI", 15),
            bg=self.colorDic["specialButtonBackground"],
            fg=self.colorDic["specialButtonForeground"],
            cursor="hand2")
        self.switchAccountLabel.pack(side="left", pady="15", padx="20")
        self.switchAccountHolder.pack(pady="1")
        self.switchAccountHolder.pack_propagate(0)
        self.switchAccountHolder.bind("<Enter>",
                                      self.guiControl.special_button_hover)
        self.switchAccountHolder.bind("<Leave>",
                                      self.guiControl.special_button_leave)
        self.switchAccountHolder.bind("<Button-1>", self.switch_account_window)
        self.switchAccountLabel.bind("<Button-1>", self.switch_account_window)
        #Copy button frame
        self.buttonHolder = Frame(self.parent,
                                  bg=self.colorDic["appBackground"])
        self.copyCodeButton = Button(
            self.buttonHolder,
            text="Copy Code",
            command=lambda: self.guiControl.copy_label_text(self.guardLabel),
            font=("Segoe UI", 12),
            relief="flat",
            cursor="hand2")
        self.copyCodeButton.configure(
            fg=self.colorDic["actionButtonForeground"],
            bg=self.colorDic["actionButtonBackground"])
        self.copyCodeButton.pack(padx=30, pady=20, ipady=10, ipadx=10)
        self.buttonHolder.pack(side="bottom")
        #Set our window properties
        self.parent.geometry("350x500")
        self.parent.resizable(0, 0)
        self.parent.configure(bg=self.colorDic["appBackground"])
        self.parent.title("Steam Guardian")
        self.parent.config(menu=self.menuBar)
        self.guiControl.center()

        if self.conn.has_active_user():
            self.update_guard()
Пример #17
0
 def __init__(self, steam_user, steam_pass, steam_owner_id):
     self.steam_user = steam_user
     self.steam_pass = steam_pass
     self.steam_owner_id = steam_owner_id
     self.client = SteamClient()
Пример #18
0
from gevent import monkey
monkey.patch_ssl()

from steam import SteamClient
from dota2 import Dota2Client
from dota2.enums import EDOTAGCMsg
from steam import WebAPI
import time

client = SteamClient()
dota = Dota2Client(client)

OPEN_SPEED = 0.2

api_key = ''
api = ''

print("\n\nDue to limitations imposed by valve (f**k you skin gambling) you will need:")
print("\t1. An API KEY")
print("\t2. Your profile and inventory temporarily set to public")
print("API keys can be optained easily from: http://steamcommunity.com/dev/apikey\n\n")

while True:
    api_key = input("Enter your API key: ")
    try:
        api = WebAPI(key = api_key)
        break
    except:
        print("invalid key")

print("You will now be prompted to log in. You will not see any input when entering password.")
Пример #19
0
    def __init__(self, worker_manager, credential, admins, casters, id, name,
                 password, team1, team2, team1_ids, team2_ids,
                 team_choosing_first):
        """Initialize the Dota bot thread for a unique job process.

        Args:
            worker_manager: `DazzarWorkerManager` this bot is linked to.
            credential: `Credential` used to connect to steam.
        """
        Greenlet.__init__(self)

        # High Level properties
        self.credential = credential
        self.worker_manager = worker_manager
        self.app = self.worker_manager.app

        self.client = SteamClient()
        self.dota = dota2.Dota2Client(self.client)

        # Game settings
        self.id = id
        self.name = name
        self.password = password
        self.team1 = team1
        self.team2 = team2
        self.team1_ids = team1_ids
        self.team2_ids = team2_ids
        self.admins = admins
        self.casters = casters
        self.lobby_options = {
            'game_name': self.name,
            'pass_key': self.password,
            'game_mode': dota2.enums.DOTA_GameMode.DOTA_GAMEMODE_CM,
            'server_region': int(dota2.enums.EServerRegion.Europe),
            'fill_with_bots': False,
            'allow_spectating': True,
            #'allow_cheats': False,
            'allow_cheats': True,
            'allchat': False,
            'dota_tv_delay': 2,
            'pause_setting': 1,
            #'leagueid': 4947 # FTV LEAGUE SEASON 1
            #'leagueid': 9674 # FTV LEAGUE SEASON 2
        }

        # Choices
        self.team_choosing_first = team_choosing_first
        self.team_choosing_now = team_choosing_first
        self.team_choices = [None, None]
        self.team_choices_possibilities = ['!radiant', '!dire', '!fp', '!sp']
        self.team_inverted = False

        # State machine variables
        self.machine_state = DotaBotState.STARTING
        self.lobby_status = {}
        """
        self.lobby_channel_id = None
        self.invite_timer = None
        self.missing_players = None
        self.missing_players_count = None
        self.wrong_team_players = None
        self.wrong_team_players_count = None
        """
        # Prepare all event handlers
        # - Steam client events
        # - Dota client events
        # - Bot events
        self.client.on('connected', self.steam_connected)
        self.client.on('logged_on', self.steam_logged)
        self.client.on('disconnected', self.steam_disconnected)

        self.dota.on('ready', self.dota_ready)
        self.dota.on('notready', self.closed_dota)

        self.dota.on(dota2.features.Lobby.EVENT_LOBBY_NEW, self.game_hosted)
        self.dota.on(dota2.features.Lobby.EVENT_LOBBY_CHANGED,
                     self.game_update)
        self.dota.channels.on(
            dota2.features.chat.ChannelManager.EVENT_JOINED_CHANNEL,
            self.channel_join)
        self.dota.channels.on(dota2.features.chat.ChannelManager.EVENT_MESSAGE,
                              self.channel_message)