Cov txheej txheem:

Raspberry Pi Slack Scroll Bot!: 10 Kauj Ruam
Raspberry Pi Slack Scroll Bot!: 10 Kauj Ruam

Video: Raspberry Pi Slack Scroll Bot!: 10 Kauj Ruam

Video: Raspberry Pi Slack Scroll Bot!: 10 Kauj Ruam
Video: Slack Pi Bot 2024, Hlis ntuj nqeg
Anonim
Raspberry Pi Slack Scroll Bot!
Raspberry Pi Slack Scroll Bot!
Raspberry Pi Slack Scroll Bot!
Raspberry Pi Slack Scroll Bot!
Raspberry Pi Slack Scroll Bot!
Raspberry Pi Slack Scroll Bot!

Txoj haujlwm no suav nrog Raspberry Pi nrog Pimoroni Scroll Bot cov khoom siv (hloov kho nrog cov nyees khawm), Slack, thiab IFTT rau kev pom thiab hnov suab ceeb toom thaum cov vis dis aus youtube tau tshaj tawm rau npe!

Lub pob hloov kho rau cov khoom siv yog nyob ntawm yeem, nrog rau tus neeg hais lus tshaj tawm txog qhov tuaj txog ntawm cov vis dis aus tshiab.

Koj kuj tseem tuaj yeem siv qhov no los xa cov lus mus rau bot los ntawm kev ua qeeb los ntawm kev ua ntej "bot" ua ntej ntawm cov lus, xws li "bot nyob zoo ntiaj teb". "bot clear" yuav tshem qhov screen.

Kauj ruam 1: Scroll Bot Assembly

Ua kom tiav cov lus qhia rau kev sib sau Pimoroni Scroll Bot:

learn.pimoroni.com/tutorial/sandyj/assembl…

Kauj Ruam 2: Nruab Pob thiab Codebase

Nruab Pob Pob:

sudo apt-tau hloov tshiab & sudo apt-tau hloov tshiab -y

sudo apt-tau nruab mpg123

Nruab pob sej:

pip nruab flask

pip nruab psutil pip nruab slackclient

Ua raws li kev qhia ntawm Pimoroni's rau Pib Nrog Scroll Hat:

learn.pimoroni.com/tutorial/sandyj/getting…

uas suav nrog rub tawm cov qauv piv txwv cov cai thiab cov peev txheej:

curl https://get.pimoroni.com/scrollphathd | tsoo

Txij li lub vijtsam tau teeb tsa upside down hauv cov khoom siv neeg hlau, koj yuav tsum tsis ua raws txoj cai kom tig lub vijtsam 180:

$ sed -i 's/#scrollphathd.rotate (degrees = 180) /scrollphathd.rotate (degrees = 180)/g' /home/pi/Pimoroni/scrollphathd/examples/web-api.py

Kauj ruam 3: Configuring Slack Instance

Configuring Slack Instance
Configuring Slack Instance
Configuring Slack Instance
Configuring Slack Instance

Rau tsab ntawv los tham nrog Slack, koj yuav xav tau tus lej API API.

