When you use fbchat i don't think is running a loop(maybe in bots mode) and just do API call to the chat.
Then you need to make a running loop.
Use
Here is a working example.
Then you need to make a running loop.
Use
BackgroundScheduler
so it don't block fbchat calls and your function call is wrong.Here is a working example.
from apscheduler.schedulers.background import BackgroundScheduler from datetime import datetime import time, random def mesaj_fb(path,my_id): print(f'Tick! The time is: {datetime.now()} {random.choice(path), my_id}') if __name__ == '__main__': scheduler = BackgroundScheduler() scheduler.add_job(mesaj_fb, 'interval', args=[('image_1.png','image_2.png','image_3.png'), 10], seconds=5) scheduler.start() print('Press Ctrl+C to exit') try: while True: time.sleep(2) except (KeyboardInterrupt, SystemExit): scheduler.shutdown()
Output:C:\code
λ python tick.py
Press Ctrl+C to exit
Tick! The time is: 2020-01-04 21:35:11.823093 ('image_3.png', 10)
Tick! The time is: 2020-01-04 21:35:16.823867 ('image_3.png', 10)
Tick! The time is: 2020-01-04 21:35:21.823910 ('image_1.png', 10)
Tick! The time is: 2020-01-04 21:35:26.824082 ('image_2.png', 10)
Tick! The time is: 2020-01-04 21:35:31.824071 ('image_3.png', 10)