Git Product home page Git Product logo

telegram_bot's Introduction

telegram_bot

A telegram bot for theory of computation final project.

這個聊天機器人最終的目的是可以用來查詢各種體育的隊伍數據,數據來源是個各個數據網站的資料。 目前支援的體育賽事有:

MLB
NPB(未完成)
CPBL(未完成)

目前支援的棒球隊伍數據有:

打擊率
上壘率
長打率

程式執行方法

1.確認自己有安裝python3

sudo apt-get install python3-all

2.安装python3的python-pip

sudo apt-get install python3-pip

3.有些人在安裝某些module的時候會失敗,解決的方法是執行

sudo pip3 install --upgrade pip

4.安裝程式相依的module

sudo pip3 install -r requirement.txt

4-2.沒意外的話,很多人會卡在安裝pygraphviz,這邊會出現一個錯誤,解決方法是

sudo apt-get install graphviz graphviz-dev
sudo pip install pygraphviz --install-option="--include-path='/usr/include/graphviz/'" --install-option="--library-path='/usr/lib/graphviz/'"

然後繼續安裝剩下的module

sudo pip3 install -r requirement.txt

5.準備執行程式,在這之前必須設定兩個程式裡的變數,編輯app.py更改兩個變數的內容

API_TOKEN = '你申請的telegram bot HTTP API token'
WEBHOOK_URL = 'https server url'

6.我們使用ngrok來暫時代替一個真正的http server(github附的ngrok是linux-64bit的執行檔) Flask預設port是5000

./ngrok http 5000

7.複製ngrok產生的https url加上/hook到WEBHOOK_URL,例如:

https://56790d34.ngrok.io/hook

每次執行ngrok得到的url都會不一樣,記得都要重新設定

8.執行Flask server

python3 app.py

fsm

聊天機器人使用方法

1.先選擇賽區: US 查詢MLB JP 查詢NPB TW 查詢CPBL

2.根據不同賽區有不同隊數,選擇球隊: 例如MLB可以輸入0~30 0代表重新選擇賽區 1~30代表取得不同隊的數據

3.根據不同隊的要求,會回報要求隊伍的數據內容,然後可以再次選擇隊伍

備註

1.目前因為不同賽區的數據要在不同網頁抓,所以尚未完成NPB和CPBL的部份,但為了符合作業basic要求,還是確實可以進入後面state,不過目前回報的數據內容是寫死的,不是即時數據。

2.未來可以考慮加入防禦率,歷史對戰紀錄數據

3.未來可以考慮加入籃球項目數據

4.未來可以考慮加入自動數據分析

這樣我以後玩運彩就可以靠這個分析過盤率了

telegram_bot's People

Contributors

apple11361 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.