Pib los ntawm kev nkag mus rau hauv koj pawg Slack lub vev xaib (https://my.slack.com/services/new/bot) thiab xaiv lub npe siv rau koj tus bot, tom qab ntawd luam theej API API cim.

Kauj Ruam 4: Tsim Slack Channel, thiab Caw Koj Cov Neeg Hlau rau Channel

Tsim Slack Channel, thiab Caw Koj Cov Neeg Hlau rau Channel
Tsim Slack Channel, thiab Caw Koj Cov Neeg Hlau rau Channel

Koj tuaj yeem siv cov channel slack dav dav, lossis yog tias koj xav tau koj tuaj yeem tsim cov channel slack cais.

Hauv kuv qhov xwm txheej kuv siv #neeg hlau-claire-tswj

Koj yuav tsum caw koj tus neeg hlau mus rau hauv cov channel, lossis nws yuav tsis pom cov lus uas tau xa tuaj.

Kauj ruam 5: Rub tawm SlackPiBot Source Code & Configure

Rub lub slackPiBot sourcecode los ntawm git:

git clone

Hloov kho kab 29 nrog koj tus lej API:

slack_client = SlackClient ("xoxb-KOJ-API-KEY-HERE")

Hloov kho kab 34 nrog koj lub npe neeg hlau:

yog user.get ('lub npe') == "neeg hlau-claire":

Kauj Ruam 6: Kho Kho Crontabs kom Pib Txais ntawm khau raj:

Teeb tsa crontabs kom pib txiav ntawm khau raj:

crontab -e

Ntxiv cov hauv qab no rau hauv qab ntawm koj lub crontab:

@reboot python /home/pi/Pimoroni/scrollphathd/examples/web-api.py@reboot python /home/pi/slackPiBot/check_button.py @reboot python /home/pi/slackPiBot/forever.py/home/pi/ slackPiBot/slackPiBot.py >> /home/pi/slackPiBot/outputLog.txt 2> & 1

Kauj Ruam 7: Tsis teb los tau: Ntxiv USB Cov Lus Hais Tawm

Txog qhov haujlwm no, Kuv tab tom siv USB hais lus los ntawm Asmeskas Robotics - muaj nyob ntawm amazon lossis ebay.

Yog tias siv qee yam zoo sib xws, koj yuav tsum tau hloov lub kaw lus txheej txheem suab los ntawm kev hloov kho alsa teeb tsa (/usr/share/alsa/alsa.conf). Hloov cov kab hauv qab no:

defaults.ctl.card 1defaults.pcm.card 1

1 yog qhov ntsuas ntawm koj lub cuab yeej. Txhawm rau nrhiav tus lej ID ntawm koj lub cuab yeej USB, khiav aplay -l thiab nrhiav daim npav ID.

Kauj Ruam 8: Tsis teb los tau: Ntxiv Wired Buttons rau Neeg Hlau kom Pom Cov Lus

Tsis teb los tau: Ntxiv Wired Nyees khawm rau Neeg Hlau kom pom meej cov lus
Tsis teb los tau: Ntxiv Wired Nyees khawm rau Neeg Hlau kom pom meej cov lus
Tsis teb los tau: Ntxiv Wired Nyees khawm rau Neeg Hlau kom pom meej cov lus
Tsis teb los tau: Ntxiv Wired Nyees khawm rau Neeg Hlau kom pom meej cov lus

Cov kauj ruam no yog nyob ntawm yeem tab sis pom zoo kom tshem tawm cov lus ntawm lub vijtsam.

Kuv tau ntxiv ob lub laub khawm rau kuv tus neeg hlau, tab sis hauv txoj haujlwm no kuv tsuas yog siv GPIO17.

Tsab ntawv check_button.py uas khiav ntawm kev xaiv lub npav GPIO17 txhua ob peb lub milliseconds thiab yog tias kev nyuaj siab xa HTTP POST mus rau tus qauv tshuaj ntsuam kab ntawv kom pom lub vijtsam.

Kauj Ruam 9: Rub Nws Txhua Zaug Ua Ke thiab Xa Cov Zis Tawm rau Pi

Muaj 4 tsab ntawv uas ua haujlwm ua ke rau txoj haujlwm no:

/home/pi/Pimoroni/scrollphathd/examples/web-api.py/home/pi/slackPiBot/check_button.py/home/pi/slackPiBot/forever.py/home/pi/slackPiBot/slackPiBot.py

Tsab ntawv web-api tau muab los ntawm Pimoroni thiab yog daim ntawv thov web yooj yim los tswj lub vijtsam nrog POST cov lus txib.

Lub check_button sej tsab ntawv pov npav GPIO pins thiab thaum lub pob nyuaj siab xa HTTP POST mus rau lub vev xaib -api.py tsab ntawv.

Tsab ntawv forever.py ncaws tawm tsab ntawv slackPiBot.py kom ntseeg tau tias yog tias muaj qhov tsis raug lossis tsis raug cuam tshuam los ntawm slack, tsab ntawv tau rov pib dua kom tsis txhob muaj cov lus ploj.

SlackPiBot.py tsab ntawv txuas rau slack thiab saib xyuas cov channel rau cov lus pib nrog "bot" lossis tshaj tawm los ntawm IFTT. Yog tias muaj kev sib tw, nws yuav xa HTTP POST mus rau web-api.py tsab ntawv thiab tso tawm ntawm lub vijtsam.

Kauj Ruam 10: Yeem: IFTT Kev Sib Koom

Yeem: IFTT Kev Sib Koom
Yeem: IFTT Kev Sib Koom
Yeem: IFTT Kev Sib Koom
Yeem: IFTT Kev Sib Koom
Yeem: IFTT Kev Sib Koom
Yeem: IFTT Kev Sib Koom

Txoj haujlwm no tau tsim los ceeb toom rau kuv cov menyuam ntawm cov vis dis aus tshaj tawm los ntawm cov neeg lawv ua raws hauv youtube, vim tias lawv tseem hluas heev kom muaj lawv tus kheej iPhone lossis iPads. Kuv ua tiav qhov no los ntawm kev tsim IFTT cov zaub mov xa tuaj ceeb toom rau slack tswj channel ib zaug cov vis dis aus tau tshaj tawm.

Cov ntawv qhia wiki ua qhov nyuaj rau pom hauv ib kauj ruam, tab sis cov duab saum toj no qhia qhov kawg.

Pom zoo: