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

add contrib.discord: first Discord Bot! #976

Merged
merged 7 commits into from
Jun 25, 2020
Merged

add contrib.discord: first Discord Bot! #976

merged 7 commits into from
Jun 25, 2020

Conversation

casperdcl
Copy link
Sponsor Member

@casperdcl casperdcl commented May 23, 2020

  • add contrib.discord (similar to contrib.telegram)
  • document
  • abstract common features with contrib.telegram
    • fix lazy large memory usage and discard unsent messages

Steps to test:

from tqdm.contrib.discord import tqdm, trange
for _ in trange(
	int(1e8),
	token='THIS1SSOMETOKEN0BTAINeDfrOmD1SC0rd',
    channel_id=0246813579,
):
    # worst-case empty for-loop
    # still does ~6M it/s, i.e. overhead ~170 ns/it
	pass

Result:

image

@casperdcl casperdcl added p3-enhancement 🔥 Much new such feature submodule ⊂ Periphery/subclasses to-merge ↰ Imminent labels May 23, 2020
@casperdcl casperdcl added this to the v5.0.0 milestone May 23, 2020
@casperdcl casperdcl self-assigned this May 23, 2020
@codecov-commenter
Copy link

codecov-commenter commented May 23, 2020

Codecov Report

Merging #976 into master will decrease coverage by 1.52%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #976      +/-   ##
==========================================
- Coverage   86.90%   85.37%   -1.53%     
==========================================
  Files          21       22       +1     
  Lines        1260     1279      +19     
  Branches      215      218       +3     
==========================================
- Hits         1095     1092       -3     
- Misses        144      166      +22     
  Partials       21       21              

@casperdcl casperdcl requested a review from lrq3000 as a code owner June 25, 2020 19:23
@casperdcl casperdcl changed the base branch from master to devel June 25, 2020 19:24
@casperdcl casperdcl merged commit 2cf0bbb into devel Jun 25, 2020
Casper automation moved this from Next Release to Done Jun 25, 2020
@casperdcl casperdcl mentioned this pull request Jun 25, 2020
1 task
@casperdcl casperdcl deleted the discord branch June 25, 2020 19:29
@oohwooh
Copy link

oohwooh commented Sep 20, 2020

Hi so I'm really glad I found this because it's exactly what I wanted for a project I'm working on, but I'm wondering if there's any reason you opted to use disco-py instead of discord.py? From my experience discord.py is much more reliable and better maintained, and it currently looks like there's an issue with Python 3.8 compatibility for disco-py
would you be opposed to me porting this to use discord.py instead? The libraries look to be structured similarly so it would probably be only a few code changes.

Thoughts?

@oohwooh
Copy link

oohwooh commented Sep 20, 2020

I take back what I said about it being an easy fix, just realized disco is synchronous and discord.py isn't. I'm not sure what a clean solution would be to overcome that. Looking into it

@casperdcl
Copy link
Sponsor Member Author

Apart from the async issue and need to mess with mainloops, discord.py is also py3 only; whereas disco works perfectly fine with tqdm on a lot of old py2 code.

Also as a matter of personal taste, discord.py seems to have an extremely unpythonic design which goes against what I try to do with tqdm.

I think both discord libs are maintained - I don't particularly care about how much - but I'd be very interested in why you say one is more reliable than the other. If disco really is unreliable then I'd probably prefer switching to just plain requests like with https://github.com/tqdm/tqdm/blob/master/tqdm/contrib/telegram.py

@casperdcl
Copy link
Sponsor Member Author

About the py3.8 issue, is it b1naryth1ef/disco#178? It it similar to b1naryth1ef/disco#107 (i.e. a gevent issue)?

@oohwooh
Copy link

oohwooh commented Sep 20, 2020

Thanks for the quick response! I appreciate the insight.
Reliable probably wasn't the best choice of words, in hindsight. What I was trying to say with that is that the current issue with installing the package from pip seems to have been present for a while. I just managed to resolve that one by using a constraints.txt file to ensure gevent was installed with an up-to-date version, and after doing that tqdm.contrib.discord works as expected.

Totally understand the matter of personal preference, and given that I think it's very reasonable for this code to just stay as is, and then when the gevent issue eventually gets fixed the package becomes a bit easier to use.

@casperdcl
Copy link
Sponsor Member Author

hmm yes just posted b1naryth1ef/disco#178 (comment). I might open another PR there. They merged in my last PR pretty quickly...

@casperdcl
Copy link
Sponsor Member Author

b1naryth1ef/disco#183 hopefully makes things more reliable :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-enhancement 🔥 Much new such feature submodule ⊂ Periphery/subclasses to-merge ↰ Imminent
Projects
Casper
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants