Class: Steam::Handler::SteamUser
- Inherits:
-
Object
- Object
- Steam::Handler::SteamUser
- Includes:
- Base
- Defined in:
- lib/steam/handler/steam_user.rb
Overview
Note:
You need to handle the LogonResponse to catch Steam Guard prompts and 2FA
Handles messages releated to a Steam user
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
-
#change_persona_name(name) ⇒ Object
Change the Client's name.
-
#change_persona_state(state) ⇒ Object
Change the Client's persona state.
-
#handle(packet) ⇒ Object
Handles a given packet.
-
#login(username, password, token = nil, hash = nil) ⇒ Object
rubocop:disable MethodLength rubocop:disable AbcSize.
-
#logoff ⇒ Bool
Logs the Client off the Steam network.
Methods included from Base
#handles?, included, #initialize, #send_msg
Instance Method Details
#change_persona_name(name) ⇒ Object
Change the Client's name
81 82 83 84 85 86 87 88 89 |
# File 'lib/steam/handler/steam_user.rb', line 81 def change_persona_name(name) client_status = Steamclient::CMsgClientChangeStatus.new client_status.player_name = name client_change_status = ProtobufMessage.new(MsgHdrProtoBuf.new, client_status, EMsg::CLIENT_CHANGE_STATUS) send_msg(client_change_status) end |
#change_persona_state(state) ⇒ Object
Change the Client's persona state.
63 64 65 66 67 68 69 70 71 |
# File 'lib/steam/handler/steam_user.rb', line 63 def change_persona_state(state) client_status = Steamclient::CMsgClientChangeStatus.new client_status.persona_state = state client_change_status = ProtobufMessage.new(MsgHdrProtoBuf.new, client_status, EMsg::CLIENT_CHANGE_STATUS) send_msg(client_change_status) end |
#handle(packet) ⇒ Object
Handles a given packet
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/steam/handler/steam_user.rb', line 104 def handle(packet) case packet.msg_type when EMsg::CLIENT_LOG_ON_RESPONSE handle_client_logon_response(packet) when EMsg::CLIENT_UPDATE_MACHINE_AUTH handle_machine_auth_update(packet) when EMsg::CLIENT_NEW_LOGIN_KEY handle_login_key(packet) when EMsg::CLIENT_LOGGED_OFF handle_client_logoff(packet) end end |
#login(username, password, token = nil, hash = nil) ⇒ Object
rubocop:disable MethodLength rubocop:disable AbcSize
Log a Client in
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/steam/handler/steam_user.rb', line 31 def login(username, password, token = nil, hash = nil) msg = ProtobufMessage.new(MsgHdrProtoBuf.new, Steamclient::CMsgClientLogon.new, EMsg::CLIENT_LOGON) msg.body.auth_code = token if token msg.body.eresult_sentryfile = EResult::FILE_NOT_FOUND if hash msg.body.sha_sentryfile = hash msg.body.eresult_sentryfile = EResult::OK end ip = LocalIp.new.to_i ^ MsgClientLogon::OBFUSCATION_MASK msg.body.obfustucated_private_ip = ip msg.body.account_name = username msg.body.password = password msg.body.protocol_version = MsgClientLogon::CURRENT_PROTOCOL msg.body.client_os_type = EOSType::WIN311 msg.body.client_package_version = 1771 send_msg(msg) end |
#logoff ⇒ Bool
Logs the Client off the Steam network
94 95 96 97 98 99 |
# File 'lib/steam/handler/steam_user.rb', line 94 def logoff logoff = ProtobufMessage.new(MsgHdrProtoBuf.new, Steamclient::CMsgClientLogOff.new, EMsg::CLIENT_LOG_OFF) send_msg(logoff) end |