# !CC

### Nightbot 設定

原先是使用Nightbot + pastebin 去隨機抓取，但是[CC](https://twitch.tv/orangehappycc)名言太多時常要更新，

我自己也沒時間一直去維護那個表單，所以改到GAS上讓觀眾能自己投稿名言。

以下是指令內容

{% code overflow="wrap" lineNumbers="true" %}

```
$(eval cc = `$(urlfetch json https://script.google.com/macros/s/AKfycbwNZIQhStcNYfLJecZ1_TkAbhKkqL3yNZl4_mcu-XHddivAAdT7k2B8zeueq3VH4UCzUQ/exec)`.split(","); cc[Math.floor(Math.random() * cc.length)])
```

{% endcode %}

輸出結果:

```
[16:39] 阿痕 (ds83171): !CC
[16:39] Nightbot: 我嘗著你話裡面的奶油 溜啊溜 聽過的每句話都很可口 油啊油
```

讀取網頁回傳的 json ，用.split分割半形逗號，在陣列內的數字做隨機輸出。

### GAS(Google App Script)&#x20;

如果你只是想加!CC指令，那這段可以不用看沒關係，

這是清單的GAS ，只需要回傳清單中所有的C語錄就好了，很簡單。

```javascript
// 複製 Sheet 網址裡 [sheet-id] 的部份
// https://docs.google.com/spreadsheets/d/[sheet-id]/
const SpreadSheetID = "你的SheetID";
const SpreadSheet = SpreadsheetApp.openById(SpreadSheetID);

function getSheet(sheetName) {
  return SpreadSheet.getSheetByName(sheetName);
}

function doGet(){

  const Sheet = getSheet('Sheet1');
  var rowLength = Sheet.getLastRow() - 1; // 列數
  //var columnLength = Sheet.getLastColumn(); // 欄數
  
  //getRange (startRow,startCol,NumRows, NumCols)
  var allData = Sheet.getRange(2, 1, rowLength, 1).getValues()
  
  return ContentService.createTextOutput(allData);

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ds83171.gitbook.io/workspace/nightbot-zhi-ling/cc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
