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

Update telegram connector to accept first_name and username #841

Merged
merged 6 commits into from
Mar 2, 2019

Conversation

FabioRosado
Copy link
Member

@FabioRosado FabioRosado commented Feb 14, 2019

Description

This is a fix for the issue with Telegram, I've also added the suggestion by @iobreaker so this connector should now work with private messages, groups and chats.

I have also decided to include a warning message when the result didn't contain message and text in its fields.

On the test side, I have removed the unused opsdroid mock.

--EDIT--
I decided to follow the Matrix connector logic by setting self.session to aiohttp.ClientSession on connect and use that same session when calling different api methods. I would like to know if this is a good way to do it instead of using with - this definitely kept the line numbers shorter

I have refactored the telegram methods, added changes suggested by @iobreaker. Changed the whitelist method to include userIDs to try and address the issue raised by Cadair about people bypassing this by changing their name.

I have also implemented a disconnect method - this was suggested by another contributor (I dont remember the name sorry) and was implemented to the shell connector. I have tested the disconnect method extensively without cancelling pending tasks and everything seems to be working okay.

In order to get this disconnect method I had to move the while loop to another method - this probably could be done in a different way.

Overall, I am happy with these changes and ready for the review 😄👍

Fixes #839 and #840

Status

READY | UNDER DEVELOPMENT | ON HOLD

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation fix
  • Test fixed and added

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

  • Tox - all green
  • Manually with telegram - all good
  • Tested telegram with userID, username and none - all okay
  • Tested disconnect with tasks.cancel() commented out in core - connector disconnected property without raising an exception

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@codecov
Copy link

codecov bot commented Feb 14, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@b4db89d). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##             master   #841   +/-   ##
=======================================
  Coverage          ?   100%           
=======================================
  Files             ?     34           
  Lines             ?   2110           
  Branches          ?      0           
=======================================
  Hits              ?   2110           
  Misses            ?      0           
  Partials          ?      0
Impacted Files Coverage Δ
opsdroid/connector/telegram/__init__.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b4db89d...9566e68. Read the comment docs.

Copy link
Member

@jacobtomlinson jacobtomlinson left a comment

Choose a reason for hiding this comment

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

This looks good. Let me know when it is ready.

@FabioRosado
Copy link
Member Author

I tried to fix #853 with this new update. As I mentioned on the issue I might try to implement a webhook to get the updates from the Telegram in the future.

@jacobtomlinson jacobtomlinson merged commit 74a5c5d into opsdroid:master Mar 2, 2019
@FabioRosado FabioRosado deleted the telegram branch March 6, 2019 15:56
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.

Telegram connector crashes when receiving a message from a channel
2 participants