gevanni_bot's People
gevanni_bot's Issues
テストデータのファイル化
テストデータをjsonファイルから読み込むように修正する
テストの共通化
テストごとで共通してる処理をまとめる
テストを書き直す
Chai とかいらないかも。
assert だけでイケる。
→ chai をメインに例外処理などを書き直す
error = (()=>glib.Sugar.GAS.hasOwnProperty('extend'));
assert.throws(error, /hasOwnProperty/);
glib.GAS.extend({
namespaces: ['GAS']
});
例外処理
テストのクラス化対応
テストファイルを、クラスのテストとその他で分割する
dopost での重複処理
dopost 時に投稿済のものが投稿されてしまう
sugar-gs を使うよう修正
node モジュールの sugar ではなく、sugar-gs を使うよう修正する
Common のテスト修正
コマンドの登録
コマンドの登録は BotFather にやってもらう
ハイフンorアンダーバー
プロジェクト名に含むのはハイフンとアンダーバーのどちらが適切か
結論
- nodejs のモジュールなどはハイフン
- 個人プロジェクトはアンダーバー
- ブログにまとめるとかしたら完了
参考記事色々
createPayloadList 関数をクラスから外す
createPayloadList
はプロジェクト特有の処理なので、クラス内から移動させる
クラスを別ファイルへと分割
クラスを別ファイルへと分割して、他のコードからも参照できるようにする
同じプロジェクト内であれば参照可能
If both gs are in the same project, its already available. Else read about apps script libraries.
両方のgが同じプロジェクトにあれば、すでに利用可能です。それ以外の場合は、アプリスクリプトライブラリについて読んでください。
簡単なはずなのに余計なことをしている例
クラスのインスタンス化を不要化
クラスをインスタンス化しなくても良いように修正する
telegram 投稿をライブラリ化する
Common クラスの修正
名前を変えたり色々
- Common クラスを適切に修正する
- クロージャーは使わない
- ファイル名を大文字始まりに修正する
- そのうちやる
投稿処理の共通化
telegram への投稿処理を共通化する
dopost.js の作成
1分ごとのチェックではなく、即時返信に対応するために doPost を実装する
function doPost(e) {
var json = JSON.parse(e.postData.contents);
...
}
参考記事
リアルタイム応答でもID保存
リアルタイム投稿でもIDを保存して、どこまでの投稿に対応したかを覚えておく
テストデータを、各ファイル毎に分配
node-fixtures を使うといい感じに書ける
node-config は特定のルールに基づいたファイルでないと読み込めない
コードのクラス化
GAS ファイルの方をクラス化して見やすくする
power-assert が使えるか検証する
chai を power-assert に置き換えれるか検証する
- power-assert-js/power-assert: Power Assert in JavaScript. Provides descriptive assertion messages through standard assert interface. No API is the best API.
- Chaiをやめてpower-assertを使うことにした - WEB SALAD
- mocha + power-assert環境の構築 - Qiita
- power-assertの例外処理を見やすくする - Qiita
テストファイルの分割はしない。
以下の記事は使わないけど参考に。
OSで処理わけ
テストデータを、GAS実行時のみ設定したい
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.