Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added http proxy support #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

added http proxy support #5

wants to merge 1 commit into from

Conversation

zhum
Copy link
Contributor

@zhum zhum commented Apr 17, 2018

simple and fast (but working well) support for http proxy.

@@ -1,3 +1,3 @@
class TelegramBotMiddleware
VERSION = "0.3.2"
VERSION = "0.3.3"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/MutableConstant: Freeze mutable objects assigned to constants.

def send_to_telegram(path, query)
log_debug("Sending to chat: #{path} - #{query}")
self.class.post("/bot#{@config.token}/#{path}", query: query)
options=@def_options.clone
options[:query]=query

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

def send_to_telegram(path, query)
log_debug("Sending to chat: #{path} - #{query}")
self.class.post("/bot#{@config.token}/#{path}", query: query)
options=@def_options.clone

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i
if ! @config.proxy_user.nil?
@def_options[:http_proxyuser][email protected]_user
@def_options[:http_proxypass][email protected]_pass || ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Surrounding space missing for operator =.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@def_options[:http_proxyaddr][email protected]_addr
@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i
if ! @config.proxy_user.nil?
@def_options[:http_proxyuser][email protected]_user

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

if ! @config.proxy_addr.nil?
@def_options[:http_proxyaddr][email protected]_addr
@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i
if ! @config.proxy_user.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/NegatedIf: Favor unless over if for negative conditions.
Layout/SpaceAfterNot: Do not leave space between ! and its argument.

@def_options={}
if ! @config.proxy_addr.nil?
@def_options[:http_proxyaddr][email protected]_addr
@def_options[:http_proxyport]=(@config.proxy_port || 1080).to_i

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

# proxy settings
@def_options={}
if ! @config.proxy_addr.nil?
@def_options[:http_proxyaddr][email protected]_addr

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

@@ -41,6 +41,16 @@ def initialize(app, &_block)
raise ArgumentError.new("Config error: host can't be null || empty.") if @config.host.nil? || @config.host.empty?
raise ArgumentError.new("Config error: token can't be null || empty.") if @config.token.nil? || @config.token.empty?

# proxy settings
@def_options={}
if ! @config.proxy_addr.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/NegatedIf: Favor unless over if for negative conditions.
Layout/SpaceAfterNot: Do not leave space between ! and its argument.

@@ -41,6 +41,16 @@ def initialize(app, &_block)
raise ArgumentError.new("Config error: host can't be null || empty.") if @config.host.nil? || @config.host.empty?
raise ArgumentError.new("Config error: token can't be null || empty.") if @config.token.nil? || @config.token.empty?

# proxy settings
@def_options={}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAroundOperators: Surrounding space missing for operator =.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 38.854% when pulling ec0ee2d on zhum:master into 8acd4da on MirkoMignini:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 38.854% when pulling ec0ee2d on zhum:master into 8acd4da on MirkoMignini:master.

@coveralls
Copy link

coveralls commented Apr 17, 2018

Coverage Status

Coverage decreased (-0.2%) to 38.854% when pulling ec0ee2d on zhum:master into 8acd4da on MirkoMignini:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants