<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[hamielKuo - Medium]]></title>
        <description><![CDATA[C#/NetCore/GoLang/Devops/Raspberry/IOT/AI - Medium]]></description>
        <link>https://medium.com/hamielkuo?source=rss----16875b90a816---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>hamielKuo - Medium</title>
            <link>https://medium.com/hamielkuo?source=rss----16875b90a816---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 21:49:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/hamielkuo" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GO.VSCode.效能調整.GoLanguageServer.更換為gopls]]></title>
            <link>https://medium.com/hamielkuo/go-vscode-%E6%95%88%E8%83%BD%E8%AA%BF%E6%95%B4-golanguageserver-%E6%9B%B4%E6%8F%9B%E7%82%BAgopls-f0197c3ca260?source=rss----16875b90a816---4</link>
            <guid isPermaLink="false">https://medium.com/p/f0197c3ca260</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Kuo Hamiel]]></dc:creator>
            <pubDate>Tue, 10 Sep 2019 07:38:57 GMT</pubDate>
            <atom:updated>2019-09-10T08:25:12.796Z</atom:updated>
            <content:encoded><![CDATA[<p>GO.VSCode.效能調整.GoLanguageServer.更換為gopls</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3QIWyEbhcUZYPc_1Bqt9rA.png" /></figure><p>朋友反應使用VSCode開發時，import 及 code auto complete都很慢，後來查閱網路資料後，發現由於VSCode預設使用的「go-langserver」是不支援使用「GO Module」套件管理方式，故微軟說將「go-langserver」更換為「gopls」來解決本問題，本篇會介紹如何安裝及啟用gopls。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*KGWEu7KQoR5XZ2XE2WUI6Q.png" /><figcaption>圖片來源： <a href="https://github.com/microsoft/vscode-go">https://github.com/microsoft/vscode-go</a></figcaption></figure><h3>安裝「gopls」</h3><p>在vscode編輯器內，使用快速鍵「ctrl+shift+p」，在輸入框內輸入「go: install/update tools」後，顯示下圖，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*wf-GUxMKEH1BU2Rpo5pJMQ.png" /></figure><p>請按下「enter」鍵後，會顯示下圖，請選擇「gopls」，等待安裝完畢，安裝完畢後，接下來開始設定vscode的「user settings」。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*zg6P139syQ0hrMhZDI7uHg.png" /><figcaption>選擇「gopls」</figcaption></figure><h3>啟用gopls</h3><p>在VSCode編輯器內，使用快速鍵「ctrl+shift+p」，在輸入框內輸入「user settings」，顯示下圖，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*vT3F6qhhn3eTVm7SYt6-jQ.png" /><figcaption>user settings</figcaption></figure><p>按下enter鍵後，會打開設定頁面如下圖，請點選「Edit in settings.json」，就會進到「settings.json」檔案內，請增加如下字串到檔案內，</p><pre>&quot;go.useLanguageServer&quot;: true</pre><p>最後結果如下圖，存檔後，將vscode重開後，問題就解決了。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*1o93_YatFD5H02ULoRQMeA.png" /></figure><p>參考資料：</p><ul><li><a href="https://github.com/microsoft/vscode-go">https://github.com/microsoft/vscode-go</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0197c3ca260" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hamielkuo/go-vscode-%E6%95%88%E8%83%BD%E8%AA%BF%E6%95%B4-golanguageserver-%E6%9B%B4%E6%8F%9B%E7%82%BAgopls-f0197c3ca260">GO.VSCode.效能調整.GoLanguageServer.更換為gopls</a> was originally published in <a href="https://medium.com/hamielkuo">hamielKuo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go.GRPC.Protobuf.Gogo安裝筆記]]></title>
            <link>https://medium.com/hamielkuo/go-grpc-protobuf-gogo%E5%AE%89%E8%A3%9D%E7%AD%86%E8%A8%98-d2f66342bc8?source=rss----16875b90a816---4</link>
            <guid isPermaLink="false">https://medium.com/p/d2f66342bc8</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[protobuf]]></category>
            <dc:creator><![CDATA[Kuo Hamiel]]></dc:creator>
            <pubDate>Sat, 07 Sep 2019 02:54:50 GMT</pubDate>
            <atom:updated>2020-10-06T06:44:11.900Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HhTVk0C5TfF0kMW-Z-qtOQ.png" /></figure><p>本篇介紹如何安裝Protobuf工具，讓我們在開發GRPC時，將Protobuf的定義檔proto，透過Google 出的轉換程序(protoc)將proto定義檔，產出對應的程序，作為後續開發GRPC用。</p><h3>安裝Protoc</h3><ol><li>下載 [ protoc-3.6.1-win32.zip ], 檔案下載位置: <a href="https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-win32.zip">https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-win32.zip</a></li><li>把上面zip檔解壓縮，將解壓縮後的檔案放置到[GOPATH/bin]底下。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*SsGGXv-onj-TlAeSLFvRbA.png" /></figure><p>3. 驗證作業，透過取得protoc 版本來確認是否安裝好protoc，打開cmd，執行下面指令，出現如下圖紅框，就是安裝完畢。</p><pre>protoc --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*UxlWAqPAf3aT8hIfROO9rw.png" /></figure><h3>安裝Go Protocol buffer plugin</h3><p>打開cmd，執行下面指令。</p><pre>go get -u github.com/golang/protobuf/protoc-gen-go</pre><h3>安裝 gogoprotobuf</h3><p>gogoprotobuf是基於protoc 上的一個更好的complier，能夠產生高質量的程序碼。</p><p>安裝方式透過go get 安裝即可，指令如下。</p><pre>go get github.com/gogo/protobuf/protoc-gen-gofast</pre><pre>go get github.com/gogo/protobuf/protoc-gen-gogoslick</pre><h3>安裝 ProtoActor Grain complier</h3><p>在建立 ProtoActor 的 Grain時，使用下面指令，會出現找不到Grain Plugin問題，</p><pre>protoc -I=. -I=%GOPATH%/src --gograin_out=. protos.proto</pre><p>原因是因為 grain 是在 ProtoActor的專案內，故需要透過下面指令去安裝相對應的「proto-gen-gogograin」，安裝完畢後，問題解決。</p><pre>go get github.com/AsynkronIT/protoactor-go/…</pre><p>以上安裝完畢後，就可以開始寫protoc，後續文章會在介紹…..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2f66342bc8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hamielkuo/go-grpc-protobuf-gogo%E5%AE%89%E8%A3%9D%E7%AD%86%E8%A8%98-d2f66342bc8">Go.GRPC.Protobuf.Gogo安裝筆記</a> was originally published in <a href="https://medium.com/hamielkuo">hamielKuo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mattermost-心得]]></title>
            <link>https://medium.com/hamielkuo/mattermost-%E5%BF%83%E5%BE%97-f071178073fd?source=rss----16875b90a816---4</link>
            <guid isPermaLink="false">https://medium.com/p/f071178073fd</guid>
            <category><![CDATA[mattermost]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Kuo Hamiel]]></dc:creator>
            <pubDate>Tue, 05 Feb 2019 02:28:54 GMT</pubDate>
            <atom:updated>2019-02-05T02:28:54.613Z</atom:updated>
            <content:encoded><![CDATA[<p>Mattermost是一個可以取代Slack的開源專案，其專案語言是用GoLang，本篇文章整理了些資料，整理如下。</p><h3>Mattermost專案開發文件</h3><p>官方文件：https://developers.mattermost.com/contribute/server/developer-setup/</p><h3>安裝開發遇到的問題如下：</h3><ul><li>第七步驟，環境變數修改，設定要修改，下面步驟是在【http://babun.github.io/】這個軟體內執行，這個軟體是一個模擬Linux環境的好工具，不過未來應該會使用WSL來處理。</li></ul><pre>以下動作是將變數改為本機的Golang執行位置。</pre><pre>export PATH=&quot;/c/Go/bin&quot;:$PATH</pre><pre>export PATH=&quot;/c/Program Files/nodejs&quot;:$PATH</pre><pre>export PATH=&quot;/c/Program Files/Git/bin&quot;:$PATH</pre><pre>export GOROOT=&quot;c:\\GO&quot;</pre><pre>export GOPATH=&quot;c:\\Users\\User\\Go&quot;</pre><pre>export PATH=&quot;/c/Program Files/Docker/Docker&quot;:$PATH # change the path accordingly if you are using Docker for Windows</pre><pre>//eval $(docker-machine env default) # skip this line if you are using Docker for Windows</pre><ul><li>使用make check-prereq 時候,會出現 [ syntax-error-near-unexpected-token $ r ]的問題。</li></ul><pre>透過下面網站,所說的方式,如下-&gt;</pre><pre>用NotePad++打開 /scripts/prereq-check.sh 後,用 edit-&gt; EOL Converison -&gt; linux,</pre><pre>存檔,重新執行程序即可.</pre><pre>https://stackoverflow.com/questions/6473766/syntax-error-near-unexpected-token-in-r</pre><ul><li>使用make restart-server時候,會無法刪除正在運行的go server, 請到工作管理員刪除 [main] 即可。</li><li>web 頁面404 解決方式，要修改原始碼，因為Windows Url跟linux 環境不一樣，導致程序在讀取網頁檔案時候，讀不到所以才會有404。</li></ul><pre>將[C:\Users\User\go\src\github.com\mattermost\mattermost-server\model]的 [client4.go ]</pre><pre>-&gt; CLIENT_DIR 改為web專案位置,如下: 注意是指定到 dist</pre><pre>C:\\Users\\User\\go\\src\\github.com\\mattermost\\mattermost-webapp\\dist\\</pre><ul><li>官方說明當部屬在超過2000人的生產環境時候，建議使用官方的測試軟體，來確認環境能否撐住。</li></ul><pre>官方：https://github.com/mattermost/mattermost-load-test</pre><h3>程序</h3><ul><li>程序運行流程</li></ul><pre>commands -&gt; Cobra -&gt; RunE -&gt; server.go -&gt; runServer -&gt;</pre><pre>NewServer -&gt; api.go -&gt; Init</pre><ul><li>程序目錄說明</li></ul><pre>. /api4,holds all API and application related code</pre><pre>. /api4/api.go,url與函式的對應表</pre><pre>. /app,邏輯,api 程序會呼叫這邊的邏輯。</pre><pre>. /app/app.go,主要邏輯。</pre><pre>. /app/server.go, session資料採用LRU Cache儲存</pre><pre>. LRU Cache,https://juejin.im/post/5ae0159e518825671c0e3900</pre><pre>. /build,放置Jenkins的指令,透過這些指令來build mattermost-server專案.</pre><pre>. /build/Dockerfile.buildenv, docker 建立的golang build環境</pre><pre>. /cmd,cmd指令</pre><pre>. /cmd/mattermost/main.go, 用「go run main」时候,Cobra会呼叫「RootCmd.RunE」所指定的函式,這系统是呼叫「server.go」,啟動「RunServer」.</pre><pre>. /config, mattermost 設定檔<br>. /data,filestore位置</pre><pre>. /doc,放置文檔,但文檔都放到網路上，故這邊只是放了一個連結。</pre><pre>. /einterfaces, 放置interface位置</pre><pre>. /fonts,字型檔</pre><pre>. /i18n,國際化,專換定義檔,有對應各國的語系檔</pre><pre>. /imports,?不知道用途</pre><pre>. /jobs,處理排成的程序</pre><pre>. /manualtesting, 手動測試</pre><pre>. /migrations, 更新版本</pre><pre>. /mlog, mattermost的log紀錄機制,其機制還包括國際化log,可以依照不同語言紀錄.</pre><pre>. /model,holds all data model definitions and the Go driver</pre><pre>. 存放所有物件定義的位置</pre><pre>. /plugin,mattermost 處理玩家自行開發的套件程序</pre><pre>. /plugins,放置自行開發的套件</pre><pre>. /scripts,shell scripts</pre><pre>. /services, 設定「設定、檔案、http、mail、mfa、timezone、mfa(處理安全相關的類別,如加密或解密)」等服務的interface</pre><pre>. /store,holds all database querying code</pre><pre>. 存放對儲存媒體的curd方式</pre><pre>. /templates,email或其他模版html</pre><pre>. /testlib,測試时候,會用到的lib</pre><pre>. /utils,holds all utilities, such as the mail utility</pre><pre>. /vendor,用govendor管理的專案相關套件都會存放在這個資料夾</pre><pre>. /web,處理web 網頁要求的handler</pre><pre>. /wsapi,處理websocket 連線</pre><h3>專案套件</h3><ul><li>Cobra, 提供簡單的接口來創建CLI工具，Docker的程序就是使用Cobra.</li></ul><pre>教學：https://o-my-chenjian.com/2017/09/20/Using-Cobra-With-Golang/</pre><ul><li>Zap, 日誌庫，表现非常突出。</li></ul><pre>日誌hook,lumberjack.Logger,http://vearne.cc/archives/658</pre><ul><li>Golang. 使用sync保证container/list链表线程安全,</li></ul><pre>參考網址：http://xiaorui.cc/2016/03/10/golang%E4%BD%BF%E7%94%A8sync%E4%BF%9D%E8%AF%81containerlist%E9%93%BE%E8%A1%A8%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8/</pre><h3>參考資料</h3><p>. API,https://api.mattermost.com/</p><p>. Incoming Webhooks,https://docs.mattermost.com/developer/webhooks-incoming.html</p><p>. Outgoing Webhooks,https://docs.mattermost.com/developer/webhooks-outgoing.html</p><p>. Slash Commands,https://docs.mattermost.com/developer/slash-commands.html</p><p>. Message Attachments,https://docs.mattermost.com/developer/message-attachments.html</p><p>. Interactive Messages: Buttons and Menus,. <a href="https://docs.mattermost.com/developer/interactive-messages.html">https://docs.mattermost.com/developer/interactive-messages.html</a></p><p>. Interactive Dialogs,https://docs.mattermost.com/developer/interactive-dialogs.html</p><p>. Personal Access Tokens,https://docs.mattermost.com/developer/personal-access-tokens.html</p><p>. OAuth 2.0 Applications,https://docs.mattermost.com/developer/oauth-2-0-applications.html</p><p>. Integrations FAQ,https://docs.mattermost.com/developer/integration-faq.html</p><p>. Embedding Mattermost in other applications,https://docs.mattermost.com/integrations/embedding.html</p><p>. Using Mattermost with Webhook,https://docs.mattermost.com/integrations/webhook.html</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f071178073fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hamielkuo/mattermost-%E5%BF%83%E5%BE%97-f071178073fd">Mattermost-心得</a> was originally published in <a href="https://medium.com/hamielkuo">hamielKuo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy-Mock.私有環境及Docker架設]]></title>
            <link>https://medium.com/hamielkuo/easy-mock-%E7%A7%81%E6%9C%89%E7%92%B0%E5%A2%83%E5%8F%8Adocker%E6%9E%B6%E8%A8%AD-f8e1211476b9?source=rss----16875b90a816---4</link>
            <guid isPermaLink="false">https://medium.com/p/f8e1211476b9</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[easymock]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[mock]]></category>
            <dc:creator><![CDATA[Kuo Hamiel]]></dc:creator>
            <pubDate>Sat, 02 Feb 2019 03:53:31 GMT</pubDate>
            <atom:updated>2019-02-02T04:00:07.106Z</atom:updated>
            <content:encoded><![CDATA[<p>Easy-Mock 是一個模擬後端 Api 的 NodeJS Server，其好處如下所列，而本篇針對私有環境及Docker兩種架設方式，做說明。</p><ol><li>讓前端與後端並行開發，不需後端先提供假Server，前後端雙方先定義好API格式即可。</li><li>整合MockJs ，其語法及相關介紹，可看【<a href="http://mockjs.com/">http://mockjs.com/</a>】。</li><li>可以自行架設在私有環境，如公司 or 本機上。</li></ol><h3>安裝環境前置作業</h3><ul><li>Node.js ,請使用8.xx最後一版,不能使用node.js 最新版本，裝新版本會遇到【<a href="https://github.com/easy-mock/easy-mock/issues/269">https://github.com/easy-mock/easy-mock/issues/269</a>】這些問題。</li></ul><pre>本篇安裝的node.js 下載位置為：「https://nodejs.org/dist/v8.9.4/node-v8.9.4-x64.msi」。</pre><ul><li>Pyhton 請安裝 Pyhton 3, 而不是Pyhton 2。</li></ul><h3>本地安裝步驟</h3><p>參考官方安裝說明文檔：<a href="https://github.com/easy-mock/easy-mock/blob/dev/README.zh-CN.md">https://github.com/easy-mock/easy-mock/blob/dev/README.zh-CN.md</a>。</p><p>下面將指令做個整理列在下方：</p><ul><li>下載原始碼</li></ul><pre>git clone https://github.com/easy-mock/easy-mock.git</pre><ul><li>進到目錄後，透過 Npm 安裝必要套件</li></ul><pre>cd easy-mock &amp;&amp; npm install</pre><ul><li>新增生產設定檔，並變更db 和 redis 位置</li></ul><pre>cd config &amp;&amp; copy default.json production.json</pre><ul><li>回到根目錄，透過 npm 建置原始碼</li></ul><pre>cd.. &amp;&amp; npm run build</pre><ul><li>設定node.js env 變數為 production。</li><li>透過 PM2 將 Easy-Mock Run 在背景，並設定在window restart時，自動啟動easymock。</li></ul><pre>npm install pm2 -g</pre><pre>npm install pm2-windows-startup -g</pre><pre>pm2-startup install</pre><pre>pm2 start app.js --name app</pre><pre># 將上面參數設定<br>pm2 save</pre><pre># 重启电脑</pre><pre>pm2 ls</pre><pre>參考來源：http://llever.com/2018/01/22/pm2-window-%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8/</pre><pre>pm2 指令：https://blog.linuxeye.cn/435.html</pre><h3>Docker安裝步驟</h3><p>參考官方說明文檔；<a href="https://github.com/easy-mock/easy-mock-docker">https://github.com/easy-mock/easy-mock-docker</a>。</p><p>注意事項，目前還不能使用log紀錄功能，故刪除官方 docker-compose內的log部分。</p><p>安裝指令如下：</p><ul><li>建立volume。</li></ul><pre>docker volume create mongodata</pre><pre>docker volume create redisdata</pre><ul><li>建立 docker-compose.yml，將下面內容貼到檔案內。</li></ul><pre>version: &quot;3.3&quot;</pre><pre>services:</pre><pre>mongodb:</pre><pre>image: mongo:latest</pre><pre>volumes:</pre><pre>- type: volume</pre><pre>source: mongodata</pre><pre>target: /data/db</pre><pre>   redis:</pre><pre>    image: redis:latest</pre><pre>command: redis-server --appendonly yes</pre><pre>volumes:</pre><pre>- type: volume</pre><pre>source: redisdata</pre><pre>target: /data</pre><pre>web:</pre><pre>image: easymock/easymock:latest</pre><pre>command: /bin/bash -c &quot;npm start&quot;</pre><pre>links:</pre><pre>- mongodb:mongodb</pre><pre>ports:</pre><pre>- 7300:7300</pre><pre>volumes:</pre><pre>- type: bind</pre><pre>source: ./production.json # 配置地址，请使用本地配置地址替换</pre><pre>target: /home/easy-mock/easy-mock/config/production.json</pre><pre># 一定要声明volumes</pre><pre>volumes:</pre><pre>mongodata:</pre><pre>external:</pre><pre>name: mongodata</pre><pre>redisdata:</pre><pre>external:</pre><pre>name: redisdata</pre><ul><li>新增設定檔，檔案名稱：production.json，將下面內容貼到檔案內，在docker運行下，不用設定DB 和 Redis。</li></ul><pre>{</pre><pre>&quot;port&quot;: 7300,</pre><pre>&quot;host&quot;: &quot;0.0.0.0&quot;,</pre><pre>&quot;pageSize&quot;: 30,</pre><pre>&quot;proxy&quot;: false,</pre><pre>&quot;unsplashClientId&quot;: &quot;&quot;,</pre><pre>&quot;blackList&quot;: {</pre><pre>&quot;projects&quot;: [],</pre><pre>&quot;ips&quot;: []</pre><pre>},</pre><pre>&quot;rateLimit&quot;: {</pre><pre>&quot;max&quot;: 1000,</pre><pre>&quot;duration&quot;: 1000</pre><pre>},</pre><pre>&quot;jwt&quot;: {</pre><pre>&quot;expire&quot;: &quot;14 days&quot;,</pre><pre>&quot;secret&quot;: &quot;shared-secret&quot;</pre><pre>},</pre><pre>&quot;upload&quot;: {</pre><pre>&quot;types&quot;: [&quot;.jpg&quot;, &quot;.jpeg&quot;, &quot;.png&quot;, &quot;.gif&quot;, &quot;.json&quot;, &quot;.yml&quot;, &quot;.yaml&quot;],</pre><pre>&quot;size&quot;: 5242880,</pre><pre>&quot;dir&quot;: &quot;../public/upload&quot;,</pre><pre>&quot;expire&quot;: {</pre><pre>&quot;types&quot;: [&quot;.json&quot;, &quot;.yml&quot;, &quot;.yaml&quot;],</pre><pre>&quot;day&quot;: -1</pre><pre>}</pre><pre>},</pre><pre>&quot;ldap&quot;: {</pre><pre>&quot;server&quot;: &quot;&quot;,</pre><pre>&quot;bindDN&quot;: &quot;&quot;,</pre><pre>&quot;password&quot;: &quot;&quot;,</pre><pre>&quot;filter&quot;: {</pre><pre>&quot;base&quot;: &quot;&quot;,</pre><pre>&quot;attributeName&quot;: &quot;&quot;</pre><pre>}</pre><pre>},</pre><pre>&quot;fe&quot;: {</pre><pre>&quot;copyright&quot;: &quot;&quot;,</pre><pre>&quot;storageNamespace&quot;: &quot;easy-mock_&quot;,</pre><pre>&quot;timeout&quot;: 25000,</pre><pre>&quot;publicPath&quot;: &quot;/dist/&quot;</pre><pre>}</pre><pre>}</pre><ul><li>運行。</li></ul><pre>docker-compose up -d</pre><ul><li>打開瀏覽器，連到 http://localhost:7300，就可以看到網站。</li></ul><h3>參考網址</h3><ul><li>Easy-Mock GitHub：https://github.com/easy-mock/easy-mock</li><li>PM2 windows ：http://llever.com/2018/01/22/pm2-window-%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8/</li><li>PM2 指令：https://blog.linuxeye.cn/435.html</li><li>window 不能使用bind,只能使用volume,故參考「https://github.com/easy-mock/easy-mock-docker/issues/7」</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8e1211476b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hamielkuo/easy-mock-%E7%A7%81%E6%9C%89%E7%92%B0%E5%A2%83%E5%8F%8Adocker%E6%9E%B6%E8%A8%AD-f8e1211476b9">Easy-Mock.私有環境及Docker架設</a> was originally published in <a href="https://medium.com/hamielkuo">hamielKuo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Telegram.Bot.申請及Channel使用方式]]></title>
            <link>https://medium.com/hamielkuo/telegram-bot-%E7%94%B3%E8%AB%8B%E5%8F%8Achannel%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F-419bd470f030?source=rss----16875b90a816---4</link>
            <guid isPermaLink="false">https://medium.com/p/419bd470f030</guid>
            <category><![CDATA[telegram]]></category>
            <dc:creator><![CDATA[Kuo Hamiel]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 09:34:38 GMT</pubDate>
            <atom:updated>2022-06-10T03:49:06.428Z</atom:updated>
            <content:encoded><![CDATA[<p>Telegram是個通訊軟體，但也可以自行開發程序，做個像Line機器人一樣的功能，故用這個來當系統運行Fail時的通知。</p><h4>本文分成:</h4><ol><li>申請Bot流程</li><li>如何使用Telegram的Channel，來推送訊息</li><li>Telegram bot 傳送訊息時，注意事項</li></ol><h4>1. 申請Bot流程</h4><p>找到Telegram的bot申請帳號: 【BotFather】，跟他對話.</p><p>申請的對話流程，如下: 以下模擬對話流程</p><p>me =&gt;申請人，BotFather=&gt; Telegram的申請帳號Bot</p><p>me : /newbot</p><p>BotFather: Alright, a new bot. How are we going to call it? Please choose a name for your bot.</p><p>me: 這邊打上，你要設定的bot name</p><p>BotFather: Good. Now let’s choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.</p><p>me: 這邊打上，bot的username，注意 名稱內一定要打上【bot】，這個也是未來別人要找你的bot時，用的名稱。</p><p>BotFather: ps=&gt; 回覆分兩種 ，</p><p>如果跟別人的bot名稱重複，就會申請失敗，出現=&gt;Sorry, this username is already taken. Please try something different</p><p>下面就是正常回應狀況，代表成功=&gt; 最重要的是這邊會顯示Token，未來程序會用這個當作登入密碼，可用【/token】再次申請。</p><p>Done! Congratulations on your new bot. You will find it at <a href="http://telegram.me/ambersysbot">telegram.me/ambersysbot</a>. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you’ve finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.</p><p>Use this token to access the HTTP API:<br>【這邊會顯示Token】</p><p>For a description of the Bot API, see this page: <a href="https://core.telegram.org/bots/api">https://core.telegram.org/bots/api</a></p><p>— — 到這邊就算申請成功，如果要看下可用指令，可打【/help】。</p><h4>2. 如何使用Telegram的Channel，來推送訊息</h4><p>bot要發送訊息，需要 chatid 才能知道要發訊息到那邊，而 chatid 取得方式是用 telegram api 提供的 [ getUpdates ].</p><p>使用方式:</p><ol><li>將 bot 加入到 Group or Chanel，並設置為[ administrators ]，才能獲得該群的資料。</li><li>在群裡，隨便傳遞各訊息。</li><li>打開瀏覽器使用 <a href="https://api.telegram.org/bot%7Btoken%7D/getUpdates">https://api.telegram.org/bot{token}/getUpdates</a> ，在回傳的訊息中，就可以看到chatid。</li><li>透過tg api : sendmessage，測試傳遞訊息，<a href="https://api.telegram.org/bot%7Btoken%7D/sendMessage?chat_id={chatid}&amp;text={%E8%A8%8A%E6%81%AF}%E3%80%82">https://api.telegram.org/bot{token}/sendMessage?chat_id={chatid}&amp;text={訊息}。</a></li></ol><h4>3. Telegram bot 傳送訊息時，注意事項</h4><p>注意事項如官方說明(如下)，簡單來說，就是不能在一分鐘內傳送20個訊息及一秒鐘內不能傳超過30個訊息，不然會被Telegram擋掉，</p><p>不過測試時，發現以每3秒做傳送的話，會被TG擋掉，現在測試後，以每次5秒傳送訊息，基本上沒問題，給大家參考。</p><p>If you’re sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so. Consider spreading out notifications over large intervals of 8–12 hours for best results.</p><p>Also note that your bot will not be able to send more than 20 messages per minute to the same group</p><p><strong>4. tg api getupdates 注意事項</strong></p><p>當群組有過多訊息，未被Bot確認為已讀訊息時，會導致打api 後，看到的訊息都是舊的，必須透過 offset=「最後一筆訊息update_id」，來設定訊息為已讀。</p><h4>指令:</h4><ul><li>/newbot : 申請新的bot</li><li>/setname : 設定bot的名稱</li><li>/token : 重新申請token</li><li>/mybots：顯示申請過的bot</li></ul><h4>參考網址:</h4><ul><li>API文件，<a href="https://core.telegram.org/bots/api">https://core.telegram.org/bots/api</a></li><li>官方說明， <a href="https://core.telegram.org/bots">https://core.telegram.org/bots</a></li><li>Walker，<a href="http://studyhost.blogspot.tw/2016/06/telegram-bot.html">http://studyhost.blogspot.tw/2016/06/telegram-bot.html</a></li><li>Telegram 即時通活用教學：10大最愛技巧包含中文化，<a href="http://www.playpcesor.com/2015/12/telegram-10.html">http://www.playpcesor.com/2015/12/telegram-10.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=419bd470f030" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hamielkuo/telegram-bot-%E7%94%B3%E8%AB%8B%E5%8F%8Achannel%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F-419bd470f030">Telegram.Bot.申請及Channel使用方式</a> was originally published in <a href="https://medium.com/hamielkuo">hamielKuo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>