%global _empty_manifest_terminate_build 0 Name: python-aiocord Version: 1.1.10 Release: 1 Summary: API wrapper for Discord. License: MIT URL: https://github.com/Exahilosys/aiocord Source0: https://mirrors.nju.edu.cn/pypi/web/packages/eb/53/8bd4d520c1054a7fdd41cea211c622d044ee30f74559712b3c066e5e4794/aiocord-1.1.10.tar.gz BuildArch: noarch Requires: python3-aiohttp Requires: python3-yarl Requires: python3-pynacl %description # Installing ``` python3 -m pip install aiocord ``` # Simple Usage ```py import asyncio import aiohttp import aiocord.engine # external token = 'APPLICATION_TOKEN' # get the event loop loop = asyncio.get_event_loop() # create a session session = aiohttp.ClientSession(loop = loop) # cooperative client client = aiocord.engine.Client(session, token, loop = loop) @client.track('ready') async def handle_0(shard, version, initial_guild_ids): # caution! blocking print(shard, 'ready') @client.track('message create') async def handle_1(shard, guild, channel, message): signal = '.say ' if message.content.startswith(signal): response = message.content[len(signal):] await client.create_message(channel.id, content = response) async def initialize(): await client.start() async def finalize(): await client.close() await session.close() try: loop.run_until_complete(initialize()) try: loop.run_forever() except KeyboardInterrupt: pass finally: loop.run_until_complete(finalize()) ``` # Advanced Usage ```py import asyncio import aiohttp import aiocord import functools token = 'APPLICATION_TOKEN' # get the event loop loop = asyncio.get_event_loop() # create a session session = aiohttp.ClientSession(loop = loop) # used for fetching info rest = aiocord.rest.Client(session, loop = loop) # authorize rest.authorize(token) # this is our stream handler def handle(shard, event, data): # caution! blocking print(shard, event) if event == 'READY': session_id = data['session_id'] # needed for resume shard.patch(session_id) return shards = [] async def initialize(): # sharding information data = await rest.get_gateway_bot() # shard count and gateway url count, url = data['shards'], data['url'] # index is the shard id for index in range(count): # needed for identify info = (index, count) # used for listening to events gateway = aiocord.gateway.Client(session, token, info, loop = loop) # docs advice to routinely update the response of the # get gateway bot request, hence why this method exists gateway.update(url) # pass the current gateway to our handler callback = functools.partial(handle, gateway) # will be called with # every event dispatch gateway.track(callback) # connect, start event steam # and identify with info given await gateway.start() shards.append(gateway) if not index < count: break await asyncio.sleep(5.5) async def finalize(): for gateway in shards: await gateway.close() await session.close() try: loop.run_until_complete(initialize()) try: loop.run_forever() except KeyboardInterrupt: pass finally: loop.run_until_complete(finalize()) ``` %package -n python3-aiocord Summary: API wrapper for Discord. Provides: python-aiocord BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-aiocord # Installing ``` python3 -m pip install aiocord ``` # Simple Usage ```py import asyncio import aiohttp import aiocord.engine # external token = 'APPLICATION_TOKEN' # get the event loop loop = asyncio.get_event_loop() # create a session session = aiohttp.ClientSession(loop = loop) # cooperative client client = aiocord.engine.Client(session, token, loop = loop) @client.track('ready') async def handle_0(shard, version, initial_guild_ids): # caution! blocking print(shard, 'ready') @client.track('message create') async def handle_1(shard, guild, channel, message): signal = '.say ' if message.content.startswith(signal): response = message.content[len(signal):] await client.create_message(channel.id, content = response) async def initialize(): await client.start() async def finalize(): await client.close() await session.close() try: loop.run_until_complete(initialize()) try: loop.run_forever() except KeyboardInterrupt: pass finally: loop.run_until_complete(finalize()) ``` # Advanced Usage ```py import asyncio import aiohttp import aiocord import functools token = 'APPLICATION_TOKEN' # get the event loop loop = asyncio.get_event_loop() # create a session session = aiohttp.ClientSession(loop = loop) # used for fetching info rest = aiocord.rest.Client(session, loop = loop) # authorize rest.authorize(token) # this is our stream handler def handle(shard, event, data): # caution! blocking print(shard, event) if event == 'READY': session_id = data['session_id'] # needed for resume shard.patch(session_id) return shards = [] async def initialize(): # sharding information data = await rest.get_gateway_bot() # shard count and gateway url count, url = data['shards'], data['url'] # index is the shard id for index in range(count): # needed for identify info = (index, count) # used for listening to events gateway = aiocord.gateway.Client(session, token, info, loop = loop) # docs advice to routinely update the response of the # get gateway bot request, hence why this method exists gateway.update(url) # pass the current gateway to our handler callback = functools.partial(handle, gateway) # will be called with # every event dispatch gateway.track(callback) # connect, start event steam # and identify with info given await gateway.start() shards.append(gateway) if not index < count: break await asyncio.sleep(5.5) async def finalize(): for gateway in shards: await gateway.close() await session.close() try: loop.run_until_complete(initialize()) try: loop.run_forever() except KeyboardInterrupt: pass finally: loop.run_until_complete(finalize()) ``` %package help Summary: Development documents and examples for aiocord Provides: python3-aiocord-doc %description help # Installing ``` python3 -m pip install aiocord ``` # Simple Usage ```py import asyncio import aiohttp import aiocord.engine # external token = 'APPLICATION_TOKEN' # get the event loop loop = asyncio.get_event_loop() # create a session session = aiohttp.ClientSession(loop = loop) # cooperative client client = aiocord.engine.Client(session, token, loop = loop) @client.track('ready') async def handle_0(shard, version, initial_guild_ids): # caution! blocking print(shard, 'ready') @client.track('message create') async def handle_1(shard, guild, channel, message): signal = '.say ' if message.content.startswith(signal): response = message.content[len(signal):] await client.create_message(channel.id, content = response) async def initialize(): await client.start() async def finalize(): await client.close() await session.close() try: loop.run_until_complete(initialize()) try: loop.run_forever() except KeyboardInterrupt: pass finally: loop.run_until_complete(finalize()) ``` # Advanced Usage ```py import asyncio import aiohttp import aiocord import functools token = 'APPLICATION_TOKEN' # get the event loop loop = asyncio.get_event_loop() # create a session session = aiohttp.ClientSession(loop = loop) # used for fetching info rest = aiocord.rest.Client(session, loop = loop) # authorize rest.authorize(token) # this is our stream handler def handle(shard, event, data): # caution! blocking print(shard, event) if event == 'READY': session_id = data['session_id'] # needed for resume shard.patch(session_id) return shards = [] async def initialize(): # sharding information data = await rest.get_gateway_bot() # shard count and gateway url count, url = data['shards'], data['url'] # index is the shard id for index in range(count): # needed for identify info = (index, count) # used for listening to events gateway = aiocord.gateway.Client(session, token, info, loop = loop) # docs advice to routinely update the response of the # get gateway bot request, hence why this method exists gateway.update(url) # pass the current gateway to our handler callback = functools.partial(handle, gateway) # will be called with # every event dispatch gateway.track(callback) # connect, start event steam # and identify with info given await gateway.start() shards.append(gateway) if not index < count: break await asyncio.sleep(5.5) async def finalize(): for gateway in shards: await gateway.close() await session.close() try: loop.run_until_complete(initialize()) try: loop.run_forever() except KeyboardInterrupt: pass finally: loop.run_until_complete(finalize()) ``` %prep %autosetup -n aiocord-1.1.10 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-aiocord -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 1.1.10-1 - Package Spec generated