So the following code does work as i want, but i don't think this is the way it should be done.
I edited the event to this:
@events.register(
events.NewMessage(
incoming=True, # I removed the (from_users) argument
)
)
async def message_received(event):
"""This function will be called when a new message comes from the defined channels
Args:
event (_type_): Event containing information about the message
"""
incoming_message_text = event.message.message
# We use try block here as we are going to get (channel_id) for all incoming messages
# because we are getting all incoming chats, this also includes users
# which don't have (channel_id) so an exception occurs
try:
sender_id = (await event.get_input_sender()).channel_id
if sender_id == desired_channel_id:
print(f"Message from {sender_id}:\n{incoming_message_text}")
# If Sender is NOT a channel, this exception occurs, we ignore it
except AttributeError as e:
print(e)
This is a hacky/inefficient way of getting the job done and i accept it, yet i don't know the correct way.
Until someone responds with a better answer, others facing this issue can use this hack at least.