loopbot-discord-sdk 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,434 @@
1
+ Metadata-Version: 2.4
2
+ Name: loopbot-discord-sdk
3
+ Version: 1.0.0
4
+ Summary: Official Loop Discord SDK for Python - Build Discord bots without websockets
5
+ Author-email: Loop <contact@loopbot.app>
6
+ License: MIT
7
+ Project-URL: Homepage, https://loopbot.app
8
+ Project-URL: Documentation, https://loopbot.app/docs
9
+ Project-URL: Repository, https://github.com/loopbot/python-sdk
10
+ Project-URL: Issues, https://github.com/loopbot/python-sdk/issues
11
+ Keywords: discord,bot,sdk,loop,loopbot,interactions,slash-commands,buttons,modals
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Communications :: Chat
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ Requires-Dist: aiohttp>=3.8.0
28
+ Requires-Dist: aiohttp-sse-client>=0.2.1
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
32
+ Requires-Dist: black>=23.0.0; extra == "dev"
33
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
34
+
35
+ # LoopBot SDK Python
36
+
37
+ Biblioteca oficial para criar bots no LoopBot usando Python.
38
+
39
+ ## Instalação
40
+
41
+ ```bash
42
+ pip install loopbot-sdk
43
+ ```
44
+
45
+ ## Inicialização
46
+
47
+ ```python
48
+ from loopbot import Bot
49
+
50
+ bot = Bot(
51
+ token="seu_token_aqui"
52
+ )
53
+
54
+ # ... seus comandos aqui ...
55
+
56
+ bot.start()
57
+ ```
58
+
59
+ ## Guia Completo
60
+
61
+ ### Trabalhando com Embeds
62
+
63
+ Embeds são mensagens ricas que permitem exibir informações de forma estruturada.
64
+
65
+ ```python
66
+ from loopbot.builders import EmbedBuilder
67
+
68
+ @bot.command("embed_demo", "Demonstração de Embed")
69
+ def embed_demo(ctx):
70
+ # Criando um embed
71
+ embed = (
72
+ EmbedBuilder()
73
+ .set_title("Título do Embed")
74
+ .set_description("Descrição detalhada aqui...")
75
+ .set_color(0x00FF00) # Cor em hexadecimal (ex: Verde)
76
+ .set_url("https://loopbot.app")
77
+ .set_footer("Rodapé", icon_url="https://exemplo.com/icone.png")
78
+ .set_author("Nome Autor", url="https://perfil.com", icon_url="https://avatar.com/img.png")
79
+ .set_image("https://exemplo.com/imagem_grande.png")
80
+ .set_thumbnail("https://exemplo.com/miniatura.png")
81
+ .add_field("Campo 1", "Valor 1", inline=True)
82
+ .add_field("Campo 2", "Valor 2", inline=True)
83
+ .set_timestamp() # Usa hora atual se não especificado
84
+ )
85
+
86
+ # Enviando o embed
87
+ ctx.reply(embeds=[embed])
88
+ ```
89
+
90
+ ### Trabalhando com Containers (Componentes V2)
91
+
92
+ Containers são componentes avançados que permitem agrupar outros componentes, como textos, separadores e galerias.
93
+
94
+ > **Nota:** Para enviar containers, use o método `reply_with_components` ou `update_with_components`.
95
+
96
+ ```python
97
+ from loopbot.builders import ContainerBuilder, SeparatorBuilder, MediaGalleryBuilder
98
+
99
+ @bot.command("container_demo", "Demonstração de Container")
100
+ def container_demo(ctx):
101
+ # Criando um container
102
+ container = (
103
+ ContainerBuilder()
104
+ .set_accent_color(0xFF0000) # Cor da barra lateral
105
+ .set_spoiler(False) # Se o conteúdo é spoiler
106
+ .add_text("# Título dentro do Container")
107
+ .add_text("Este é um texto normal dentro do container.")
108
+ )
109
+
110
+ # Adicionando um Separador
111
+ # spacing: 1 (pequeno) ou 2 (grande)
112
+ container.add_separator(divider=True, spacing=1)
113
+
114
+ # Adicionando uma Galeria de Mídia
115
+ gallery = (
116
+ MediaGalleryBuilder()
117
+ .add_item("https://exemplo.com/img1.png", "Legenda 1")
118
+ .add_item("https://exemplo.com/img2.png", "Legenda 2")
119
+ )
120
+ container.add_component(gallery)
121
+
122
+ # Enviando o container
123
+ ctx.reply_with_components(components=[container])
124
+ ```
125
+
126
+ ### Separadores
127
+
128
+ Separadores ajudam a organizar visualmente o conteúdo dentro de containers ou como componentes independentes.
129
+
130
+ ```python
131
+ from loopbot.builders import SeparatorBuilder
132
+
133
+ # Separador com linha visível e espaçamento grande
134
+ sep = SeparatorBuilder().set_divider(True).set_spacing(2)
135
+
136
+ container.add_component(sep)
137
+ ```
138
+
139
+ ### Respondendo Interações
140
+
141
+ O contexto (`ctx`) oferece vários métodos para responder a comandos e interações.
142
+
143
+ #### Responder com Texto e Embeds
144
+
145
+ ```python
146
+ # Apenas texto
147
+ ctx.reply("Olá mundo!")
148
+
149
+ # Texto e Embed
150
+ ctx.reply("Veja isso:", embeds=[embed])
151
+
152
+ # Resposta efêmera (visível apenas para o usuário que executou o comando)
153
+ ctx.reply("Segredo...", ephemeral=True)
154
+ ```
155
+
156
+ #### Responder com Componentes V2 (Containers)
157
+
158
+ Para enviar Containers, Galerias ou Separadores como resposta principal.
159
+
160
+ ```python
161
+ ctx.reply_with_components(components=[container1, container2])
162
+ ```
163
+
164
+ #### Atualizando a Mensagem Original
165
+
166
+ Útil para interações de botões ou menus de seleção, onde você deseja alterar a mensagem original em vez de enviar uma nova.
167
+
168
+ ```python
169
+ @bot.on_button("meu_botao")
170
+ def on_click(ctx):
171
+ # Atualiza texto e embeds da mensagem onde o botão estava
172
+ embed = EmbedBuilder().set_title("Atualizado!")
173
+ ctx.update(content="Nova mensagem", embeds=[embed])
174
+
175
+ # Ou para atualizar com Containers
176
+ # ctx.update_with_components(components=[novo_container])
177
+ ```
178
+
179
+ #### Editando a Resposta (Follow-up)
180
+
181
+ Se você já respondeu (por exemplo, com `defer` ou uma resposta rápida) e quer editar essa resposta depois.
182
+
183
+ ```python
184
+ @bot.command("processar", "Processamento longo")
185
+ def processar(ctx):
186
+ # Avise que está processando
187
+ ctx.defer()
188
+
189
+ # ... processamento demorado ...
190
+
191
+ # Edita a resposta original
192
+ ctx.edit_reply(content="Processamento concluído!", embeds=[resultado_embed])
193
+ ```
194
+
195
+ ### Botões e Action Rows
196
+
197
+ Botões são componentes interativos que os usuários podem clicar. Eles devem ser colocados dentro de uma `ActionRow`.
198
+
199
+ ```python
200
+ from loopbot.builders import ActionRowBuilder, ButtonBuilder
201
+
202
+ @bot.command("botoes", "Demo de botões")
203
+ def botoes(ctx):
204
+ # Criando botões
205
+ btn_primario = (
206
+ ButtonBuilder()
207
+ .set_label("Clique aqui")
208
+ .set_custom_id("btn_click")
209
+ .set_style(1) # 1: Primary (Azul)
210
+ )
211
+
212
+ btn_link = (
213
+ ButtonBuilder()
214
+ .set_label("Visite o site")
215
+ .set_url("https://loopbot.app")
216
+ .set_style(5) # 5: Link (Cinza)
217
+ )
218
+
219
+ # Adicionando à ActionRow
220
+ row = ActionRowBuilder().add_button(btn_primario).add_button(btn_link)
221
+
222
+ ctx.reply("Escolha uma opção:", components=[row])
223
+
224
+ @bot.on_button("btn_click")
225
+ def on_btn_click(ctx):
226
+ ctx.reply("Você clicou no botão!", ephemeral=True)
227
+ ```
228
+
229
+ ### Menus de Seleção (Dropdowns)
230
+
231
+ Menus de seleção permitem que o usuário escolha uma ou mais opções de uma lista.
232
+
233
+ ```python
234
+ from loopbot.builders import SelectMenuBuilder
235
+
236
+ @bot.command("menu", "Demo de menu")
237
+ def menu(ctx):
238
+ select = (
239
+ SelectMenuBuilder()
240
+ .set_custom_id("menu_selecao")
241
+ .set_placeholder("Escolha sua classe")
242
+ .add_option("Guerreiro", "warrior", "Classe de combate corpo a corpo")
243
+ .add_option("Mago", "mage", "Classe de magia", emoji={"name": "🔮"})
244
+ .set_min_values(1)
245
+ .set_max_values(1)
246
+ )
247
+
248
+ row = ActionRowBuilder().add_select_menu(select)
249
+ ctx.reply("Selecione sua classe:", components=[row])
250
+
251
+ @bot.on_select("menu_selecao") # Evento ainda não implementado na SDK Python, verifique suporte
252
+ def on_menu_select(ctx):
253
+ # Lógica de manipulação
254
+ pass
255
+ ```
256
+
257
+ ### Modais (Formulários)
258
+
259
+ Modais são janelas pop-up com formulários para entrada de texto.
260
+
261
+ ```python
262
+ from loopbot.builders import ModalBuilder
263
+
264
+ @bot.command("feedback", "Enviar feedback")
265
+ def feedback(ctx):
266
+ modal = (
267
+ ModalBuilder()
268
+ .set_custom_id("modal_feedback")
269
+ .set_title("Nos dê seu feedback")
270
+ .add_text_input(
271
+ custom_id="input_msg",
272
+ label="Mensagem",
273
+ style="paragraph", # ou "short"
274
+ placeholder="Escreva aqui...",
275
+ required=True
276
+ )
277
+ )
278
+
279
+ ctx.show_modal(modal)
280
+ ```
281
+
282
+ ### Layout Avançado (Sections)
283
+
284
+ Sections permitem agrupar texto com um "acessório" lateral, como um botão ou imagem.
285
+
286
+ ```python
287
+ from loopbot.builders import SectionBuilder, ButtonBuilder
288
+
289
+ @bot.command("section", "Demo de Section")
290
+ def section(ctx):
291
+ btn = ButtonBuilder().set_label("Ver Mais").set_url("https://google.com").set_style(5)
292
+
293
+ section = (
294
+ SectionBuilder()
295
+ .add_text("**Título da Seção**")
296
+ .add_text("Descrição detalhada ao lado do botão.")
297
+ .set_button_accessory(btn)
298
+ )
299
+
300
+ ctx.reply_with_components(components=[section])
301
+ ```
302
+
303
+ ### Arquivos
304
+
305
+ Envio de arquivos como anexos ou dentro de estruturas.
306
+
307
+ ```python
308
+ from loopbot.builders import FileBuilder
309
+
310
+ file = FileBuilder("https://exemplo.com/arquivo.pdf").set_spoiler(False)
311
+ # Adicione a um container ou envie conforme suporte da API
312
+ ```
313
+
314
+ ## Referência Rápida
315
+
316
+ | Funcionalidade | Builder / Método |
317
+ | :--- | :--- |
318
+ | **Embed** | `EmbedBuilder` |
319
+ | **Container** | `ContainerBuilder` |
320
+ | **Separador** | `SeparatorBuilder` |
321
+ | **Galeria** | `MediaGalleryBuilder` |
322
+ | **Botão** | `ButtonBuilder` |
323
+ | **Action Row** | `ActionRowBuilder` |
324
+ | **Select Menu** | `SelectMenuBuilder` |
325
+ | **Modal** | `ModalBuilder` |
326
+ | **Section** | `SectionBuilder` |
327
+ | **Arquivo** | `FileBuilder` |
328
+ | **Responder** | `ctx.reply(...)` |
329
+ | **Responder (Container)** | `ctx.reply_with_components(...)` |
330
+ | **Atualizar Msg** | `ctx.update(...)` |
331
+ | **Editar Resposta** | `ctx.edit_reply(...)` |
332
+
333
+ ## API de Mensagens Diretas
334
+
335
+ Envie mensagens fora do contexto de interação, gerencie canais, cargos e mais.
336
+
337
+ ### Enviando Mensagens
338
+
339
+ ```python
340
+ # Enviar mensagem para qualquer canal
341
+ await bot.send(channel_id, content="Olá!")
342
+
343
+ # Editar mensagem
344
+ await bot.edit_message(channel_id, message_id, content="Atualizado!")
345
+
346
+ # Deletar mensagem
347
+ await bot.delete_message(channel_id, message_id)
348
+ ```
349
+
350
+ ### Gerenciamento de Canais
351
+
352
+ ```python
353
+ # Criar canal
354
+ await bot.create_channel(guild_id, "novo-canal", topic="Descrição")
355
+
356
+ # Modificar canal
357
+ await bot.modify_channel(channel_id, name="canal-renomeado")
358
+
359
+ # Deletar canal
360
+ await bot.delete_channel(channel_id)
361
+ ```
362
+
363
+ ### Canais de Fórum
364
+
365
+ ```python
366
+ # Criar post no fórum
367
+ await bot.create_forum_post(
368
+ forum_channel_id,
369
+ name="Título do Post",
370
+ message={"content": "Conteúdo aqui"},
371
+ applied_tags=["tag_id"]
372
+ )
373
+
374
+ # Obter/modificar tags do fórum
375
+ tags = await bot.get_forum_tags(forum_channel_id)
376
+ await bot.modify_forum_tags(forum_channel_id, [{"name": "Nova Tag"}])
377
+
378
+ # Arquivar/trancar threads
379
+ await bot.archive_thread(thread_id)
380
+ await bot.lock_thread(thread_id)
381
+ ```
382
+
383
+ ### Cargos (Roles)
384
+
385
+ ```python
386
+ # Obter cargos
387
+ roles = await bot.get_roles(guild_id)
388
+
389
+ # Criar cargo
390
+ await bot.create_role(guild_id, name="Moderador", color=0x00FF00)
391
+
392
+ # Modificar cargo
393
+ await bot.modify_role(guild_id, role_id, name="Admin", hoist=True)
394
+
395
+ # Deletar cargo
396
+ await bot.delete_role(guild_id, role_id)
397
+
398
+ # Reordenar cargos
399
+ await bot.reorder_roles(guild_id, [{"id": role_id, "position": 2}])
400
+ ```
401
+
402
+ ### Webhooks
403
+
404
+ ```python
405
+ # Criar webhook
406
+ webhook = await bot.create_webhook(channel_id, "Meu Webhook")
407
+
408
+ # Enviar mensagem via webhook
409
+ await bot.execute_webhook(
410
+ webhook_id, webhook_token,
411
+ content="Mensagem via webhook!",
412
+ username="Nome Customizado"
413
+ )
414
+
415
+ # Editar/deletar mensagem do webhook
416
+ await bot.edit_webhook_message(webhook_id, webhook_token, message_id, content="Editado")
417
+ await bot.delete_webhook_message(webhook_id, webhook_token, message_id)
418
+
419
+ # Deletar webhook
420
+ await bot.delete_webhook(webhook_id)
421
+ ```
422
+
423
+ ### Gerenciamento de Membros
424
+
425
+ ```python
426
+ # Adicionar/remover cargos
427
+ await bot.add_member_role(guild_id, user_id, role_id)
428
+ await bot.remove_member_role(guild_id, user_id, role_id)
429
+
430
+ # Expulsar/banir membros
431
+ await bot.kick_member(guild_id, user_id)
432
+ await bot.ban_member(guild_id, user_id)
433
+ ```
434
+
@@ -0,0 +1,26 @@
1
+ loopbot/__init__.py,sha256=oIkHZq8f8ygeHGLMiYgTd8cB_PmrNFDcNZnkccES7ws,1197
2
+ loopbot/bot.py,sha256=1KXrUJwlplc0cwrrLN_svJMSO41ToVdbGfPVvt39_m8,20615
3
+ loopbot/client.py,sha256=oCevrQZLGXJnaIZ87KY-VkzsZGEYJiCfFpYTE5s2nnA,26790
4
+ loopbot/types.py,sha256=MZcQgVvVDSs60UqAF5lWkHNM3yo9KLKDxZaU6tKndZQ,1645
5
+ loopbot/builders/__init__.py,sha256=STrS9XOMPsVDzx9VAvbOZW2f8fp6mITbZWzdkgmqNe4,790
6
+ loopbot/builders/action_row.py,sha256=ouQKGpcb9KIWwUWJzUT6kH7Ov60UCZi5FjWlXC6sRVw,1225
7
+ loopbot/builders/button.py,sha256=BsPTZq4-k053C3mGgRzUfxhPUw5KqX8HbLevOYBWJ5E,1649
8
+ loopbot/builders/container.py,sha256=ke5-tN1Evwl01pBlTenlSCnk2I2Lu6SmcC9uTcuSIJM,1976
9
+ loopbot/builders/embed.py,sha256=zeYR0Y2I42ZL-LVct6aJX9osybtbDyNDm28YtWlne04,2762
10
+ loopbot/builders/file.py,sha256=7UQ9lH3wmuRzeQKH9oBh_jZH1YoqNaXYFp1917I3e5U,888
11
+ loopbot/builders/media_gallery.py,sha256=VjWTDR2eyKFKRJLionoHtdPe3oZZC9cQ0FYInSdS_Oc,960
12
+ loopbot/builders/modal.py,sha256=dPErGSu1AuC4skzWs4JQr6NDbXqvd4IIigxfGvFMtho,1978
13
+ loopbot/builders/section.py,sha256=qdx10zXuWPOtVoRDbRnQ3ZiTQZPQFT80AuSS47duZO4,1516
14
+ loopbot/builders/select_menu.py,sha256=Ay5-7mCnyt4Q9Diyd50T79nZrcWoWD6BITgaWCldtz8,1975
15
+ loopbot/builders/separator.py,sha256=RWy04jS6k67wWULoSI_wlTNbV0D8L0P4XFSQgjwWe_U,882
16
+ loopbot/builders/text_display.py,sha256=vtU9NJ_QL0Kilp-nkub6mwREXcTaEzl-OFiWWlfwmEE,653
17
+ loopbot/context/__init__.py,sha256=Z3-t2n-LcL4FT-rrmPPB131JBL3t6kbC2RSXopvOqKU,352
18
+ loopbot/context/base.py,sha256=7GUiEBuo12KoJ1e2K0xR_u8idZr-mnO5OSxXTmAWgzI,8104
19
+ loopbot/context/button.py,sha256=5-XO6mYNMx2FPHhv8ijiUrsALOkxzSal-NKvVvXvMnM,756
20
+ loopbot/context/command.py,sha256=i7Z8o3F5mLvQDDSVdio8LMB5-zPzMKtSiPsK1WgNg4c,3076
21
+ loopbot/context/modal.py,sha256=QTgKDRZP7g43S3ScR5dMGKzZolUDWMtVmYqEip4GJXI,1476
22
+ loopbot/context/select.py,sha256=8ozLkBNdlZBdQdeCbJ2545j3YkwsCBUnFpHWQPW5VIw,954
23
+ loopbot_discord_sdk-1.0.0.dist-info/METADATA,sha256=2ooM5EqAJQXzhCZdAcnwpLnhbis9Duwwuyy2lBgyG0Y,12504
24
+ loopbot_discord_sdk-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
25
+ loopbot_discord_sdk-1.0.0.dist-info/top_level.txt,sha256=4sZzEMpMwz6lUz7RJzVFFh7LY-vr5W1-RAfn_bF6tks,8
26
+ loopbot_discord_sdk-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ loopbot