Open ghost opened 4 months ago
import logging
import os
from pathlib import Path
import signal
from neonize.client import NewClient
from neonize.events import (
PairStatusEv,
event,
)
from neonize.utils import log
from neonize.utils.jid import build_jid
import secrets
import tempfile
import time
def interrupted(*_):
event.set()
log.setLevel(logging.DEBUG)
signal.signal(signal.SIGINT, interrupted)
db_name = Path()._from_parts([tempfile.gettempdir(), secrets.token_hex() + ".sqlite3"])
client = NewClient(db_name.__str__())
@client.event(PairStatusEv)
def PairStatusMessage(client: NewClient, message: PairStatusEv):
log.info(f"logged as {message.ID.User}")
for i in range(50, 100, 2):
client.send_message(build_jid("myPhoneNumber"), f"{i}")
time.sleep(5)
event.set()
client.logout()
client.connect()
os.remove(db_name)
After I successfully logged in, the program is blocked until I press Ctrl-c. here is the minimal code to reproduce it
Is there a way to avoid pressing Ctrl-c?
Another question: Is it possible to avoid creating the sqlite3 db?
Another question: where can we fund you? ;)