diff options
| author | Rapptz <[email protected]> | 2015-12-04 06:43:04 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-04 06:43:04 -0500 |
| commit | 0489fcb48106fe3fc5d5b4cb4f27221acb4e5e6c (patch) | |
| tree | 78470dbc97dc020084120f0fe07e1411794c83f6 | |
| parent | Move async_client.py to client.py (diff) | |
| download | discord.py-0489fcb48106fe3fc5d5b4cb4f27221acb4e5e6c.tar.xz discord.py-0489fcb48106fe3fc5d5b4cb4f27221acb4e5e6c.zip | |
Update README and setuputils related files to point to async version.
| -rw-r--r-- | README.md | 43 | ||||
| -rw-r--r-- | requirements.txt | 4 | ||||
| -rw-r--r-- | setup.py | 1 |
3 files changed, 34 insertions, 14 deletions
@@ -34,6 +34,12 @@ If you want to install the development version of the library, then do the follo pip install git+https://github.com/Rapptz/discord.py@develop ``` +Installing the async beta is similar. + +``` +pip install git+https://github.com/Rapptz/discord.py@async +``` + Note that this requires `git` to be installed. ## Quick Example @@ -42,30 +48,45 @@ Note that this requires `git` to be installed. import discord client = discord.Client() -client.login('email', 'password') -def on_message(message): - if message.content.startswith('!hello'): - client.send_message(message.channel, 'Hello was received!') - [email protected]_event def on_ready(): print('Logged in as') print(client.user.name) print(client.user.id) print('------') -client.run() [email protected]_event +def on_message(message): + if message.content.startswith('!test'): + logs = yield from client.logs_from(message.channel, limit=100) + counter = 0 + tmp = yield from client.send_message(message.channel, 'Calculating messages...') + for log in logs: + if log.author == message.author: + counter += 1 + + yield from client.edit_message(tmp, 'You have {} messages.'.format(counter)) + elif message.content.startswith('!sleep'): + yield from asyncio.sleep(5) + yield from client.send_message(message.channel, 'Done sleeping') + +def main_task(): + yield from client.login('email', 'password') + yield from client.connect() + +loop = asyncio.get_event_loop() +loop.run_until_complete(main_task()) +loop.close() ``` You can find examples in the examples directory. ## Requirements -- Python 2.7+ or Python 3.3+. -- `ws4py` library -- `requests` library +- Python 3.4.2+ +- `aiohttp` library +- `websockets` library Usually `pip` will handle these for you. diff --git a/requirements.txt b/requirements.txt index 6d606391..e4a04ee3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -ws4py>=0.3.4 -requests>=2.7.0 +aiohttp==0.19.0 +websockets==2.7 @@ -32,7 +32,6 @@ setup(name='discord.py', 'Intended Audience :: Developers', 'Natural Language :: English', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Topic :: Internet', |