bombsquad-plugin-manager/plugins/utilities/updown.py

92 lines
2.4 KiB
Python
Raw Normal View History

from bauiv1lib import party
from babase import (
SpecialChar as sc,
charstr as cs,
Plugin,
Call
)
from bauiv1 import (
containerwidget as cw,
buttonwidget as bw,
textwidget as tw,
getsound as gs
)
from bascenev1 import (
get_chat_messages as gcm,
screenmessage as push
)
2024-05-16 18:44:57 +03:00
2025-04-07 00:16:33 +00:00
class VeryPW(party.PartyWindow):
2024-05-16 18:44:57 +03:00
def __init__(s, *args, **kwargs):
super().__init__(*args, **kwargs)
2024-05-16 16:07:23 +00:00
s._n = 0
s._o = ""
s._f = True
2024-05-16 18:44:57 +03:00
for i in range(2):
bw(
2024-05-16 18:44:57 +03:00
parent=s._root_widget,
size=(30, 30),
2025-04-07 00:16:33 +00:00
label=cs(getattr(sc, f"{['UP', 'DOWN'][i]}_ARROW")),
2024-05-16 18:44:57 +03:00
button_type='square',
enable_sound=False,
2025-04-07 00:16:33 +00:00
position=(-15, 70-(i*40)),
on_activate_call=[s._p, s._d][i]
2024-05-16 18:44:57 +03:00
)
2024-05-16 16:07:23 +00:00
def _c(s, t=""): tw(edit=s._text_field, text=t)
2024-05-16 18:44:57 +03:00
def _d(s): s._p(1)
2024-05-16 16:07:23 +00:00
2024-05-16 18:44:57 +03:00
def _p(s, i=0):
2025-05-22 15:45:53 +01:00
s._w1 = gcm()
2024-05-16 18:44:57 +03:00
if s._f:
s._o = tw(query=s._text_field)
2024-05-16 16:07:23 +00:00
s._f = False
2025-05-22 15:45:53 +01:00
s._n = 0 if i else len(s._w1)
s._n = (s._n + (1 if i else -1)) % len(s._w1)
2024-05-16 16:07:23 +00:00
try:
s._c((s._w1+[s._o])[s._n].split(": ", 1)[1])
2024-05-16 18:44:57 +03:00
except IndexError:
2024-05-16 16:07:23 +00:00
if not s._w1:
push("Empty chat")
gs('block').play()
2024-05-16 16:07:23 +00:00
s._n = 0
return
s._n = -1
s._c(s._o)
gs('deek').play()
2024-05-16 18:44:57 +03:00
[z.delete() for z in s._columnwidget.get_children()]
2024-05-16 18:44:57 +03:00
for z in range(len(s._w1)):
txt = tw(
parent=s._columnwidget,
text=s._w1[z],
h_align='left',
v_align='center',
size=(900, 13),
scale=0.55,
2025-04-07 00:16:33 +00:00
color=(1, 1, 1) if z != (s._n if s._n > -
1 else s._n + len(s._w1) + 1) else (0, 0.7, 0),
position=(-0.6, 0),
selectable=True,
autoselect=True,
click_activate=True,
maxwidth=s._scroll_width * 0.94,
shadow=0.3,
flatness=1.0
)
tw(
txt,
2025-04-07 00:16:33 +00:00
on_activate_call=Call(s._copy_msg, s._w1[z])
)
cw(edit=s._columnwidget, visible_child=txt)
2024-05-16 18:44:57 +03:00
2025-01-22 21:47:33 +05:30
# ba_meta require api 9
2025-04-07 00:16:33 +00:00
2025-06-24 00:55:09 +05:30
# ba_meta export babase.Plugin
2025-06-23 19:27:10 +00:00
class byBordd(Plugin):
2024-05-16 18:44:57 +03:00
def __init__(s):
party.PartyWindow = VeryPW