Giter Site home page Giter Site logo

1.創一個新的Twitch帳號,作為機器人使用

2.到 https://twitchtokengenerator.com
一進去會出現下面這個,選機器人

然後拉到下面,先點Select All,再點Generate Token!

拉回上面,記下ACCESS TOKEN和CLIENT ID,之後會用到

3.開始Coding,code都在這→ https://github.com/IBM5100o/TwitchBot
這是主程式 命名為 app.py,keep_alive是另一個檔案,為了在線上跑用的

首先把剛才的token和client_id填入,nick就填機器人的帳號
initial_channels則是你想讓機器人在哪裡運作(機器人必須要有那些頻道的MOD,很重要)
這樣就完成了,如果把keep_alive去掉,直接在本地端跑就可以運作了,可以先測試看看
在頻道打 !add 1 2,機器人應該會回1+2=3

4.問題來了,你不可能一直開著電腦跑這個程式吧,所以我們需要把它丟到網路上跑
這邊我是用 fly.io,使用教學可以看這裡 fly教學
裝好後,把github那包放到一個資料夾,然後在那個資料夾用cmd打fly launch
要注意的是fly.toml和Procfile這兩個檔案,如果你在fly launch的時候有覆寫到
請把它們改回我github給的那樣,然後fly deploy機器人就上線了

5.如果怕斷線,可以用 https://uptimerobot.com ,設一個Monitor到fly
Monitor設定的網址→https://XXX.fly.dev (你的app網址)
簡單來說就是它會每隔一段時間去ping你的fly,提升穩定性(不用也可)

教學到此結束~
自己寫機器人的好處是你可以做任何你想做的事
不過如果你想要的功能沒有那麼複雜,用現有的機器人就好(例如Nightbot)

12332188a's Projects

twitchbot icon twitchbot

Create your own twitch bot with simple python code

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.