@luckydonaldsbots · Post #256 · 08.07.2020 г., 23:11
New feature I forgot to write about, @BanWarnBot will now also notice you if a user which already has gotten warns joins back into your group. #update#BanWarnBot.
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #381 · 23 окт.
Установить свойства виджета в PySide можно не только через соответствующие методы и конструктор класса. Можно их изменять с помощью метода setProperty по имени. btn = QPushButton("Click Me") btn.setProperty("flat", True) Это аналогично вызову btn.setFlat(True) Если указать несуществующее свойство, то оно просто создается btn.setProperty("btnType", "super") Получить его значение можно методом .property(name) btn_type = btn.property("btnType") Когда это может быть полезно? ▫️Можно просто хранить какие то данные в виджете и потом их доставать обратно widget = QWidget() widget.setProperty('my_data', 123) print(widget.property('my_data')) ▫️ Назначая эти свойства разным виджетам можно потом отличить виджеты во время итераци по ним. Например, найти все кнопки со свойством my_data="superbtn". Но ведь вместо кастомного свойства можно использовать objectName, будет тот же результат. Да, но y ObjectName есть ограничение - только строки. ▫️ Если нам потребуется не просто поиск а, например, сортировка по числу, то свойства позволяют нам это сделать. Поддерживается любой тип данных widget.setProperty('my_data', {'Key': 'value'}) widget.setProperty('order', 1) all_widgets.sort(key=w: w.property('order')) Но ведь Python позволяет всё вышеперечисленное сделать простым созданием атрибута у объекта widget.order = 1 widget.my_data = 123 Да, но я думаю что не надо объяснять почему не стоит так делать. К тому же, если у виджета нет свойства то метод .property(name) вернет None, а отсутствующий атрибут выбросит исключение. ▫️ Действительно полезное применение кастомным свойствам - контроль стилей. Здесь атрибутами не обойтись, нужны именно свойства. Дело в том, что в селекторах стилей можно указывать конкретные свойства виджетов на которые следует назначать стиль. Просто запустите этот код from PySide2.QtWidgets import * if __name__ == "__main__": app = QApplication([]) widget = QWidget(minimumWidth=300) layout = QVBoxLayout(widget) btn1 = QPushButton("Action 1") btn2 = QPushButton("Action 2") btn3 = QPushButton("Action 3", flat=True) layout.addWidget(btn1) layout.addWidget(btn2) layout.addWidget(btn3) # добавим кастомное свойство одной кнопке btn1.setProperty("btnType", "super") # добавляем стили widget.setStyleSheet( """ QPushButton[btnType="super"] { background-color: yellow; color: red; } QPushButton[flat="true"] { color: yellow; } """ ) widget.show() app.exec_() С помощью селектора мы избирательно назначили стили на конкретные кнопки. Как получить список всех кастомный свойств? Функция получения списка кастомных свойств отличается от получения дефолтных. def print_widget_dyn_properties(widget): for prop_name in widget.dynamicPropertyNames(): property_name = prop_name.data().decode() property_value = widget.property(property_name) print(f"{property_name}: {property_value}") #tricks#qt
Пребарај: #banwarnbot
@luckydonaldsbots · Post #256 · 08.07.2020 г., 23:11
New feature I forgot to write about, @BanWarnBot will now also notice you if a user which already has gotten warns joins back into your group. #update#BanWarnBot.
Hashtags
@luckydonaldsbots · Post #138 · 05.07.2018 г., 20:26
Updated @BanWarnBot to no longer kick people when revoking warns. The technical details: Telegrams unbanChatMember API method is actually is a kick+unban, which isn't documented anywhere. It will now check first if the user is not member of the group, being kicked (=banned) or the user left the group (or "was forcefully left by admins"). Else it will not attempting to unban the use as that would kick, too. #update#BanWarnBot
Hashtags
@luckydonaldsbots · Post #133 · 04.07.2018 г., 11:17
@BanWarnBot now allows to revoke warnings by clicking on a button right under it. #update#BanWarnBot
Hashtags
@luckydonaldsbots · Post #300 · 12.11.2025 г., 07:19
Experienced another way how the disk can run full, deleted 100 GB of ancient pending RabbitMQ tasks and set a message TTL as well as a maximum queue length. With that the bots are back online. #JoinCaptchaBot #BanWarnBot
Hashtags
@luckydonaldsbots · Post #299 · 05.06.2024 г., 22:18
Some bots were down again, which was caused by the disk running full. Deleted 460 GB of log files and restored the services. Bots will process all pending updates normally. #JoinCaptchaBot#BanWarnBot
Hashtags
@luckydonaldsbots · Post #252 · 04.07.2020 г., 15:57
@BanWarnBot is nowsuccessfully back up and running the newest version: Here's a list of what's new: New /kick and /ban commands: Just like the /warn one, but immediately removes the user from the chat, either once or permanently. You can specify a reason for why you kicked/banned someone after the command. Those kicks count into the normal warn count, because they are kinda like special warns. Those 3 commands, /warn, /kick and /ban now also allow the first thing after the command to be the id of a user, in the format of #1234, or a user mention. This can come in handy if you don't have a message to reply to. Overhaul of the warning lists: Now the list of /listwarnings and /listallwarnings will link you to the message warn message, if you press the date stamp. Also support for distinguishing automatic kicks/bans and manual kicks/bans has been added. #update#BanWarnBot#resolved
Hashtags
@luckydonaldsbots · Post #251 · 04.07.2020 г., 14:51
Maintenance: Moving @BanWarnBot to the new server. Okey going through the same procedure for @BanWarnBot now, hopefully without the database breaking this time. Turning the bot off for moving the database, so any /warns send in the meantime shouldn't get lost. As soon as it's on the new server it should pick up those, and carry out the needed actions. I'll take @BanWarnBot down in 10 minutes. Other bots should not be affected. #maintenance#downtime#BanWarnBot
Hashtags
@luckydonaldsbots · Post #295 · 15.12.2021 г., 23:01
It was brought to attention that with some bots admin commands were no longer working. That was happining for the bots migrated yesterday, because of the new bot API version. This is #fixed now. Thanks for letting me know, A. A.! #BanWarnBot#RulesRulesBot#JoinCaptchaBot
@luckydonaldsbots · Post #232 · 24.03.2020 г., 10:45
I will soon migrage some services onto a new server. Therefore those services will be unavailable for the next two hours: @JoinCaptchaBot@BanWarnBot@RulesRulesBot and @ForwardWhitelistBot. #downtime #JoinCaptchaBot#BanWarnBot#RulesRulesBot#ForwardWhitelistBot
@luckydonaldsbots · Post #230 · 23.03.2020 г., 11:24
I will definitely work hard to keep the most important group management services stable, including: @JoinCaptchaBot, @RulesRulesBot, @BanWarnBot, and @HeyAdminBot. And for now also the less important @NoServiceBot. #PermalinkBot#NoServiceBot#RulesRulesBot, #BanWarnBot#HeyAdminBot #ongoing#issue