Compare commits

..

16 Commits

Author SHA1 Message Date
a100324265 Reformatted and cleaned up everything 2025-04-16 18:05:07 +02:00
e90694f0aa Merge remote-tracking branch 'origin/master' 2025-04-16 17:58:35 +02:00
13f92b2817 Improved logging and fixed missing locale strings 2025-04-16 17:57:30 +02:00
939bb4fef3 Improved logging and fixed missing locale strings 2025-04-16 17:56:41 +02:00
906770ef60 Enabled automerge for Renovate 2025-04-16 15:56:35 +02:00
b85ca1d017 Added support for libbot 4.1.0 2025-04-16 15:54:52 +02:00
e906852abe Update dependency uvloop to v0.21.0 (#58)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [uvloop](https://github.com/MagicStack/uvloop) | minor | `==0.20.0` -> `==0.21.0` |

---

### Release Notes

<details>
<summary>MagicStack/uvloop (uvloop)</summary>

### [`v0.21.0`](https://github.com/MagicStack/uvloop/releases/tag/v0.21.0)

[Compare Source](https://github.com/MagicStack/uvloop/compare/v0.20.0...v0.21.0)

# Changes

-   Add cleanup_socket param on create_unix_server()
    ([#&#8203;623](https://github.com/MagicStack/uvloop/issues/623)) (by [@&#8203;fantix](https://github.com/fantix) in [`d6114d2`](https://github.com/MagicStack/uvloop/commit/d6114d2))

# Fixes

-   Use cythonized SO_REUSEPORT rather than the unwrapped native one. ([#&#8203;609](https://github.com/MagicStack/uvloop/issues/609))
    (by [@&#8203;ptribble](https://github.com/ptribble) in [`4083a94`](https://github.com/MagicStack/uvloop/commit/4083a94e) for [#&#8203;550](https://github.com/MagicStack/uvloop/issues/550))

-   UDP errors should result in protocol.error_received ([#&#8203;601](https://github.com/MagicStack/uvloop/issues/601))
    (by [@&#8203;jensbjorgensen](https://github.com/jensbjorgensen) in [`3c3bbef`](https://github.com/MagicStack/uvloop/commit/3c3bbeff))

-   Updates for Cython3 ([#&#8203;587](https://github.com/MagicStack/uvloop/issues/587))
    (by [@&#8203;alan-brooks](https://github.com/alan-brooks) in [`3fba9fa`](https://github.com/MagicStack/uvloop/commit/3fba9fab) for [#&#8203;587](https://github.com/MagicStack/uvloop/issues/587))

-   Test with Python 3.13 ([#&#8203;610](https://github.com/MagicStack/uvloop/issues/610))
    (by [@&#8203;edgarrmondragon](https://github.com/edgarrmondragon) in [`fb5a139`](https://github.com/MagicStack/uvloop/commit/fb5a139))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: https://git.end-play.xyz/profitroll/PyrogramBotBase/pulls/58
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-10-15 10:11:05 +03:00
a73534f688 Update dependency async_pymongo to v0.1.9 (#57)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [async_pymongo](https://github.com/Mayuri-Chan/async_pymongo) | patch | `==0.1.8` -> `==0.1.9` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: #57
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-10-08 16:49:52 +03:00
d3bf927f33 Update dependency async_pymongo to v0.1.8 (#56)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [async_pymongo](https://github.com/Mayuri-Chan/async_pymongo) | patch | `==0.1.7` -> `==0.1.8` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: #56
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-09-25 22:25:29 +03:00
2a4e3ad187 Update dependency async_pymongo to v0.1.7 (#55)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [async_pymongo](https://github.com/Mayuri-Chan/async_pymongo) | patch | `==0.1.6` -> `==0.1.7` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: #55
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-09-21 01:52:39 +03:00
518bc0d278 Update dependency uvloop to v0.20.0 (#54)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [uvloop](https://github.com/MagicStack/uvloop) | minor | `==0.19.0` -> `==0.20.0` |

---

### Release Notes

<details>
<summary>MagicStack/uvloop (uvloop)</summary>

### [`v0.20.0`](https://github.com/MagicStack/uvloop/releases/tag/v0.20.0)

[Compare Source](https://github.com/MagicStack/uvloop/compare/v0.19.0...v0.20.0)

# Changes

-   Upgrade libuv to v1.48.0 ([#&#8203;600](https://github.com/MagicStack/uvloop/issues/600))
    (by [@&#8203;niklasr22](https://github.com/niklasr22) [@&#8203;fantix](https://github.com/fantix) in [`7777852`](https://github.com/MagicStack/uvloop/commit/77778525) for [#&#8203;596](https://github.com/MagicStack/uvloop/issues/596) [#&#8203;615](https://github.com/MagicStack/uvloop/issues/615))

# Fixes

-   Fix test_create_server\_4 with Python 3.12.5 ([#&#8203;614](https://github.com/MagicStack/uvloop/issues/614))
    (by [@&#8203;shadchin](https://github.com/shadchin) in [`62f9239`](https://github.com/MagicStack/uvloop/commit/62f92393))

-   Use len(os.sched_getaffinity(0)) instead of os.cpu_count() ([#&#8203;591](https://github.com/MagicStack/uvloop/issues/591))
    (by [@&#8203;avkarenow](https://github.com/avkarenow) in [`c8531c2`](https://github.com/MagicStack/uvloop/commit/c8531c24) for [#&#8203;591](https://github.com/MagicStack/uvloop/issues/591))

-   Inline \_Py_RestoreSignals() from CPython ([#&#8203;604](https://github.com/MagicStack/uvloop/issues/604))
    (by [@&#8203;befeleme](https://github.com/befeleme) in [`8511ba1`](https://github.com/MagicStack/uvloop/commit/8511ba1f) for [#&#8203;603](https://github.com/MagicStack/uvloop/issues/603))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: https://git.end-play.xyz/profitroll/PyrogramBotBase/pulls/54
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-08-15 23:48:19 +03:00
eeb6d04f51 Update dependency libbot to v3.2.3 (#53)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [libbot](https://git.end-play.xyz/profitroll/LibBotUniversal) | patch | `==3.2.2` -> `==3.2.3` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: #53
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-07-10 08:12:13 +03:00
264731c755 Update dependency async_pymongo to v0.1.6 (#52)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [async_pymongo](https://github.com/Mayuri-Chan/async_pymongo) | patch | `==0.1.5` -> `==0.1.6` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: #52
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-06-23 14:34:06 +03:00
856b389b1b Update dependency async_pymongo to v0.1.5 (#51)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [async_pymongo](https://github.com/Mayuri-Chan/async_pymongo) | patch | `==0.1.4` -> `==0.1.5` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Co-authored-by: Profitroll <profitroll@noreply.localhost>
Reviewed-on: #51
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-06-02 12:54:53 +03:00
1671d30444 Update dependency libbot to v3.2.2 (#50)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [libbot](https://git.end-play.xyz/profitroll/LibBotUniversal) | patch | `==3.2.1` -> `==3.2.2` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: #50
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-05-26 23:58:23 +03:00
2e60b8616d Update dependency libbot to v3.2.1 (#49)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [libbot](https://git.end-play.xyz/profitroll/LibBotUniversal) | minor | `==3.1.0` -> `==3.2.1` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4zNS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMzUuMCIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Reviewed-on: #49
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-05-26 19:41:01 +03:00
16 changed files with 109 additions and 46 deletions

View File

@@ -2,5 +2,16 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "extends": [
"config:base" "config:base"
],
"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"automerge": true
}
] ]
} }

View File

@@ -1,12 +1,13 @@
import logging
from dataclasses import dataclass from dataclasses import dataclass
from logging import Logger
from typing import Union from typing import Union
from bson import ObjectId from bson import ObjectId
from modules.database_mongo import col_users from modules.database_mongo import col_users
from modules.logging_utils import get_logger
logger = logging.getLogger(__name__) logger: Logger = get_logger(__name__)
@dataclass @dataclass

View File

@@ -3,8 +3,9 @@ from dataclasses import dataclass
from typing import Union from typing import Union
from modules.database_sqlite import cursor from modules.database_sqlite import cursor
from modules.logging_utils import get_logger
logger = logging.getLogger(__name__) logger: logging.Logger = get_logger(__name__)
@dataclass @dataclass
@@ -30,16 +31,12 @@ class PyroUser:
### Returns: ### Returns:
* `PyroUser`: User with its database data. * `PyroUser`: User with its database data.
""" """
db_entry = cursor.execute( db_entry = cursor.execute("SELECT id, locale FROM users WHERE id = ?", (id,)).fetchone()
"SELECT id, locale FROM users WHERE id = ?", (id,)
).fetchone()
if db_entry is None: if db_entry is None:
cursor.execute("INSERT INTO users VALUES (?, ?)", (id, locale)) cursor.execute("INSERT INTO users VALUES (?, ?)", (id, locale))
cursor.connection.commit() cursor.connection.commit()
db_entry = cursor.execute( db_entry = cursor.execute("SELECT id, locale FROM users WHERE id = ?", (id,)).fetchone()
"SELECT id, locale FROM users WHERE id = ?", (id,)
).fetchone()
if db_entry is None: if db_entry is None:
raise RuntimeError("Could not find inserted user entry.") raise RuntimeError("Could not find inserted user entry.")

View File

@@ -10,6 +10,7 @@
}, },
"commands": { "commands": {
"start": "Start using the bot", "start": "Start using the bot",
"shutdown": "Turn off the bot",
"language": "Change bot's language", "language": "Change bot's language",
"remove_commands": "Unregister all commands" "remove_commands": "Unregister all commands"
}, },

View File

@@ -9,6 +9,7 @@
}, },
"commands": { "commands": {
"start": "Почати користуватись ботом", "start": "Почати користуватись ботом",
"shutdown": "Вимкнути бота",
"language": "Змінити мову бота", "language": "Змінити мову бота",
"remove_commands": "Видалити всі команди" "remove_commands": "Видалити всі команди"
}, },

28
main.py
View File

@@ -1,14 +1,17 @@
import contextlib import contextlib
import logging import logging.config
from argparse import ArgumentParser from argparse import ArgumentParser
from os import getpid from logging import Logger
from os import getpid, makedirs
from pathlib import Path from pathlib import Path
from sys import exit
from libbot import sync from libbot.utils import json_read
from classes.pyroclient import PyroClient from classes.pyroclient import PyroClient
from modules.logging_utils import get_logger, get_logging_config
# Main uses MongoDB implementation of DB # Main uses MongoDB implementation of DB,
# but you can also select SQLite one below # but you can also select SQLite one below
# from modules.migrator_sqlite import migrate_database # from modules.migrator_sqlite import migrate_database
from modules.migrator_mongo import migrate_database from modules.migrator_mongo import migrate_database
@@ -21,13 +24,11 @@ from modules.scheduler import scheduler
# from convopyro import Conversation # from convopyro import Conversation
logging.basicConfig( makedirs(Path("logs/"), exist_ok=True)
level=logging.DEBUG if sync.config_get("debug") else logging.INFO,
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
datefmt="[%X]",
)
logger = logging.getLogger(__name__) logging.config.dictConfig(get_logging_config())
logger: Logger = get_logger(__name__)
parser = ArgumentParser( parser = ArgumentParser(
prog="__name__", prog="__name__",
@@ -52,15 +53,16 @@ def main():
logger.info("Migration finished. Exiting...") logger.info("Migration finished. Exiting...")
exit() exit()
client = PyroClient( client = PyroClient(scheduler=scheduler, commands_source=json_read(Path("commands.json")))
scheduler=scheduler, commands_source=sync.json_read(Path("commands.json"))
)
# Conversation(client) # Conversation(client)
try: try:
client.run() client.run()
except KeyboardInterrupt: except KeyboardInterrupt:
logger.warning("Forcefully shutting down with PID %s...", getpid()) logger.warning("Forcefully shutting down with PID %s...", getpid())
except Exception as exc:
logger.error("An unexpected exception has occurred: %s", exc, exc_info=exc)
exit(1)
finally: finally:
if client.scheduler is not None: if client.scheduler is not None:
client.scheduler.shutdown() client.scheduler.shutdown()

View File

@@ -3,7 +3,7 @@
from typing import Any, Mapping from typing import Any, Mapping
from async_pymongo import AsyncClient, AsyncCollection, AsyncDatabase from async_pymongo import AsyncClient, AsyncCollection, AsyncDatabase
from libbot.sync import config_get from libbot.utils import config_get
db_config: Mapping[str, Any] = config_get("database") db_config: Mapping[str, Any] = config_get("database")
@@ -16,9 +16,7 @@ if db_config["user"] is not None and db_config["password"] is not None:
db_config["name"], db_config["name"],
) )
else: else:
con_string = "mongodb://{0}:{1}/{2}".format( con_string = "mongodb://{0}:{1}/{2}".format(db_config["host"], db_config["port"], db_config["name"])
db_config["host"], db_config["port"], db_config["name"]
)
db_client = AsyncClient(con_string) db_client = AsyncClient(con_string)
db: AsyncDatabase = db_client.get_database(name=db_config["name"]) db: AsyncDatabase = db_client.get_database(name=db_config["name"])

View File

@@ -3,7 +3,7 @@
import sqlite3 import sqlite3
from pathlib import Path from pathlib import Path
from libbot.sync import config_get from libbot.utils import config_get
db: sqlite3.Connection = sqlite3.connect(Path(config_get("database"))) db: sqlite3.Connection = sqlite3.connect(Path(config_get("database")))
cursor: sqlite3.Cursor = db.cursor() cursor: sqlite3.Cursor = db.cursor()

35
modules/logging_utils.py Normal file
View File

@@ -0,0 +1,35 @@
import logging
from logging import Logger
from pathlib import Path
from typing import Any, Dict
from libbot.utils import config_get
def get_logging_config() -> Dict[str, Any]:
return {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"file": {
"class": "logging.handlers.RotatingFileHandler",
"filename": str(Path("logs/latest.log")),
"maxBytes": 500000,
"backupCount": 10,
"formatter": "simple",
},
"console": {"class": "logging.StreamHandler", "formatter": "systemd"},
},
"formatters": {
"simple": {"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"},
"systemd": {"format": "%(name)s - %(levelname)s - %(message)s"},
},
"root": {
"level": "DEBUG" if config_get("debug") else "INFO",
"handlers": ["file", "console"],
},
}
def get_logger(name: str) -> Logger:
return logging.getLogger(name)

View File

@@ -1,6 +1,6 @@
from typing import Any, Mapping from typing import Any, Mapping
from libbot.sync import config_get from libbot.utils import config_get
from mongodb_migrations.cli import MigrationManager from mongodb_migrations.cli import MigrationManager
from mongodb_migrations.config import Configuration from mongodb_migrations.config import Configuration

View File

@@ -2,7 +2,7 @@ from os import rename
from pathlib import Path from pathlib import Path
from typing import Mapping from typing import Mapping
from libbot.sync import json_read from libbot.utils import json_read
from modules.database_sqlite import cursor from modules.database_sqlite import cursor
@@ -18,9 +18,7 @@ def migrate_database() -> None:
user_locale = None if "locale" not in keys else keys["locale"] user_locale = None if "locale" not in keys else keys["locale"]
user_card = None if "card" not in keys else keys["card"] user_card = None if "card" not in keys else keys["card"]
cursor.execute( cursor.execute("INSERT INTO users VALUES (?, ?)", (int(user), user_card, user_locale))
"INSERT INTO users VALUES (?, ?)", (int(user), user_card, user_locale)
)
cursor.connection.commit() cursor.connection.commit()
rename(Path("data/database.json"), Path("data/database.migrated.json")) rename(Path("data/database.json"), Path("data/database.migrated.json"))

View File

@@ -6,6 +6,4 @@ from classes.pyroclient import PyroClient
@PyroClient.on_callback_query(filters.regex("nothing")) # type: ignore @PyroClient.on_callback_query(filters.regex("nothing")) # type: ignore
async def callback_nothing(app: PyroClient, callback: CallbackQuery): async def callback_nothing(app: PyroClient, callback: CallbackQuery):
await callback.answer( await callback.answer(text=app._("nothing", "callbacks", locale=callback.from_user.language_code))
text=app._("nothing", "callbacks", locale=callback.from_user.language_code)
)

View File

@@ -8,6 +8,4 @@ from classes.pyroclient import PyroClient
~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]) # type: ignore ~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]) # type: ignore
) )
async def command_start(app: PyroClient, message: Message): async def command_start(app: PyroClient, message: Message):
await message.reply_text( await message.reply_text(app._("start", "messages", locale=message.from_user.language_code))
app._("start", "messages", locale=message.from_user.language_code)
)

View File

@@ -18,9 +18,7 @@ async def command_language(app: PyroClient, message: Message):
buttons: List[InlineButton] = [] buttons: List[InlineButton] = []
for locale, data in app.in_every_locale("metadata").items(): for locale, data in app.in_every_locale("metadata").items():
buttons.append( buttons.append(InlineButton(f"{data['flag']} {data['name']}", f"language:{locale}"))
InlineButton(f"{data['flag']} {data['name']}", f"language:{locale}")
)
keyboard.add(*buttons) keyboard.add(*buttons)

25
pyproject.toml Normal file
View File

@@ -0,0 +1,25 @@
[project]
name = "PyrogramBotBase"
authors = [{ name = "Profitroll" }]
readme = "README.md"
requires-python = ">=3.11"
[tool.black]
line-length = 108
target-version = ["py311", "py312", "py313"]
[tool.isort]
profile = "black"
[tool.mypy]
namespace_packages = true
install_types = true
strict = true
show_error_codes = true
[tool.pylint]
disable = ["line-too-long"]
[tool.pylint.main]
extension-pkg-whitelist = ["ujson"]
py-version = 3.11

View File

@@ -1,10 +1,10 @@
apscheduler~=3.10.4 apscheduler~=3.11.0
async_pymongo==0.1.9
convopyro==0.5 convopyro==0.5
tgcrypto==1.2.5 libbot[speed,pyrogram]==4.1.0
uvloop==0.19.0 tgcrypto-pyrofork==1.2.7
uvloop==0.21.0
# If uses MongoDB: # If uses MongoDB:
mongodb-migrations==1.3.1 mongodb-migrations==1.3.1
--extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple --extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple
async_pymongo==0.1.4
libbot[speed,pyrogram]==3.2.0
pykeyboard==0.1.7 pykeyboard==0.1.7