Skip to content

如何安裝使用 clawdbot(Moltbot) 並且連線至 telegram

Published: at 下午05:26

前言

在各種消息渠道網路新聞上面衝浪時

看到一款被稱之為 MAC MINI 促銷軟體的 神器

Clawdbot(Moltbot)

於是就也來安裝一下

安裝過程

我有兩台 vps

一台 1 cpu 1GB ram

一台 8 cpu 8GB ram

那台 1 GB ram 的 死活就是裝不上去

這跟 clawdbot 是 node 開發的可能有關

導致 他需要的 ram 會比較多

也有參考 這裡 的安裝方式

做swap 用硬碟來抽換

安裝完畢 在執行設定時 (clawdbot doctor)

也都還是會遇到 JavaScript heap out of memory

<--- Last few GCs --->

[2220502:0x1baf5000]    25861 ms: Mark-Compact 478.3 (491.3) -> 476.8 (492.8) MB, pooled: 0 MB, 876.34 / 0.00 ms  (average mu = 0.158, current mu = 0.010) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xe40d24 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [clawdbot-doctor]
 2: 0x1216be0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [clawdbot-doctor]
 3: 0x1216eb7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [clawdbot-doctor]
 4: 0x1444875  [clawdbot-doctor]
 5: 0x145e109 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [clawdbot-doctor]
 6: 0x14327b8 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [clawdbot-doctor]
 7: 0x14336e5 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [clawdbot-doctor]
 8: 0x140c3be v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [clawdbot-doctor]
 9: 0x186da1c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [clawdbot-doctor]

於是就 轉身 安裝在 規格比較好的 VPS 上面

就一路順遂

前情提要 非常重要 !!!

因為 clawdbot 啟動之後 將APP 開放在 18789 port

所以要特別注意 如果使用 VPS 這個 port 不能對外

關於 如何管理 機器 防火牆 可以參考 ufw使用

機器的 port 能不開全部 就不開全部 還是比較好

開始安裝

連線至 VPS 後 輸入

 curl -fsSL curl -fsSL https://molt.bot/install.sh | bash | bash

他就會開始安裝

安裝完畢後就會看到

clawdbot-1.png

接著會問你各種選擇

以下是我的選擇

I understand this is powerful and inherently risky. Continue?
│ Yes

◇ Onboarding mode
│ QuickStart

◇ QuickStart ─────────────────────────╮
│ │
│ Gateway port: 18789 │
│ Gateway bind: Loopback (127.0.0.1) │
│ Gateway auth: Token (default) │
│ Tailscale exposure: Off │
│ Direct to chat channels. │
│ │
├──────────────────────────────────────╯

◇ Model/auth provider
│ Copilot

◇ Copilot auth method
│ GitHub Copilot (GitHub device login)

◇ GitHub Copilot ─────────────────────────────────────────────╮
│ │
│ This will open a GitHub device login to authorize Copilot. │
│ Requires an active GitHub Copilot subscription. │
│ │
├──────────────────────────────────────────────────────────────╯
┌ GitHub Copilot login

◇ Device code ready

◇ Authorize ──────────────────────────────╮
│ │
│ Visit: https://github.com/login/device
│ Code: 9CE0-382F │
│ │
├──────────────────────────────────────────╯

◇ How channels work ─────────────────────────────────────────────────────────────────────╮ │ │ │ DM security: default is pairing; unknown DMs get a pairing code. │ │ Approve with: clawdbot pairing approve │ │ Public DMs require dmPolicy=“open” + allowFrom=[”*”]. │ │ Multi-user DMs: set session.dmScope=“per-channel-peer” to isolate sessions. │ │ Docs: start/pairing │ │ │ │ Telegram: simplest way to get started — register a bot with @BotFather and get going. │ │ WhatsApp: works with your own number; recommend a separate phone + eSIM. │ │ Discord: very well supported right now. │ │ Google Chat: Google Workspace Chat app with HTTP webhook. │ │ Slack: supported (Socket Mode). │ │ Signal: signal-cli linked device; more setup (David Reagans: “Hop on Discord.”). │ │ iMessage: this is still a work in progress. │ │ Nostr: Decentralized protocol; encrypted DMs via NIP-04. │ │ Microsoft Teams: Bot Framework; enterprise support. │ │ Mattermost: self-hosted Slack-style chat; install the plugin to enable. │ │ Nextcloud Talk: Self-hosted chat via Nextcloud Talk webhook bots. │ │ Matrix: open protocol; install the plugin to enable. │ │ BlueBubbles: iMessage via the BlueBubbles mac app + REST API. │ │ LINE: LINE Messaging API bot for Japan/Taiwan/Thailand markets. │ │ Zalo: Vietnam-focused messaging platform with Bot API. │ │ Zalo Personal: Zalo personal account via QR code login. │ │ Tlon: decentralized messaging on Urbit; install the plugin to enable. │ │ │ ├─────────────────────────────────────────────────────────────────────────────────────────╯

◇ Select channel (QuickStart) │ Telegram (Bot API)

最後通訊方式 我是選擇 telegram bot

所以就要使用 /botfather 產生 一組 bot token

輸入進去之後 你的telegram bot 對話視窗就會跳出

clawdbot-2.jpg

就要回到機器上輸入 你的配對code

clawdbot pairing approve telegram {{圖中的code}}

這樣機器人才會通

可用的指令

  • 檢查配置
clawdbot doctor
  • 服務上線
 clawdbot onboard 
  • 服務重啟 服務關閉 服務啟動
clawdbot gateway start 
clawdbot gateway stop
clawdbot gateway restart

token 消耗

我使用的是 github 的 Copilot

有特別紀錄一下在使用前 的token 用量

我大概 問了快十個問題和 嘗試 叫他要提醒我在某一時間點做事

token 消耗率 就從 還有 53% 變成 剩 20%

使用前

clawdbot-3.png

使用後

clawdbot-4.png

可真的是 token 怪獸

  • 關於定時這件事情

我嘗試一直叫他 要在下個五分整點提醒我事情

他卻一直在叫說 cron 連線不到 叫我要幫他重啟

來來回回卻也還是 沒有成功讓它提醒我

一開始 以為是 時區問題 也有跟它定義了

但還是 無法成功發通知

可能是 bug 就等待優化吧

clawdbot-5.jpg

看起來 還有很多東西可以串接

但怕它亂搞 所以 就看看沒碰

但也可能是因為沒有 給他太多的權限

我用起來 就只是 把它 當作 chatgpt 的窗口 長在 telegram bot 上而已

好處可能是 它就是長在日常的 通訊系統內吧