Skip to content

Commit

Permalink
pathofexile.com/trade support (#32)
Browse files Browse the repository at this point in the history
* Adds support for multiple sources

* Makes Socket a stateful object specific to provider

* Fixes issue with mixed up parameters

* Refactors socket class

* Removes stale comment

* Adds ggg sockets implementation

* Moves PoeTradeHelper to Poetrade module and renames to UriHelper

* Moves PoeTradeParser to Poetrade module and renames to HttpResponseParser

* Moves parsing logic from Socket to HttpResponseParser

* Refactors redirect error raising and makes matching more broad

* Fixes typo

* Adds: raise before OCRA build if no ssl support

* Fixes: install EM with ssl dir

* Tries to fix openssl path

* Tries to fix SSL support

* Fixes typo

* Aligns eventmachine version between appveyor config and gemfile

* Tries to get bundle to recognize installed eventmachine

* Tries a different version agnostic approach

* Adds spec for wss connection instead of EM.ssl? check

* Fixes enevtmachine version to solve a possible bug

* Tries to use newer version of EM with custom version of OpenSSL

* Revert "Tries to use newer version of EM with custom version of OpenSSL"

This reverts commit 62f3241.

* Adds test for EM.ssl? to be true

* Removes print clutter

* Adds clipboard spec

* Fixes testcase

* Adds actul error cases

* Removes clipboard tests, adds suggestion to change to other lib

* Adds encoding to wss link

* Use permessage_deflate

* Removes open, adds comfortable ping

* Revert "Removes open, adds comfortable ping"

This reverts commit eb7598b.

* Revert "Use permessage_deflate"

This reverts commit e477eaf.

* Revert "Adds encoding to wss link"

This reverts commit d822237.

* Adds poe session id cookie

* Adds `stored_data` cookie

* Re-adds permessage_deflate

* Fixes issue with sessionid

* Adds custom headers

* Adds header logging

* Changes: use pure ruby EM instead of native extension

* Revert "Changes: use pure ruby EM instead of native extension"

This reverts commit 6521640.

* Fixes typo

* Adds new config for local testing

* Fixes nomethoderror

* Removes unneeded require

* Fixes GGG uri helper

* Creates separate whisper classes per provider

* Removes ggg headers from config

* Removes everything form example input

* Adds instructions on how to create custom macro for paste; Removes reference to own project

* Improves logging

* Adds 20 minute keepalive ping to gg api

* Add poe-sniper-pro dependency

* trigger build

* Fix appveyor.yml

* Fix appveyor again

* appveyor pls

* Try another approach

* Try via bundle config

* fuck appveyor

* fuck appveyor

* Try something else

* Remove unneeded line

* Fix env var usage

* fuck appveyor

* Remove unnecessary appveyor setup

* Fix start_offline_debug rake task

* Update readme about test env setup

* Makes Poetrade Socket independent of Alert

* Change example input to use everything on standard

* Add sniper pro dependency

* Use latest version of poe-sniper-pro, Remove local dependencies

* Update poe-sniper-pro dependency

* Update org name

* Add authentication

* Remove ggg tests

* Fix tests

* Set ocra setting to include all gem files

* Set ocra setting to include full gem files

* Further OCRA debug

* Update poe-sniper-pro dependency (manually...)

* Add firebase auth gem

* Add bundler setup before start so that gems fetched form git are also recognized

* Try normal rubygem setup

* Add bundler default setup

* Add default bundelr setup

* Fix issue with bundler setup

* Add load path fuckery

* Add manual installation of poe-sniper-pro

* Simplify git clone

* .

* Try different clone

* .

* .

* .

* .

* .

* .

* .

* .

* .

* .

* Solve building with poe-sniper-pro dependency

* .

* Add meaningful error if auth fails

* Update README, bump version, update file locations, remove mention of json support

* Silence explicit gme install

* Handle another email error case

* Rename input key from ggg to pathofexilecom

* Change config format to yaml

* Fix failing tests

* Fix references to config.ini to point to config.yaml

* Update README

* Update README

* Use master for poe-sniper-pro and gem folder
  • Loading branch information
thisismydesign authored Feb 23, 2019
1 parent d454fde commit 453ceee
Show file tree
Hide file tree
Showing 42 changed files with 592 additions and 405 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Hey,

Sorry that something didn't work out and thanks for coming here to report it.

Before you do, take a look at existing issues because there might already by a related solution or discussion: https://github.com/thisismydesign/poe-sniper/issues?utf8=%E2%9C%93&q=is%3Aissue
Before you do, take a look at existing issues because there might already by a related solution or discussion: https://github.com/5k-mirrors/poe-sniper/issues?utf8=%E2%9C%93&q=is%3Aissue

Otherwise try to describe your issue as detailed as possible providing as much information as you can. At least include:
- the version you're using
Expand Down
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ ruby '>= 1.9.2'
# https://stackoverflow.com/a/44446172/2771889
ruby "2.3.3"

gem "eventmachine"
gem "eventmachine", "1.0.9.1", platforms: :ruby # https://github.com/eventmachine/eventmachine/issues/800
gem "faye-websocket"
gem "json"
gem "nokogiri"
gem "rb-notifu"
gem "win32-clipboard"
gem "win32-clipboard" # maybe change to https://github.com/janlelis/clipboard
gem "waitutil"
gem "parseconfig"
gem "analytics-ruby", '~> 2.0.0'
gem "dotenv"
gem "permessage_deflate"
gem 'poe-sniper-pro'

group :development, :test do
gem "rake", "~> 12.3"
Expand Down
41 changes: 37 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,49 @@ GEM
safe_yaml (~> 1.0.0)
diff-lcs (1.3)
docile (1.1.5)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.2.2)
eventmachine (1.2.5)
eventmachine (1.0.9.1)
faye-websocket (0.10.7)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
ffi (1.9.23)
ffi (1.9.23-x64-mingw32)
firebase-auth (0.1.4)
rest-client (~> 2.0)
hashdiff (0.3.7)
http-cookie (1.0.3)
domain_name (~> 0.5)
json (2.1.0)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mini_portile2 (2.3.0)
netrc (0.11.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
nokogiri (1.8.2-x64-mingw32)
mini_portile2 (~> 2.3.0)
ocra (1.3.10)
parseconfig (1.0.8)
permessage_deflate (0.1.4)
poe-sniper-pro (0.1.0)
eventmachine
faye-websocket
firebase-auth
permessage_deflate
public_suffix (3.0.2)
rake (12.3.0)
rb-notifu (0.0.4)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rest-client (2.0.2-x64-mingw32)
ffi (~> 1.9)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
Expand All @@ -53,6 +80,10 @@ GEM
tins (~> 1.0)
thor (0.19.4)
tins (1.16.3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unf_ext (0.0.7.5-x64-mingw32)
waitutil (0.2.1)
webmock (3.4.2)
addressable (>= 2.3.6)
Expand All @@ -66,17 +97,19 @@ GEM

PLATFORMS
ruby
x64-mingw32

DEPENDENCIES
analytics-ruby (~> 2.0.0)
coveralls
dotenv
eventmachine
eventmachine (= 1.0.9.1)
faye-websocket
json
nokogiri
ocra (~> 1.3, >= 1.3.10)
parseconfig
permessage_deflate
poe-sniper-pro
rake (~> 12.3)
rb-notifu
rspec (~> 3.0)
Expand Down
70 changes: 43 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

Poe::Sniper is a desktop app that notifies you in-game when items you’re looking for are listed for trading in Path of Exile. It is an alternative to keeping several browser tabs open but it consumes far less resources and you don’t have to switch between the game and your browser all the time. You can use the same custom search criteria and can even message the seller instantly.

*You are viewing the README of version [v0.5.0](https://github.com/thisismydesign/poe-sniper/releases/tag/v0.5.0). You can find other releases [here](https://github.com/thisismydesign/poe-sniper/releases).*
Supported trade sites:
- [poe.trade](https://poe.trade/)
- [pathofexile.com/trade](https://www.pathofexile.com/trade/search/) (currently in closed beta)

*You are viewing the README of version [v0.6.0](https://github.com/thisismydesign/poe-sniper/releases/tag/v0.5.0). You can find other releases [here](https://github.com/thisismydesign/poe-sniper/releases).*

| Branch | Status |
| ------ | ------ |
Expand All @@ -11,65 +15,67 @@ Poe::Sniper is a desktop app that notifies you in-game when items you’re looki

## How does it work

- Copy search links from poe.trade
- Add a list of links to your searches
- [Wait for notification to appear ingame](http://i.imgur.com/RkTK4DN.png)
- [Press button](http://i.imgur.com/QpZqHJD.png)
- Enjoy

## Features

- 100% ToS compliant
- Queries new listsings instantly via poe.trade live mode
- Handles any custom search created via poe.trade
- Queries new listsings instantly via live mode
- Handles any custom search
- Uses Windows notifications which:
- don't remove focus from the game
- have a configurable timeout
- are easily dismissable anytime
- Places whisper message on clipboard for faster interaction
- Consumes far less resources than running poe.trade in browser
- Places whisper message on clipboard for faster interaction (sending message from clipboard can be automated to 1 button press)
- Consumes far less resources than running browser tabs
- Queues listings if more than one arrives within the configured notification timeframe (alerts that there are further items)

## Side effects

- PoE needs to run in windowed or windowed fullscreen mode for the notifications to show ingame
- Your clipboard will be altered with every new notification regardless whether you have any other content on it
- PoE needs to run in windowed or windowed fullscreen mode for the notifications to show while ingame
- Your clipboard will be altered with every new notification

## Installation and usage
## Installation and configuration

Download the latest release (poe-sniper.zip) from the [releases page](https://github.com/thisismydesign/poe-sniper/releases).
Extract it, inside the poe-sniper folder you will find 3 files:
Download the latest release (poe-sniper-v*.zip) from the [releases page](https://github.com/thisismydesign/poe-sniper/releases).
Extract it (preferably into it's own folder). Inside the folder you will find 3 files:
- poe-sniper.exe
- config.ini
- input/example_input.yaml
- input/example_input.json (deprecated)
- config.yaml
- example_input.yaml

[`example_input.yaml`](./artifacts/example_input.yaml) contains links to the searches you want to be notified about and a custom name for each search. If you're unsure about the [YAML format]((https://learn.getgrav.org/advanced/yaml)) just follow the example. Assuming the linked example you will receive notifications like: `New Tabula on Standard listed. ~b/o 10 chaos`. If you prefer, you can remove a trade site entirely.

Modify `config.ini` and `example_input.yaml` according to your needs. You can still use `json` format for input but it is no longer the default.
[`config.yaml`](./artifacts/config.yaml) contains Poe::Sniper's configuration such as how long the notifications should last, where the input file is located, etc. Most notably, in order to use [pathofexile.com/trade](https://www.pathofexile.com/trade/search/) you neeed to specify: `session_id` ([instructions on where to find it](https://github.com/Stickymaddness/Procurement/wiki/SessionID)), `user_email` and `user_password` (you received these if participating in the beta).

[`example_input.yaml`](./artifacts/input/example_input.yaml) contains links to the searches you want to be notified about and a custom name for each search. If you're unsure about the [YAML format]((https://learn.getgrav.org/advanced/yaml)) just follow the example. Assuming the linked example you will receive notifications like: `New Tabula on BSC listed. ~b/o 10 chaos`.
Modify `config.yaml` and `example_input.yaml` according to your needs.

[`config.ini`](./artifacts/input/config.ini) contains Poe::Sniper's configuration such as how long the notifications should last, where the input file is located, etc.
## Usage

Run poe-sniper.exe

Certain versions of Windows might warn against running unverified apps. If prompted click `More info` and `Run anyway`.

You're all set. Enjoy your interrupt free PoE.

Additionally [here's a modified version of the Lutbot AutoHotkey Macro](https://github.com/thisismydesign/poe-lutbot-ahk) where the 'Paste' option is added allowing you to hotkey sending messages from the clipboard. That's right. One click to set up a trade. It's awesome, I know!

## Disclaimer
Additionally you can automate pasting the message via [PoE TradeMacro](https://github.com/PoE-TradeMacro/POE-TradeMacro). Add the following as a custom macro: `F2::SendInput {Enter}^v{Enter}` as described [here](https://github.com/PoE-TradeMacro/POE-TradeMacro/wiki/Custom-Macros). This maps sending message from the clipboard to the F2 button.

This tool was created to improve the trading experience. We believe in creating a fair competition by making the best tools available to everyone. This is why we're releasing it to the public.
You're all set. Enjoy your interrupt free PoE.

## Technical details

Written in Ruby, packaged as standalone Windows executable with [OCRA](https://github.com/larsch/ocra/).

*Please be aware that we're sending anonymous data to gather app usage statistics.*
*Please be aware that the app sends anonymous data to gather app usage statistics.*

### Usage from source

Create `.env` file as described in the [analytics chapter](#analytics). See default tasks in [`Rakefile`](Rakefile) for running tests and building the executable.
See default tasks in [`Rakefile`](Rakefile) for running tests and building the executable.

#### Prerequisites

- Install `poe-sniper-pro` gem
- Create `.env` file as described in the [Environment config](#environment-config) chapter

#### Start in normal mode

Expand All @@ -87,15 +93,25 @@ bundle exec rake start_offline_debug

#### Debug

- Test socket connection retry by providing an incorrect `api_url` in `config.ini`
- Test socket connection retry by providing an incorrect `api_url` in `Poe::Sniper::PoeSniper.CONFIG`
- Test HTTP connection retry by going offline

### Analytics

The app is using [Segment](https://segment.com/) (via the [analytics-ruby](https://segment.com/docs/sources/server/ruby/) gem) to gather anonymous usage statistics. Open source client side key handling sucks, the current approach to maximize obscurity is to read the Base64 encoded write key from the uncommitted `ANALYTICS_KEY` environment variable stored in a `.env` file which is packaged with the build. This env var should be set when running the `ocra` Rake task and will be added to `.env` automatically during the build.
The app is using [Segment](https://segment.com/) (via the [analytics-ruby](https://segment.com/docs/sources/server/ruby/) gem) to gather anonymous usage statistics.

Certificates are stored in [config/cacert.pem](config/cacert.pem) and are referenced in the `SSL_CERT_FILE` env var in order to fix the `certificate verify failed` issue on Windows ([see](https://gist.github.com/fnichol/867550)).

### Authentication

The app is using Firebase to authenticate against using user provided email and password.

### Environment config

Open source client side key handling sucks. The current approach to maximize obscurity is to read Base64 encoded keys from uncommitted environment variables stored in a `.env` file which is packaged with the build. These variables will be added to `.env` automatically during the build (in `ocra` Rake task). However they need to be set manually when running the app locally from source:
- `ANALYTICS_KEY`: Base64 encoded Segment app key (can be anything Base64 encoded; analytics won't work but also won't produce errors)
- `AUTH_KEY`: Base64 encoded Firebase app key (can be anything Base64 encoded; `pathofexilecom` input won't work)

### Known issues / Improvements / TODO

- Get rid of Nokogiri, find a non-native way to parse HTML
Expand Down
7 changes: 4 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ task :ocra do
p 'Skipping OCRA build as system is not Windows' && exit unless Gem.win_platform?

sh "echo export ANALYTICS_KEY=%ANALYTICS_KEY% >> .env"
sh "ocra ocra/poe-sniper.rb .env config/cacert.pem --output artifacts/poe-sniper.exe"
sh "echo export AUTH_KEY=%AUTH_KEY% >> .env"
sh "ocra ocra/poe-sniper.rb .env config/cacert.pem --output artifacts/poe-sniper.exe --gem-full"
sh "cd artifacts && 7z a poe-sniper-#{version}.zip *"
end

Expand All @@ -24,13 +25,13 @@ end
task :start do
puts "When started via rake task the 'user interaction before exit' functionality is broken upon interrupt because it also interrupts the rake task."
require_relative 'lib/poe/sniper'
Poe::Sniper.run('input/config.ini')
Poe::Sniper.run('spec/resources/local_test_config/config.yaml')
end

task :start_offline_debug do
puts "When started via rake task the 'user interaction before exit' functionality is broken upon interrupt because it also interrupts the rake task."
require_relative 'lib/poe/sniper'
Poe::Sniper.offline_debug('input/config.ini', 'spec/resources/example_socket_data.json')
Poe::Sniper.offline_debug('spec/resources/local_test_config/config.yaml', 'spec/resources/example_socket_data.json')
end

task :default => [:require, :spec, :ocra]
12 changes: 12 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Envirnment:
# - https://www.appveyor.com/docs/build-environment/
# - OpenSSL 1.0.2L (32-bit) (C:\OpenSSL-Win32\bin)
# - Ruby 2.3.3 x86 (C:\Ruby23\bin)

install:
- set PATH=C:\Ruby23\bin;%PATH%

# Required because of OCRA issue: https://github.com/larsch/ocra/issues/144
- git clone https://%gl_user%:%gl_pass%@gitlab.com/5k-mirrors/poe-sniper-pro.git
- gem build poe-sniper-pro/gem/poe-sniper-pro.gemspec
- gem install poe-sniper-pro/gem/*.gem --no-document --silent

- bundle config build.eventmachine --with-ssl-dir=C:\OpenSSL-Win32
- bundle install

build: off
Expand Down
16 changes: 0 additions & 16 deletions artifacts/config.ini

This file was deleted.

9 changes: 9 additions & 0 deletions artifacts/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
notification_seconds: 10
input_file_path: 'example_input.yaml'

auth:
user_email: ""
user_password: ""

pathofexilecom:
session_id: ""
5 changes: 5 additions & 0 deletions artifacts/example_input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
poetrade:
http://poe.trade/search/nonahimimatato : Everything on Standard
http://poe.trade/search/tararikinatooo : Tabula on Standard
pathofexilecom:
https://www.pathofexile.com/trade/search/Standard/NK6Ec5 : Tabula on Standard
4 changes: 0 additions & 4 deletions artifacts/input/example_input.json

This file was deleted.

2 changes: 0 additions & 2 deletions artifacts/input/example_input.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions lib/poe/sniper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
end

require_relative 'sniper/poe_sniper'
require_relative 'sniper/analytics'
require_relative 'sniper/environment_config'

module Poe
module Sniper
def self.run(config_path)
Analytics.ensure_analytics_key!
Analytics.ensure_certificates!
EnvironmentConfig.ensure_analytics_key!
EnvironmentConfig.ensure_certificates!
EnvironmentConfig.ensure_auth_key!

# Do not start during Ocra build
return if defined?(Ocra)
Expand Down
2 changes: 1 addition & 1 deletion lib/poe/sniper/alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def to_clipboard
private

def log_alert_created(whisper, search_name)
message = "New alert created for: #{search_name} || "
message = "New snipe for #{search_name} || "
message += "Buyout: #{whisper.buyout} || " if whisper.buyout?
message += "Whisper: #{@whisper_message}"
Logger.instance.info(message)
Expand Down
Loading

0 comments on commit 453ceee

Please sign in to comment.