Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stickersbeter #20

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
12 changes: 4 additions & 8 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ on:
jobs:
code-quality:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6 ]
continue-on-error: false

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: 3.8
- name: Install dependencies
run: |
sudo apt-get update
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ venv: .venv/make_venv_complete ## Create virtual environment
python3 -m venv .venv
. .venv/bin/activate && ${env} pip install -U pip
. .venv/bin/activate && ${env} pip install -U pip-tools
. .venv/bin/activate && ${env} python3 -m piptools compile requirements.in
. .venv/bin/activate && ${env} python3 -m piptools compile requirements-dev.in
. .venv/bin/activate && ${env} pip install -Ur requirements.txt
. .venv/bin/activate && ${env} pip install -Ur requirements-dev.txt
touch .venv/make_venv_complete
Expand Down
25 changes: 12 additions & 13 deletions kassa.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,25 @@ def callhook(self, hook, arg):
def donext(self, plug, function):
self.nextcall = {"plug": plug, "function": function}


def input(self, text):
def input(self, text): # pylint: disable=too-many-branches
if not text:
self.send_message(True, "message", "Enter product, command or username")
self.send_message(True, "buttons", json.dumps({}))
return

self.buttons = {}
done = 0

for plug, plugin in self.plugins.items():
try:
plugin.pre_input(text)
except AttributeError:
pass
except:
print(traceback.format_exc())

self.prompt = ""

if self.nextcall:
try:
plug = self.nextcall["plug"]
Expand All @@ -133,22 +132,22 @@ def input(self, text):
done = 1
except:
print(traceback.format_exc())

if done == 0:
parts = text.split()
for part in parts:
if part:
done = self.handle_part(part) # Call handle_part for each part

if done == 1 and not self.prompt:
self.send_message(True, "message", "Enter product, command or username")
elif not self.prompt:
self.send_message(True, "message", "Unknown product, command or username")
self.callhook("wrong", ())

if not self.nextcall and not self.buttons:
self.send_message(True, "buttons", json.dumps({}))

def handle_part(self, part):
done = 0
if self.nextcall:
Expand All @@ -160,7 +159,7 @@ def handle_part(self, part):
done = 1
except:
print(traceback.format_exc())

if done == 0:
for plug, plugin in self.plugins.items():
try:
Expand All @@ -171,13 +170,13 @@ def handle_part(self, part):
print(traceback.format_exc())
except:
print(traceback.format_exc())

if done == 0:
if self.plugins.get("withdraw") and self.plugins["withdraw"].withdraw(part):
done = 1
if self.plugins.get("accounts") and self.plugins["accounts"].newuser(part):
done = 1

return done

def send_message(self, retain, topic, message):
Expand Down
9 changes: 7 additions & 2 deletions plugins/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ def help(self):
return {"adduseralias": "Add user key alias"}

def get_last_updated_accounts(self):
print(self.accounts)
# Sort the accounts based on last update time, in descending order
sorted_accounts = sorted(self.accounts.items(), key=lambda x: x[1]['lastupdate'], reverse=True)
sorted_accounts = sorted(
self.accounts.items(), key=lambda x: x[1]["lastupdate"], reverse=True
)
# Extract the account names from the sorted list
account_names = [account[0] for account in sorted_accounts if account[0] not in self.members][0:125]
account_names = [
account[0] for account in sorted_accounts if account[0] not in self.members
][0:125]
self.master.send_message(True, "nonmembers", json.dumps(account_names))

# Internal functions
Expand Down
Loading
Loading