@@ -182,6 +182,44 @@ func removeZipFiles(zipPaths []string) {
182182}
183183
184184func GetPack (b * gotgbot.Bot , ctx * ext.Context , packName string , langCode string , msgId int64 ) error {
185+ currentUsage , err := database .Init ("usage" , ctx .EffectiveUser .Id , nil )
186+ if err != nil {
187+ return err
188+ }
189+ if ! currentUsage ["exists" ].(bool ) {
190+ database .Init ("create" , ctx .EffectiveUser .Id , nil )
191+ currentUsage ["usage" ] = float64 (0 )
192+ currentUsage ["last_cycle_starts_at" ] = float64 (time .Now ().Unix ())
193+ }
194+ subErr := utils .SubscribeCheck (b , ctx , ctx .EffectiveUser .Id , langCode )
195+ if subErr != nil {
196+ return nil // 用户未订阅,已在 SubscribeCheck 中发送提示消息,直接返回不继续处理
197+ }
198+ limit := config .AppConfig .General .Limit
199+ userGroup , err := database .Init ("user_group" , ctx .EffectiveUser .Id , nil )
200+ if err != nil {
201+ return err
202+ }
203+ if userGroup ["user_group" ] == "sponsor" && config .AppConfig .Donation .BonusEnabled {
204+ limit = int (float64 (config .AppConfig .General .Limit ) * C .DonationBonusMultiplier ) // 赞助用户的使用限制增加奖励倍数
205+ }
206+ if int (currentUsage ["usage" ].(float64 )) >= limit && (int (currentUsage ["last_cycle_starts_at" ].(float64 ))+ 24 * 3600 ) >= int (time .Now ().Unix ()) {
207+ displayText := fmt .Sprintf (I .GetLocalisedString ("general.out_of_quota" , langCode ), limit )
208+ if userGroup ["user_group" ] != "sponsor" && config .AppConfig .Donation .Enabled && config .AppConfig .Donation .BonusEnabled {
209+ displayText += I .GetLocalisedString ("general.donate_reminder_outofquota" , langCode )
210+ }
211+ if userGroup ["user_group" ] == "sponsor" && config .AppConfig .Donation .BonusEnabled {
212+ displayText += I .GetLocalisedString ("general.donated" , langCode )
213+ }
214+ _ , _ , _ = b .EditMessageText (displayText , & gotgbot.EditMessageTextOpts {
215+ ChatId : ctx .EffectiveChat .Id ,
216+ MessageId : msgId ,
217+ })
218+ err := C .ErrOutofQuota
219+ return err
220+ } else if (int (currentUsage ["last_cycle_starts_at" ].(float64 )) + 24 * 3600 ) < int (time .Now ().Unix ()) {
221+ database .Init ("reset_usage" , ctx .EffectiveUser .Id , nil )
222+ }
185223 zipPaths , err := stickers .GetStickerPack (b , packName , ctx .EffectiveUser .Id , msgId , ctx )
186224 var limitErr * stickers.StickerPackLimitError
187225 if errors .As (err , & limitErr ) {
0 commit comments