diff --git a/src/commands/__pycache__/helpcmd.cpython-39.pyc b/src/commands/__pycache__/helpcmd.cpython-39.pyc index 6231ee4..6d09a47 100644 Binary files a/src/commands/__pycache__/helpcmd.cpython-39.pyc and b/src/commands/__pycache__/helpcmd.cpython-39.pyc differ diff --git a/src/commands/__pycache__/meet2.cpython-39.pyc b/src/commands/__pycache__/meet2.cpython-39.pyc new file mode 100644 index 0000000..b627537 Binary files /dev/null and b/src/commands/__pycache__/meet2.cpython-39.pyc differ diff --git a/src/commands/__pycache__/meetcmd.cpython-39.pyc b/src/commands/__pycache__/meetcmd.cpython-39.pyc index 3073bdd..ca7ffb7 100644 Binary files a/src/commands/__pycache__/meetcmd.cpython-39.pyc and b/src/commands/__pycache__/meetcmd.cpython-39.pyc differ diff --git a/src/commands/__pycache__/member.cpython-39.pyc b/src/commands/__pycache__/member.cpython-39.pyc index 6333afd..abdca29 100644 Binary files a/src/commands/__pycache__/member.cpython-39.pyc and b/src/commands/__pycache__/member.cpython-39.pyc differ diff --git a/src/commands/__pycache__/tasks.cpython-39.pyc b/src/commands/__pycache__/tasks.cpython-39.pyc index 69e4f44..720cd65 100644 Binary files a/src/commands/__pycache__/tasks.cpython-39.pyc and b/src/commands/__pycache__/tasks.cpython-39.pyc differ diff --git a/src/commands/meet.py b/src/commands/meet2.py similarity index 58% rename from src/commands/meet.py rename to src/commands/meet2.py index 3d76cb9..4db0df5 100644 --- a/src/commands/meet.py +++ b/src/commands/meet2.py @@ -1,4 +1,3 @@ -# from discord.client import Client from dbmongo import db import asyncio from datetime import datetime @@ -8,34 +7,46 @@ dbs = db.connection() -# mydb = dbs.DiscordBot - client = discord.Client() +#&schedule Discord Bot @Pradipta Nandi 1d 2h 3m + async def scheduleMeet(message): - index = message.content.index(' ') - index = index + 1 - main_message = message.content[index:] - sch = main_message.split(' ') - arg1 = sch[0] - arg2 = sch[1] - arg3 = sch[2] - format = '%Y-%m-%d %H:%M:%S' - sch_time = datetime.strptime(arg3, format) - sch_stamp = datetime.timestamp(sch_time) - print(sch_stamp) + keywords = ['m', 'h', 'd'] + command = message.content.split() + title = command[1] + keyword = command[-3:] + dbs = db.connection() + + + present_timestamp = datetime.now().timestamp() + deadline_duration = present_timestamp + for eachTime in keyword: + duration = int(eachTime[:-1]) + seconds = { + "m": duration * 60, + "h": duration * 60 * 60, + "d": duration * 24 * 60 * 60 + } + + k = eachTime[-1] + + deadline_duration = deadline_duration + seconds[k] + + + schedule_date = datetime.fromtimestamp(deadline_duration) countmeet = dbs.Count_Meet.find() for item in countmeet: counter = item["count"] - dbs.Data.insert_one({"ids": str(counter), "Topic": str(arg1), "DateTime": sch_time, "Description": str(arg2), "TimeStamp": sch_stamp, "Reminder": 2}) + dbs.Data.insert_one({"ids": str(counter), "Topic": title, + "DateTime": schedule_date, "TimeStamp": deadline_duration, "Reminder": 2}) print("Scheduled successfully!") await message.channel.send(f"Scheduled successfully! ID: {counter}") dbs.Count_Meet.update_one({"ids": "4"}, {"$inc": {"count": 1}}) embed = discord.Embed( title="Meeting Scheduled💻", description="Topic: " + - str(arg1) + "\n" + str(arg2), - + title, colour=discord.Colour.blue() ) name = message.author @@ -43,8 +54,8 @@ async def scheduleMeet(message): embed.set_footer(text="Please attend the meeting") emoji1 = '✅' emoji2 = '❎' - mentions = sch[-1] - men = mentions.split() + mentions = command[2:-3] + men = mentions for user in men: if str(user) == '@here': msg = await message.channel.send(embed=embed) @@ -59,6 +70,5 @@ async def scheduleMeet(message): ment.append(user[3:-1]) msgid = message.channel.id dbs.Data.update_one({"ids": str(counter)}, {"$set": {"members": ment}}) - dbs.Data.update_one({"ids": str(counter)}, {"$set": {"MessageChannel": msgid}}) - - + dbs.Data.update_one({"ids": str(counter)}, { + "$set": {"MessageChannel": msgid}}) diff --git a/src/dbmongo/__pycache__/db.cpython-39.pyc b/src/dbmongo/__pycache__/db.cpython-39.pyc index 63ca89f..e6257a4 100644 Binary files a/src/dbmongo/__pycache__/db.cpython-39.pyc and b/src/dbmongo/__pycache__/db.cpython-39.pyc differ diff --git a/src/main.py b/src/main.py index fc24f4c..2db7c2c 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,6 @@ import discord import datetime -from commands import meet +from commands import meet2 from commands import tasks from commands import helpcmd from commands import meetcmd @@ -89,8 +89,7 @@ async def on_message(message): if message.author.bot: return elif message.content.startswith('&schedule'): - print("meet") - await meet.scheduleMeet(message) + await meet2.scheduleMeet(message) elif message.content.startswith('&Task'): await tasks.Tasks(message) elif message.content.startswith('&meet'): @@ -101,4 +100,4 @@ async def on_message(message): await helpcmd.help(message) -client.run(os.environ['DISCORD_TOKEN']) +client.run('ODQ5OTA3OTQ5MjYxNDIyNjAy.YLiAdQ.cfszk0KagH1UgvdUEc_OCAX_188') diff --git a/src/remainder/__pycache__/remainder.cpython-39.pyc b/src/remainder/__pycache__/remainder.cpython-39.pyc index 390f9a8..3c2d5df 100644 Binary files a/src/remainder/__pycache__/remainder.cpython-39.pyc and b/src/remainder/__pycache__/remainder.cpython-39.pyc differ diff --git a/src/remainder/remainder.py b/src/remainder/remainder.py index cb2c010..c7a9271 100644 --- a/src/remainder/remainder.py +++ b/src/remainder/remainder.py @@ -12,7 +12,6 @@ async def remainder(Client): try: data = Task_details.discord.find() for eachTask in data: - print(1) presentTime=datetime.datetime.now().timestamp() if presentTime>eachTask['deadline']: await postReminder.send_after_reminder(Client, eachTask) @@ -21,12 +20,8 @@ async def remainder(Client): data = Task_details.Data.find() for eachMeet in data: - id = eachMeet["ids"] - tz_NY = pytz.timezone('Asia/Kolkata') - datetime_NY = datetime.datetime.now(tz_NY) - presentTime = datetime.datetime.timestamp(datetime_NY) - print(presentTime, eachMeet["TimeStamp"]) + presentTime = datetime.datetime.now().timestamp() if presentTime > eachMeet["TimeStamp"]-1800 and eachMeet["Reminder"] == 2: Task_details.Data.update_one({"ids" : str(id)},{ "$inc" : {"Reminder": -1} }) await premeetReminder.send_before_reminder(Client, eachMeet) diff --git a/src/utils/__pycache__/postReminder.cpython-39.pyc b/src/utils/__pycache__/postReminder.cpython-39.pyc index 59c88cf..9d582a4 100644 Binary files a/src/utils/__pycache__/postReminder.cpython-39.pyc and b/src/utils/__pycache__/postReminder.cpython-39.pyc differ diff --git a/src/utils/__pycache__/postmeetReminder.cpython-39.pyc b/src/utils/__pycache__/postmeetReminder.cpython-39.pyc index cc8479c..d3379be 100644 Binary files a/src/utils/__pycache__/postmeetReminder.cpython-39.pyc and b/src/utils/__pycache__/postmeetReminder.cpython-39.pyc differ diff --git a/src/utils/__pycache__/preReminder.cpython-39.pyc b/src/utils/__pycache__/preReminder.cpython-39.pyc index 7dee429..259afcf 100644 Binary files a/src/utils/__pycache__/preReminder.cpython-39.pyc and b/src/utils/__pycache__/preReminder.cpython-39.pyc differ diff --git a/src/utils/__pycache__/premeetReminder.cpython-39.pyc b/src/utils/__pycache__/premeetReminder.cpython-39.pyc index fdc157e..4d2512a 100644 Binary files a/src/utils/__pycache__/premeetReminder.cpython-39.pyc and b/src/utils/__pycache__/premeetReminder.cpython-39.pyc differ diff --git a/src/utils/postmeetReminder.py b/src/utils/postmeetReminder.py index a12d878..02496e1 100644 --- a/src/utils/postmeetReminder.py +++ b/src/utils/postmeetReminder.py @@ -1,6 +1,5 @@ import discord async def send_after_reminder(Client, MeetSchema): - print(4) top = MeetSchema["Topic"] for id in MeetSchema['members']: if str(id) == 'r': diff --git a/src/utils/premeetReminder.py b/src/utils/premeetReminder.py index bbd1c73..ea0a521 100644 --- a/src/utils/premeetReminder.py +++ b/src/utils/premeetReminder.py @@ -1,7 +1,6 @@ import discord async def send_before_reminder(Client, MeetSchema): - print(5) top = MeetSchema["Topic"] for id in MeetSchema['members']: if str(id) == 'r':