嗨,我想在特定时间从机器人发送消息(没有我的消息),例如每个星期六早上 8:00。这是我的代码:
import telebot
import config
from datetime import time, date, datetime
bot = telebot.TeleBot(config.bot_token)
chat_id=config.my_id
@bot.message_handler(commands=['start', 'help'])
def print_hi(message):
bot.send_message(message.chat.id, 'Hi!')
@bot.message_handler(func=lambda message: False) #cause there is no message
def saturday_message():
now = datetime.now()
if (now.date().weekday() == 5) and (now.time() == time(8,0)):
bot.send_message(chat_id, 'Wake up!')
bot.polling(none_stop=True)
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用。试过
urlopen("https://api.telegram.org/bot" +bot_id+ "/sendMessage?chat_id=" +chat_id+ "&text="+msg)
Run Code Online (Sandbox Code Playgroud)
但又没有结果。不知道该怎么办,请帮忙指点迷津。
这段代码出现错误:
import PIL.ImageOps
inverted_image = PIL.ImageOps.invert(image)
Run Code Online (Sandbox Code Playgroud)
回溯是
Traceback (most recent call last):
File "filter.py", line 32, in <module>
inverted_image = PIL.ImageOps.invert(denoise)
File "/usr/lib/python3/dist-packages/PIL/ImageOps.py", line 367, in invert
return _lut(image, lut)
File "/usr/lib/python3/dist-packages/PIL/ImageOps.py", line 48, in _lut
if image.mode == "P":
AttributeError: 'numpy.ndarray' object has no attribute 'mode'
Run Code Online (Sandbox Code Playgroud)
我该如何解决?