summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-discsocket.spec354
-rw-r--r--sources1
3 files changed, 356 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..c81635a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/discsocket-1.1.6.tar.gz
diff --git a/python-discsocket.spec b/python-discsocket.spec
new file mode 100644
index 0000000..39a0343
--- /dev/null
+++ b/python-discsocket.spec
@@ -0,0 +1,354 @@
+%global _empty_manifest_terminate_build 0
+Name: python-discsocket
+Version: 1.1.6
+Release: 1
+Summary: Python framework for Discord interactions.
+License: MIT
+URL: https://github.com/murillotadeo/discsocket
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/4d/e2/7855408c1e758a4330a07fc553cb4d658085d80240fde77c138986e1acb0/discsocket-1.1.6.tar.gz
+BuildArch: noarch
+
+
+%description
+# discsocket
+
+Python framework for Discord interactions.
+
+# Installation
+`pip install discsocket`
+
+# Introduction
+This is the code needed for a minimal application with an on_ready event
+```py
+import discsocket
+
+socket = discsocket.Socket()
+
+# Event names go in the event decorator
+# The function can be named whatever
+@socket.event('ready')
+async def ready():
+ print(f"{socket.user.username} is connected")
+
+socket.run('token')
+```
+
+or if you want to make the bot function as a class
+```py
+import discsocket
+
+class Socket(discsocket.Socket):
+ def __init__(self):
+ super().__init__(gateway_version=8)
+
+ # Events in a class structure won't require a decorator
+ # and instead follow the 'on_' + gateway_event format
+
+ async def on_ready(self):
+ print(f"{self.user.username} is online")
+
+if __name__ == '__main__':
+ Socket().run('token')
+```
+# Extensions
+Extensions work to separate your code into different files so it is not all in a single file
+
+```py
+import discsocket
+from discsocket import ext
+
+class Boop(ext.Extension):
+ def __init__(self, socket):
+ self.socket = socket
+
+ # Example of a command within an extension
+ @ext.Extension.command('boop', discsocket.utils.SLASH)
+ async def boop(self, context: discsocket.models.BaseContext):
+ await context.callback(content='boop!')
+
+ # Example of a listener within an extension
+ @ext.Extension.listener('message_create')
+ async def message(self, message):
+ print(message['content'])
+
+def init_ext(socket):
+ socket.add_ext(Boop(socket))
+```
+
+As an example, the above extension is in a folder called 'extensions'
+
+```py
+
+import discsocket
+import pathlib
+
+class Socket(discsocket.Socket):
+ def __init__(self):
+ super().__init__(gateway_version=8)
+ self.load()
+
+ def load(self):
+ for ext in [f'{p.parent}.{p.stem}' for p in pathlib.Path('extensions').glob('*.py')]:
+ try:
+ self.add_extension(ext)
+ except Exception as e:
+ print(f"Failed to load {ext}.\n-> {e}")
+ else:
+ print(f"Loaded {ext}")
+
+ async def on_ready(self):
+ print(f"{self.user.username} is online")
+
+if __name__ == '__main__':
+ Socket().run('token')
+```
+
+
+
+
+%package -n python3-discsocket
+Summary: Python framework for Discord interactions.
+Provides: python-discsocket
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-discsocket
+# discsocket
+
+Python framework for Discord interactions.
+
+# Installation
+`pip install discsocket`
+
+# Introduction
+This is the code needed for a minimal application with an on_ready event
+```py
+import discsocket
+
+socket = discsocket.Socket()
+
+# Event names go in the event decorator
+# The function can be named whatever
+@socket.event('ready')
+async def ready():
+ print(f"{socket.user.username} is connected")
+
+socket.run('token')
+```
+
+or if you want to make the bot function as a class
+```py
+import discsocket
+
+class Socket(discsocket.Socket):
+ def __init__(self):
+ super().__init__(gateway_version=8)
+
+ # Events in a class structure won't require a decorator
+ # and instead follow the 'on_' + gateway_event format
+
+ async def on_ready(self):
+ print(f"{self.user.username} is online")
+
+if __name__ == '__main__':
+ Socket().run('token')
+```
+# Extensions
+Extensions work to separate your code into different files so it is not all in a single file
+
+```py
+import discsocket
+from discsocket import ext
+
+class Boop(ext.Extension):
+ def __init__(self, socket):
+ self.socket = socket
+
+ # Example of a command within an extension
+ @ext.Extension.command('boop', discsocket.utils.SLASH)
+ async def boop(self, context: discsocket.models.BaseContext):
+ await context.callback(content='boop!')
+
+ # Example of a listener within an extension
+ @ext.Extension.listener('message_create')
+ async def message(self, message):
+ print(message['content'])
+
+def init_ext(socket):
+ socket.add_ext(Boop(socket))
+```
+
+As an example, the above extension is in a folder called 'extensions'
+
+```py
+
+import discsocket
+import pathlib
+
+class Socket(discsocket.Socket):
+ def __init__(self):
+ super().__init__(gateway_version=8)
+ self.load()
+
+ def load(self):
+ for ext in [f'{p.parent}.{p.stem}' for p in pathlib.Path('extensions').glob('*.py')]:
+ try:
+ self.add_extension(ext)
+ except Exception as e:
+ print(f"Failed to load {ext}.\n-> {e}")
+ else:
+ print(f"Loaded {ext}")
+
+ async def on_ready(self):
+ print(f"{self.user.username} is online")
+
+if __name__ == '__main__':
+ Socket().run('token')
+```
+
+
+
+
+%package help
+Summary: Development documents and examples for discsocket
+Provides: python3-discsocket-doc
+%description help
+# discsocket
+
+Python framework for Discord interactions.
+
+# Installation
+`pip install discsocket`
+
+# Introduction
+This is the code needed for a minimal application with an on_ready event
+```py
+import discsocket
+
+socket = discsocket.Socket()
+
+# Event names go in the event decorator
+# The function can be named whatever
+@socket.event('ready')
+async def ready():
+ print(f"{socket.user.username} is connected")
+
+socket.run('token')
+```
+
+or if you want to make the bot function as a class
+```py
+import discsocket
+
+class Socket(discsocket.Socket):
+ def __init__(self):
+ super().__init__(gateway_version=8)
+
+ # Events in a class structure won't require a decorator
+ # and instead follow the 'on_' + gateway_event format
+
+ async def on_ready(self):
+ print(f"{self.user.username} is online")
+
+if __name__ == '__main__':
+ Socket().run('token')
+```
+# Extensions
+Extensions work to separate your code into different files so it is not all in a single file
+
+```py
+import discsocket
+from discsocket import ext
+
+class Boop(ext.Extension):
+ def __init__(self, socket):
+ self.socket = socket
+
+ # Example of a command within an extension
+ @ext.Extension.command('boop', discsocket.utils.SLASH)
+ async def boop(self, context: discsocket.models.BaseContext):
+ await context.callback(content='boop!')
+
+ # Example of a listener within an extension
+ @ext.Extension.listener('message_create')
+ async def message(self, message):
+ print(message['content'])
+
+def init_ext(socket):
+ socket.add_ext(Boop(socket))
+```
+
+As an example, the above extension is in a folder called 'extensions'
+
+```py
+
+import discsocket
+import pathlib
+
+class Socket(discsocket.Socket):
+ def __init__(self):
+ super().__init__(gateway_version=8)
+ self.load()
+
+ def load(self):
+ for ext in [f'{p.parent}.{p.stem}' for p in pathlib.Path('extensions').glob('*.py')]:
+ try:
+ self.add_extension(ext)
+ except Exception as e:
+ print(f"Failed to load {ext}.\n-> {e}")
+ else:
+ print(f"Loaded {ext}")
+
+ async def on_ready(self):
+ print(f"{self.user.username} is online")
+
+if __name__ == '__main__':
+ Socket().run('token')
+```
+
+
+
+
+%prep
+%autosetup -n discsocket-1.1.6
+
+%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-discsocket -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 17 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.6-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..a5d76c8
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+340417962d96147810b26cf657d78af6 discsocket-1.1.6.tar.gz