Skip to content

Sourcery suggested changes - #2

Open
SourceryAI wants to merge 1 commit into
evergreen-it-dev:masterfrom
SourceryAI:Sourcery_suggested_changes
Open

Sourcery suggested changes#2
SourceryAI wants to merge 1 commit into
evergreen-it-dev:masterfrom
SourceryAI:Sourcery_suggested_changes

Conversation

@SourceryAI

Copy link
Copy Markdown

Sourcery refactored this code to make it cleaner and more readable.

If you want Sourcery to review the full project or all new pull requests, add Sourcery to your repo.

We try to only open PRs that are helpful. If this isn't helpful or you have any feedback for us - please let us know!

Sourcery refactored this code to make it cleaner and more readable.

If you want Sourcery to review the full project or all new pull requests, add [Sourcery](https://github.com/sourcery-ai/sourcery) to your repo.

We try to only open PRs that are helpful. If this isn't helpful or you have any feedback for us - please [let us know](mailto:github@sourcery.ai)!
Comment thread skype_sender_prod.py
Comment on lines -39 to +54
if request.method == 'POST':
app.logger.info('/listen request:'+ "".join( request.data.splitlines()))
_json = request.get_json(force=True)
if request.method != 'POST':
return

if "challenge" in _json:
return _json["challenge"]
app.logger.info('/listen request:'+ "".join( request.data.splitlines()))
_json = request.get_json(force=True)

if "challenge" in _json:
return _json["challenge"]


if _json["event"]["type"] == "message":
if not 'sybtype' in _json["event"]:
r = requests.post(corezoidUrl,data=request.data)
app.logger.info('/corezoid answer:' + "".join(r.content.splitlines()))
return '{"OK":true}'
if _json["event"]["type"] == "message" and 'sybtype' not in _json["event"]:
r = requests.post(corezoidUrl,data=request.data)
app.logger.info('/corezoid answer:' + "".join(r.content.splitlines()))

return '{"OK":true}'

return '{"OK":true}'

@SourceryAI SourceryAI Nov 15, 2021

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function listen_skype refactored with the following changes:

Comment thread skype_sender_prod.py
Comment on lines -59 to +85
if request.method == 'POST':
app.logger.info('/send request:' + "".join(request.data.splitlines()))
_json = request.get_json(force=True)

if _json["event"]["type"] == "message":
if not 'subtype' in _json["event"]:
if _json["production"]:
clusterChat=clusterChat_prod

sk = Skype(skypeLogin, skypePass, 'session.tmp') # connect to Skype
chats = sk.chats # your conversations
ch = chats.chat(clusterChat)

r = requests.get(slackGetUserUrl, params={"token": slackToken, "user": _json["event"]["user"]})
# print r.content
_user = jsonpickle.decode(r.content)
# ch.sendMsg( _user["user"]["real_name"] + ' via Slack: ' + _json["event"]["text"]) # plain-text message
ch.sendRaw(messagetype="RichText", contenttype="text",
content='<b>' + _user["user"]["real_name"] + ' via Slack: </b>' + remove_html_tags(_json["event"][
"text"])) # plain-text message
app.logger.info(_user["user"]["real_name"] + ' via Slack: ' + remove_html_tags(_json["event"]["text"]))
return '{"OK":true}'
if request.method != 'POST':
return

app.logger.info('/send request:' + "".join(request.data.splitlines()))
_json = request.get_json(force=True)

if _json["event"]["type"] == "message" and 'subtype' not in _json["event"]:
if _json["production"]:
clusterChat=clusterChat_prod

sk = Skype(skypeLogin, skypePass, 'session.tmp') # connect to Skype
chats = sk.chats # your conversations
ch = chats.chat(clusterChat)

r = requests.get(slackGetUserUrl, params={"token": slackToken, "user": _json["event"]["user"]})
# print r.content
_user = jsonpickle.decode(r.content)
# ch.sendMsg( _user["user"]["real_name"] + ' via Slack: ' + _json["event"]["text"]) # plain-text message
ch.sendRaw(messagetype="RichText", contenttype="text",
content='<b>' + _user["user"]["real_name"] + ' via Slack: </b>' + remove_html_tags(_json["event"][
"text"])) # plain-text message
app.logger.info(_user["user"]["real_name"] + ' via Slack: ' + remove_html_tags(_json["event"]["text"]))

return '{"OK":true}'

return '{"OK":true}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function send_skype refactored with the following changes:

Comment thread skype_sender_prod.py
Comment on lines -88 to +109
if request.method == 'POST':
app.logger.info('/send telegram request:' + "".join(request.data.splitlines()))
_json = request.get_json(force=True)
if request.method != 'POST':
return

if _json["event"]["type"] == "message":
if not 'subtype' in _json["event"]:
app.logger.info('/send telegram request:' + "".join(request.data.splitlines()))
_json = request.get_json(force=True)

if _json["event"]["type"] == "message" and 'subtype' not in _json["event"]:

sk = Skype(skypeLogin, skypePass, 'session.tmp') # connect to Skype
chats = sk.chats # your conversations
ch = chats.chat(clusterChat)
sk = Skype(skypeLogin, skypePass, 'session.tmp') # connect to Skype
chats = sk.chats # your conversations
ch = chats.chat(clusterChat)

ch.sendRaw(messagetype="RichText", contenttype="text",
content='<b>' + _json["event"]["user"] + ' via Telegram: </b>' + remove_html_tags(_json["event"][
"text"])) # plain-text message
app.logger.info(_json["event"]["user"] + ' via Telegram: ' + remove_html_tags(_json["event"]["text"]))
return '{"OK":true}'
ch.sendRaw(messagetype="RichText", contenttype="text",
content='<b>' + _json["event"]["user"] + ' via Telegram: </b>' + remove_html_tags(_json["event"][
"text"])) # plain-text message
app.logger.info(_json["event"]["user"] + ' via Telegram: ' + remove_html_tags(_json["event"]["text"]))

return '{"OK":true}'

return '{"OK":true}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function send_skype_telegram refactored with the following changes:

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.

1 participant