banterbotapi 0.2.4__tar.gz → 0.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/PKG-INFO +1 -1
  2. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/__init__.py +1 -1
  3. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/client.py +15 -63
  4. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterbotapi.egg-info/PKG-INFO +1 -1
  5. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/pyproject.toml +1 -1
  6. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/LICENSE +0 -0
  7. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/README.md +0 -0
  8. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/commands.py +0 -0
  9. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/embed.py +0 -0
  10. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/errors.py +0 -0
  11. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/gateway.py +0 -0
  12. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/http.py +0 -0
  13. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/intents.py +0 -0
  14. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/interactions.py +0 -0
  15. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/models.py +0 -0
  16. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterapi/permissions.py +0 -0
  17. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterbotapi.egg-info/SOURCES.txt +0 -0
  18. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterbotapi.egg-info/dependency_links.txt +0 -0
  19. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterbotapi.egg-info/requires.txt +0 -0
  20. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/banterbotapi.egg-info/top_level.txt +0 -0
  21. {banterbotapi-0.2.4 → banterbotapi-0.2.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: banterbotapi
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Python SDK for building bots on Banter (banterchat.org) — discord.py-style.
5
5
  Author-email: Banter <contact@banterchat.org>
6
6
  License-Expression: MIT
@@ -23,7 +23,7 @@ The library mirrors discord.py conventions where possible. See the Bot,
23
23
  Intents, Embed, and Permissions classes for the main entry points.
24
24
  """
25
25
 
26
- __version__ = "0.2.4"
26
+ __version__ = "0.2.6"
27
27
 
28
28
  from .client import Bot
29
29
  from .intents import Intents
@@ -38,7 +38,7 @@ from .models import User, Guild, Channel, Member, Message
38
38
  from .errors import GatewayError
39
39
 
40
40
  log = logging.getLogger("banterapi.client")
41
-
41
+ e
42
42
 
43
43
  # Default REST/gateway URL fragments. Kept as module constants so that
44
44
  # the URL derivation in __init__ is easy to trace and future API
@@ -157,71 +157,28 @@ class Bot:
157
157
  self._handlers[name] = fn
158
158
  return fn
159
159
 
160
- def command(self, name=None, aliases=None, help=None, slash=False, description="", options=None):
161
- """Register a prefix command (optionally also as a slash command).
160
+ def command(self, name=None, aliases=None, help=None):
161
+ """Register a prefix command.
162
162
 
163
- The decorated function is called as ``await fn(ctx, *args)``
164
- positional arguments are parsed from the message text after the
165
- prefix. Argument annotations (``int``, ``float``, ``bool``) are
166
- applied automatically by :class:`~banterapi.commands.Command`;
167
- ``*args`` and keyword-only (``*, text: str``) signatures are
168
- supported.
163
+ The handler runs when a user types ``<prefix><name> ...`` in a
164
+ channel the bot can see. Function signature drives arg parsing:
165
+ ``int`` / ``float`` / ``bool`` annotations convert tokens,
166
+ ``*args`` collects the rest, ``*, text: str`` consumes the
167
+ remainder verbatim.
169
168
 
170
169
  Args:
171
170
  name: Command name as typed (without prefix). Defaults to
172
171
  the function name.
173
- aliases: Iterable of additional names the command answers
174
- to (e.g. ``aliases=["p"]`` for a ``ping`` command).
175
- help: Short help text shown in the default ``help`` embed.
176
- Defaults to the function's docstring's first line.
177
- slash: If ``True``, also register as a slash command at
178
- :meth:`sync_commands` time. The user sees it in the
179
- ``/`` autocomplete dropdown.
180
- description: Slash-command description. Ignored when
181
- ``slash=False``. Falls back to ``help`` or the name.
182
- options: Iterable of :class:`~banterapi.SlashOption` to
183
- expose as typed slash-command arguments. Only
184
- applies when ``slash=True``. When a user invokes the
185
- slash command, the server parses the typed options
186
- and delivers them to the slash handler as
187
- ``interaction.options``. Prefix-invocation is
188
- unaffected — prefix args continue to parse from the
189
- message text via function-signature introspection.
190
-
191
- Usage::
192
-
193
- @bot.command(aliases=["p"], slash=True, description="Health check")
194
- async def ping(ctx):
195
- await ctx.reply("pong")
172
+ aliases: Iterable of alternate names.
173
+ help: Short help text for the default help embed. Defaults
174
+ to the first line of the function's docstring.
196
175
 
197
- With typed slash options::
198
-
199
- from banterapi import SlashOption, OPTION_INTEGER
200
-
201
- @bot.command(
202
- slash=True, description="Roll a die",
203
- options=[SlashOption("sides", type=OPTION_INTEGER, required=False)],
204
- )
205
- async def roll(ctx, sides: int = 6):
206
- await ctx.reply(f"🎲 {sides}")
176
+ For slash commands (typed options + UI autocomplete), use
177
+ :meth:`slash_command` — prefix and slash are separate paths.
207
178
  """
208
179
  def decorator(fn):
209
180
  cmd = Command(fn, name=name, aliases=aliases, help=help)
210
181
  self._commands.add(cmd)
211
- if slash:
212
- entry = {
213
- "name": cmd.name,
214
- "description": description or cmd.help or cmd.name,
215
- }
216
- if options:
217
- # Defer import to avoid a circular: commands.py is
218
- # loaded by client.py, and SlashOption lives there.
219
- from .commands import SlashOption as _SO
220
- entry["options"] = [
221
- (o.to_dict() if isinstance(o, _SO) else dict(o))
222
- for o in options
223
- ]
224
- self._slash_commands.append(entry)
225
182
  return fn
226
183
  return decorator
227
184
 
@@ -281,7 +238,7 @@ class Bot:
281
238
  def _register_default_help(self):
282
239
  from .embed import Embed
283
240
 
284
- @self.command(name="help", slash=True, description="Show available commands")
241
+ @self.command(name="help")
285
242
  async def _help(ctx):
286
243
  visible = [c for c in self._commands.all() if not getattr(c, "_hidden", False)]
287
244
  visible.sort(key=lambda c: c.name)
@@ -307,7 +264,7 @@ class Bot:
307
264
  chunks.append(chunk)
308
265
  for i, c in enumerate(chunks):
309
266
  e.add_field("Commands" if i == 0 else "\u200b", c, inline=False)
310
- e.set_footer(f"Type {self.command_prefix}<command> or /<command>")
267
+ e.set_footer(f"Type {self.command_prefix}<command>")
311
268
  await ctx.reply(embed=e)
312
269
 
313
270
  async def sync_commands(self):
@@ -413,11 +370,6 @@ class Bot:
413
370
  return
414
371
 
415
372
  if event_type == "interaction_create":
416
- # Route slash-command invocations to their registered
417
- # handlers. Falls back to a no-op (plus on_raw_event) if
418
- # the command name isn't known — that shouldn't normally
419
- # happen because the server filters by command ownership,
420
- # but we don't want to crash the dispatch loop on drift.
421
373
  from .interactions import Interaction
422
374
  interaction = Interaction(payload, client=self)
423
375
  handler = self._slash_handlers.get(interaction.command_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: banterbotapi
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Python SDK for building bots on Banter (banterchat.org) — discord.py-style.
5
5
  Author-email: Banter <contact@banterchat.org>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "banterbotapi"
7
- version = "0.2.4"
7
+ version = "0.2.6"
8
8
  description = "Python SDK for building bots on Banter (banterchat.org) — discord.py-style."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes