added bot setup
This commit is contained in:
parent
9b34195fdf
commit
726417c2f7
|
@ -21,6 +21,7 @@ packages = find:
|
||||||
python_requires = >=3.8
|
python_requires = >=3.8
|
||||||
install_requires =
|
install_requires =
|
||||||
click
|
click
|
||||||
|
deltachat
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = src
|
where = src
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
import click
|
import click
|
||||||
import remember_remember_bot.loop
|
import remember_remember_bot.loop
|
||||||
|
import remember_remember_bot.commands
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--email", type=str, default=None, help="the email account for the bot")
|
@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(
|
||||||
@click.option("--db", type=str, default="remember.db/db.sqlite", help="path to the bot's database")
|
"--password", type=str, default=None, help="the password of the email account"
|
||||||
@click.option("--debug", is_flag=True, default=False, help="show low level delta chat ffi events")
|
)
|
||||||
|
@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
|
@click.pass_context
|
||||||
def run(ctx, email: str, password: str, db: str, debug: bool):
|
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.
|
"""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 db: the path to the database
|
||||||
:param debug: whether to show low-level deltachat FFI events
|
:param debug: whether to show low-level deltachat FFI events
|
||||||
"""
|
"""
|
||||||
# setup
|
ac = remember_remember_bot.commands.setup(email, password, db, debug)
|
||||||
remember_remember_bot.loop.loop()
|
remember_remember_bot.loop.loop(ac)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
run(auto_envvar_prefix='REMEMBER')
|
run(auto_envvar_prefix="REMEMBER")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
7
src/remember_remember_bot/commands.py
Normal file
7
src/remember_remember_bot/commands.py
Normal 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
|
|
@ -1,8 +1,10 @@
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import deltachat
|
||||||
|
|
||||||
def loop():
|
|
||||||
|
def loop(ac: deltachat.Account):
|
||||||
current_day = 0
|
current_day = 0
|
||||||
while True:
|
while True:
|
||||||
if check_new_day(current_day):
|
if check_new_day(current_day):
|
||||||
|
@ -13,8 +15,9 @@ def loop():
|
||||||
|
|
||||||
|
|
||||||
def check_new_day(current_day):
|
def check_new_day(current_day):
|
||||||
if current_day == datetime.datetime.now().day:
|
if current_day != datetime.datetime.now().day:
|
||||||
return True
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def update_day():
|
def update_day():
|
||||||
|
|
Loading…
Reference in a new issue