Skip to content

Extract shared Telegram helpers and dedupe README sections - #2

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1786759721-dedupe-shared-utils
Open

Extract shared Telegram helpers and dedupe README sections#2
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1786759721-dedupe-shared-utils

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Repo ini isinya dokumentasi + satu Worker, jadi duplikasi yang ada bersifat: (a) pola Telegram Bot API yang di-copy antara examples/worker.js dan snippet README, (b) blok README yang tercetak dua kali.

Shared utility baru: examples/lib/telegram.js jadi satu-satunya tempat URL Bot API, header JSON, parsing update, dan response 200 OK:

callApi(env, method, payload)   // POST https://api.telegram.org/bot<TOKEN>/<method>
sendMessage(env, chatId, text, extra?)
parseUpdate(request)            // null kalau body bukan JSON
textMessage(update)             // { chatId, text } | null
ok()                            // new Response("ok")

examples/worker.js sekarang tinggal:

const message = textMessage(await parseUpdate(request));
if (message) ctx.waitUntil(sendMessage(env, message.chatId, `Kamu bilang: ${message.text}`));
return ok();

Perilaku identik (diverifikasi lokal: update teks → satu POST sendMessage dengan body yang sama; request non-JSON → ok tanpa panggilan API). Snippet webhook di README diganti jadi versi yang import helper ini, supaya tidak ada dua implementasi yang bisa bergeser.

README dedupe: daftar isi yang muncul dua kali (di atas + di dalam bagian Workers) tinggal satu, dan dua bagian "Apa itu Cloudflare Workers?" (versi tak bernomor dan bagian 1) digabung jadi satu bagian bernomor — subbagian unik (Arsitektur Sederhana, Kapan Pakai Workers) dipertahankan.

Link to Devin session: https://app.devin.ai/sessions/b45d3060c80446b191090c9487c925d8
Requested by: @Celebez

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Celebez Celebez self-assigned this Aug 15, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant