class csgo_client (object): def __init__(self, config): self._client = SteamClient() self._client.set_credential_location(config["steam_credential_location"]) self._cs = CSGOClient(self._client) self._ready = False @self._client.on("channel_secured") def send_login(): if self._client.relogin_available: self._client.relogin() @self._client.on("disconnected") def handle_disconnect(): logging.warning("disconnected from steam") if self._client.relogin_available: self._client.reconnect(maxdelay=10) @self._client.on('logged_on') def start_csgo(): logging.info("connecting to csgo") self._cs.launch() @self._cs.on('ready') def gc_ready(): logging.info("connected") self._ready = True self._client.cli_login(username=config["steam_bot_username"], password=config["steam_bot_password"]) while not self._ready: self._client.sleep(0.125) def send(self, *args, **kwargs): self._cs.send(*args, **kwargs) def wait_event(self, *args, **kwargs): return self._cs.wait_event(*args, **kwargs) def get_item_killcount(self, s, a, d): if not self._cs.connection_status == GCConnectionStatus.HAVE_SESSION: logging.warning("not connected to GC") raise ValueError("not connected to gc") self.send(ECsgoGCMsg.EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest, { 'param_s': s, 'param_a': a, 'param_d': d, 'param_m': 0 }) response, = self.wait_event(ECsgoGCMsg.EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse, timeout=2) if response.iteminfo.itemid != a: raise ValueError("mismatched req/rep") return response.iteminfo.killeatervalue
def command(): client = SteamClient() client.set_credential_location(settings.STEAM_SENTRY_DIR) for index, username in enumerate(settings.STEAM_USERNAMES): click.echo(f"Logging into Steam as {username}...") client.cli_login(username=username, password=settings.STEAM_PASSWORDS[index]) time.sleep(5) # copy to correct location for `auth-ticket.js` src = os.path.join(settings.STEAM_SENTRY_DIR, f"{username}_sentry.bin") dest = os.path.join(settings.STEAM_SENTRY_DIR, f"sentry.{username}.bin") copy2(src, dest) click.echo("Login successful. Steam Guard should not prompt anymore") client.logout()
def run_account(acc): client = SteamClient() client.set_credential_location('creds') cs = CSGOClient(client) profile = gevent.event.Event() matches = gevent.event.Event() events.append(profile) events.append(matches) @client.on('logged_on') def start_csgo(): print("Logged in!") cs.launch() print("Launched CS:GO") @client.on('new_login_key') def key(): print(f"New login key for {acc['username']}!") acc['login_key'] = client.login_key #@client.on(None) #def kek(msgtype, msg=None): # print(msgtype) # print(msg) @client.on(EMsg.ClientVACBanStatus) def vac_status(msg): acc['bans'] = msg.body.numBans @client.on(EMsg.ClientEmailAddrInfo) def email(msg): acc['email'] = msg.body.email_address @client.on(EMsg.ClientAccountInfo) def name(msg): acc['name'] = msg.body.persona_name @client.on(EMsg.ClientWalletInfoUpdate) def name(msg): if msg.body.currency: acc['wallet_balance'] = msg.body.balance64 acc['wallet_balance_delayed'] = msg.body.balance64_delayed acc['wallet_currency'] = msg.body.currency @cs.on('ready') def gc_ready(): print("CS:GO Ready!") cs.request_player_profile(cs.account_id) cs.request_recent_user_games(cs.account_id) print("Requested player profile info") @cs.on('recent_user_games') def got_matches(resp): if len(resp.matches) > 0: acc['last_mm'] = resp.matches[-1].matchtime matches.set() @cs.on('player_profile') def got_profile(response): if response.account_id == cs.account_id: print(f"Got {acc['username']} CS:GO profile!") acc['csgo_profile'] = json.loads(json_format.MessageToJson(response)) #cs.exit() #client.logout() profile.set() # def cleanup(): print(f'Logging in to {acc["username"]}') if 'login_key' not in acc or client.login(acc['username'], login_key=acc['login_key']) != 1: client.cli_login(acc['username'], acc['password'])
from steam.enums import EResult #The interval between checking for new posts refreshInterval = 15 #ARMA 3 Looking for a unit community forum unitForumURL = 'https://steamcommunity.com/app/107410/discussions/21/' #begin as empty string but is used to refrence if the found post is new or not oldPosts = [] #The URL for the discord Webhook url = "Replace Discord Webhook Here" #Creating the steam client client = SteamClient() #set location to store sentry files and other stuff client.set_credential_location(".") #logs into steam client client.cli_login() #creating a web session session = client.get_web_session() #allows to reconnect upon error @client.on("disconnected") def handle_disconnect(): if client.relogin_available: client.reconnect(maxdelay=30)
import logging from steam.client import SteamClient from steam.enums import EResult # setup logging logging.basicConfig(format="%(asctime)s | %(message)s", level=logging.INFO) LOG = logging.getLogger() 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)) @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):
if __name__ == "__main__": save = questionary.confirm( default=True, message="Save your input to a cache file?").ask() pre_username = load_from_cache('username') pre_password = load_from_cache('password') pre_selected_friends = load_from_cache('selected_friends') username = questionary.text(default=pre_username, message="Your Steam username?").ask() password = questionary.password(default=pre_password, message="Your Steam password?").ask() if save: merge_to_cache({'username': username, 'password': password}) cl = SteamClient() cl.set_credential_location('.') cl.cli_login(username=username, password=password) api = WebAPI(key=fetch_web_api_key(cl)) friends = list( fetch_friends(cl) ) # we need to listify it, to be able to use it twice. TODO: Investigate how to clone generator/iterator? loop = True while loop: pre_selected_friends = load_from_cache('selected_friends') qfriends = list( questionize_friends(deepcopy(friends), pre_selected_friends)) selected_friends = questionary.checkbox('Select friends to compare', choices=qfriends).ask()
class SteamNotifier(object, metaclass=Singleton): _instantiated = False _running = False _notification = None def create(self, path): if not self._instantiated: self._instantiated = True self._cache = path + '/cache/' if not os.path.exists(self._cache): os.makedirs(self._cache) # Steam Client self._steamClient = SteamClient() # Hook Steam Client Events self._steamClient.on(SteamClient.EVENT_AUTH_CODE_REQUIRED, self.auth_code_prompt) self._steamClient.on("FriendMessagesClient.IncomingMessage#1", self.handle_message) self._steamClient.on(SteamClient.EVENT_LOGGED_ON, self.login_success) self._steamClient.on(SteamClient.EVENT_CHANNEL_SECURED, self.login_secured) self._steamClient.on(SteamClient.EVENT_ERROR, self.login_error) self._steamClient.on(SteamClient.EVENT_CONNECTED, self.connected) self._steamClient.on(SteamClient.EVENT_DISCONNECTED, self.disconnected) self._steamClient.on(SteamClient.EVENT_NEW_LOGIN_KEY, self.new_login_key) # Bind EndPoints RyderClient().addEndPoint('on_connect', self._run) RyderClient().addEndPoint('steamLogin', self._steamLoginData) RyderClient().addEndPoint('steam2fa',self._steam2faData) def setupNotificationHandlerHook(self, notification): self._notification = notification def _run(self): # Start Login Sequence if not self._running: self._running = True self._steamClient.set_credential_location(self._cache) if os.path.exists(self._cache + 'steam.txt'): f = open(self._cache + 'steam.txt', 'r') data = f.readlines() f.close() gevent.spawn_later(2, SteamClient.login, self._steamClient, username=data[0].replace('\n',''), login_key=data[1]) else: if self._notification != None: self._notification('Steam', 'Login', 'Requesting Login Data') RyderClient().send("[\"steamLogin\"]") def _steamLoginData(self, data): print('Steam login data received') self._login_data = [data[1], data[2]] self._steamClient.login(username=self._login_data[0], password=self._login_data[1]) def _steam2faData(self, data): print("Steam 2FA data received") self._steamClient.login(two_factor_code=data[1], username=self._login_data[0], password=self._login_data[1]) # Handle SteamClient events def connected(self): print("Connected") def disconnected(self): print("Disconnected") if self._steamClient.relogin_available: if self._notification != None: self._notification('Steam', self._steamClient.username, 'Connection lost! Re-trying...') self._steamClient.reconnect(maxdelay=30) def login_secured(self): print("Login secured") if self._steamClient.relogin_available: self._steamClient.relogin() def login_error(self, data): print("Login error") print(data) if data == EResult.InvalidPassword: if self._notification != None: self._notification('Steam', 'Login', 'Requesting Login Data') RyderClient().send("[\"steamLogin\"]") def auth_code_prompt(self, is2fa, code_mismatch): print("Steam2FA Required") if self._notification != None: self._notification('Steam', 'Login', 'Requesting 2 Factor Authentication') RyderClient().send("[\"steam2fa\"]") def handle_message(self, msg): if msg.body.chat_entry_type == EChatEntryType.ChatMsg and not msg.body.local_echo: user = self._steamClient.get_user(msg.body.steamid_friend) text = msg.body.message if self._notification != None: self._notification('Steam', user.name, text) def login_success(self): print("Login successfull") self._steamClient.change_status(persona_state = EPersonaState.Invisible) if self._notification != None: self._notification('Steam', self._steamClient.username, 'Logged in!') def new_login_key(self): print("New login key") f = open(self._cache + 'steam.txt', 'w') f.write(self._steamClient.username + '\n' + self._steamClient.login_key) f.close()