The Messenger of Allah ﷺ said, "Whoever comes to the mosque for something, that is his share of it."
حدثنا هشام بن عمار حدثنا صدقة بن خالد حدثنا عثمان بن أبي العاتكة الأزدي عن عمير بن هانئ العنسي
قال رسول الله ﷺ من أتى المسجد لشيء فهو حظه
[Its chain of transmission is daif] Bayhaqi narrated it 2/447, 3/66 from the hadith of Abu Dawud, and its chain of transmission is daif. The hadith has supporting narrations in meaning, see Tanqih Ruwat 1/131, no. 730.Uthman Azdi is considered daif by the majority, though some regard him as such only with regard to other than Ali bin Yazid Alhani, and their view is the weaker one.