added bot setup

This commit is contained in:
missytake 2023-09-01 15:00:55 +02:00
parent 9b34195fdf
commit 726417c2f7
4 changed files with 26 additions and 8 deletions

View file

@ -21,6 +21,7 @@ packages = find:
python_requires = >=3.8
install_requires =
click
deltachat
[options.packages.find]
where = src

View file

@ -1,12 +1,19 @@
import click
import remember_remember_bot.loop
import remember_remember_bot.commands
@click.command()
@click.option("--email", type=str, default=None, help="the email account for the bot")
@click.option("--password", type=str, default=None, help="the password of the email account")
@click.option("--db", type=str, default="remember.db/db.sqlite", help="path to the bot's database")
@click.option("--debug", is_flag=True, default=False, help="show low level delta chat ffi events")
@click.option(
"--password", type=str, default=None, help="the password of the email account"
)
@click.option(
"--db", type=str, default="remember.db/db.sqlite", help="path to the bot's database"
)
@click.option(
"--debug", is_flag=True, default=False, help="show low level delta chat ffi events"
)
@click.pass_context
def run(ctx, email: str, password: str, db: str, debug: bool):
"""Remember, remember, the 5th of November... a Delta Chat bot to send daily reminders.
@ -17,12 +24,12 @@ def run(ctx, email: str, password: str, db: str, debug: bool):
:param db: the path to the database
:param debug: whether to show low-level deltachat FFI events
"""
# setup
remember_remember_bot.loop.loop()
ac = remember_remember_bot.commands.setup(email, password, db, debug)
remember_remember_bot.loop.loop(ac)
def main():
run(auto_envvar_prefix='REMEMBER')
run(auto_envvar_prefix="REMEMBER")
if __name__ == "__main__":

View file

@ -0,0 +1,7 @@
import deltachat
def setup(email: str, password: str, db: str, debug: bool) -> deltachat.Account:
ac = deltachat.account.Account(db_path=db)
ac.run_account(email, password, show_ffi=debug)
return ac

View file

@ -1,8 +1,10 @@
import time
import datetime
import deltachat
def loop():
def loop(ac: deltachat.Account):
current_day = 0
while True:
if check_new_day(current_day):
@ -13,8 +15,9 @@ def loop():
def check_new_day(current_day):
if current_day == datetime.datetime.now().day:
if current_day != datetime.datetime.now().day:
return True
return False
def update_day():