commit f0cdc80ccf468761bcf2daf95dee439ffadea310 Author: Tuan Date: Mon Feb 1 20:23:00 2021 +0000 ilk commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a4f9bb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Bot harici dosyalari gormezden gel +cacheclear.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef77df5 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# metu.life # + +Bu depo, [metu.life](https://metu.life) botlarının kaynak kodlarını barındırır. + ++ [kafeterya\_bot@metu.life](https://metu.life/@kafeterya_bot) + - kafeterya.sh menüyü kafe.txt dosyasına yazar + - kafeterya.py içeriği platformda paylaşır ++ [akademik_bot@metu.life](https://metu.life/@akademik_bot) + - cal.sh takvim kesitini cal.txt dosyasına yazar + - cal.py içeriği platformda paylaşır diff --git a/cal.py b/cal.py new file mode 100644 index 0000000..d0814e9 --- /dev/null +++ b/cal.py @@ -0,0 +1,11 @@ +from mastodon import Mastodon + +mastodon = Mastodon( + access_token = 'top-secret', + api_base_url = 'https://metu.life/' +) + +file = open("cal.txt", "r") +calendar = file.read() +if len(calendar) > 15: + mastodon.status_post(calendar) diff --git a/cal.sh b/cal.sh new file mode 100755 index 0000000..3cb9436 --- /dev/null +++ b/cal.sh @@ -0,0 +1,7 @@ +#!/bin/bash +if [[ $(date +%u) -gt 5 ]]; then + range=7 +else + range=3 +fi +calcurse -Q --days $range | sed 's/*/+/g' > cal.txt && python3 cal.py diff --git a/cal.txt b/cal.txt new file mode 100644 index 0000000..e69de29 diff --git a/kafe b/kafe new file mode 100644 index 0000000..e69de29 diff --git a/kafeterya.py b/kafeterya.py new file mode 100644 index 0000000..38d1c4e --- /dev/null +++ b/kafeterya.py @@ -0,0 +1,11 @@ +from mastodon import Mastodon + +mastodon = Mastodon( + access_token = 'top-secret', + api_base_url = 'https://metu.life/' +) + +file = open("kafe.txt", "r") +yemek = file.read() +if len(yemek) > 8: + mastodon.status_post(yemek) diff --git a/kafeterya.sh b/kafeterya.sh new file mode 100755 index 0000000..db62987 --- /dev/null +++ b/kafeterya.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +url='https://kafeterya.metu.edu.tr/' +outfile='kafe.txt' + +echo "Günün yemeği:" > ${outfile} +curl -s ${url} | /snap/bin/xmllint --html --xpath '//div[@class="yemek"]/p' --format - | sed -e 's/<[^>]*>//g' -e '/*/d' -e 's/^/+ /g' -e 's/./\L&/g4' >> ${outfile} + +python3 kafeterya.py