0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

残人生のためのプログラミング 第-1回

Last updated at Posted at 2021-06-02

LINENotifyでタスクの通知

前回(第21915回)のプログラムにTaskクラスを追加しました.
Routineクラスを少し変えたものですね.

TaskNotify.py
import requests
import datetime

class Task:
	def __init__(self, name, date):
		self.name = name
		self.date = datetime.date(year=2021, month=date[0], day=date[1])
		self.sentence = "{}まで残り{}日\n".format(name, abs(self.date-today).days)
		tasks.append(self)


def create_send(tasks):
	sentences = "\n"
	for s in tasks:
		if s.date >= today:
			sentences += s.sentence

	return sentences


if __name__ == '__main__':
	today = datetime.date.today()

	tasks = []
	write_qiita = Task("Qiitaに記事を投稿する", (6, 2))
	submit_homework = Task("課題を提出する", (6, 3))
	toeic = Task("Toeicを受ける", (6, 20))

	send_dict = {'message': create_send(tasks)}

	TOKEN = 'hoge'
	url = 'https://notify-api.line.me/api/notify'
	TOKEN_dict = {'Authorization': 'Bearer ' + TOKEN}

	requests.post(url, headers=TOKEN_dict, data=send_dict)

TaskNotify.png

明日,第21913回は

タスクの管理をcsvで行えるように実装していきます.
pandasとかで出来るらしいすね.触ったことないや...

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?