Compare commits

...

71 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
ee8a92ad3a Main now exists after migration 2024-05-26 15:02:44 +02:00
d47239899a Added debug config option 2024-05-26 13:57:16 +02:00
29e379fa3b Update dependency libbot to v3.1.0 (#47)
This PR contains the following updates:

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

---

### 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: #47
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2024-05-24 22:46:35 +03:00
02bda76c68 Update dependency mongodb-migrations to v1.3.1 (#46) 2024-05-14 01:48:42 +03:00
3a4382fe5a Update dependency mongodb-migrations to v1.3.1 2024-05-14 01:27:32 +03:00
5109e9268d New session files added to ignore 2024-03-19 23:23:09 +02:00
a473c67905 Custom pykeyboard is now used 2024-01-03 23:53:50 +01:00
0931eea035 Bump libbot to 3.0.0 and apscheduler to ~=3.10.4 2024-01-03 23:23:53 +01:00
a7d6dcb1a0 Minor cleanups 2024-01-03 23:21:43 +01:00
24873996ac Update dependency libbot to v2.1.0 (#43)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [libbot](https://github.com/botlibx/libbot) | minor | `==2.0.1` -> `==2.1.0` |

---

### 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: #43
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2023-12-28 13:36:04 +02:00
8ee7d5fe2e Update dependency uvloop to v0.19.0 (#26)
This PR contains the following updates:

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

---

### Release Notes

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

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

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

# Changes

-   Drop support of Python 3.7 and update CI ([#&#8203;578](https://github.com/MagicStack/uvloop/issues/578))
    (by [@&#8203;fantix](https://github.com/fantix) in [`ee5ad26`](https://github.com/MagicStack/uvloop/commit/ee5ad26a) for [#&#8203;578](https://github.com/MagicStack/uvloop/issues/578))

# Fixes

-   Restore uvloop.new_event_loop and other missing uvloop members to typing ([#&#8203;573](https://github.com/MagicStack/uvloop/issues/573))
    (by [@&#8203;graingert](https://github.com/graingert) in [`5c500ee`](https://github.com/MagicStack/uvloop/commit/5c500ee2) for [#&#8203;573](https://github.com/MagicStack/uvloop/issues/573))

-   Fix docstring of loop.shutdown_default_executor ([#&#8203;535](https://github.com/MagicStack/uvloop/issues/535))
    (by [@&#8203;Gelbpunkt](https://github.com/Gelbpunkt) in [`919da56`](https://github.com/MagicStack/uvloop/commit/919da567) for [#&#8203;535](https://github.com/MagicStack/uvloop/issues/535))

-   Fix CI status badge ([#&#8203;522](https://github.com/MagicStack/uvloop/issues/522))
    (by [@&#8203;shuuji3](https://github.com/shuuji3) in [`0e9ff6c`](https://github.com/MagicStack/uvloop/commit/0e9ff6cd) for [#&#8203;522](https://github.com/MagicStack/uvloop/issues/522))

</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/26
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2023-10-29 19:33:03 +02:00
d305d70f92 Update dependency uvloop to v0.18.0 (#20)
This PR contains the following updates:

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

---

### Release Notes

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

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

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

# Fixes

-   CI fixes ([#&#8203;520](https://github.com/MagicStack/uvloop/issues/520), [#&#8203;553](https://github.com/MagicStack/uvloop/issues/553))
    (by [@&#8203;altendky](https://github.com/altendky) in [`7783f1c`](https://github.com/MagicStack/uvloop/commit/7783f1c5), [@&#8203;dulmandakh](https://github.com/dulmandakh) in [`1dd40f1`](https://github.com/MagicStack/uvloop/commit/1dd40f17))

-   Make extract_stack resilient to lacking frames. ([#&#8203;563](https://github.com/MagicStack/uvloop/issues/563))
    (by [@&#8203;jhance](https://github.com/jhance) in [`0687643`](https://github.com/MagicStack/uvloop/commit/06876434) for [#&#8203;563](https://github.com/MagicStack/uvloop/issues/563))

-   Port uvloop to Python 3.12 ([#&#8203;570](https://github.com/MagicStack/uvloop/issues/570))
    (by [@&#8203;1st1](https://github.com/1st1), [@&#8203;fantix](https://github.com/fantix) in [`9f82bd7`](https://github.com/MagicStack/uvloop/commit/9f82bd74) for [#&#8203;569](https://github.com/MagicStack/uvloop/issues/569))

</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/20
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2023-10-15 17:48:20 +03:00
866ab2429f Added additional SQLite option 2023-08-23 15:45:15 +02:00
59bfc4c1ca Fixed a few nasty issues 2023-08-23 00:19:27 +02:00
4a2e15c6e7 Added collection validation 2023-08-18 20:43:22 +02:00
24a2837f34 Added migrations 2023-08-18 20:43:09 +02:00
32260e95a7 Improved docs and typing 2023-08-17 23:04:38 +02:00
4cbb51ca61 Changed find_user behavior 2023-08-17 15:21:08 +02:00
8dad53409b Added deprecation notice 2023-08-17 15:15:53 +02:00
b3805d66ef Minor improvements 2023-08-17 15:01:35 +02:00
ac36e70b7f Removed unused aiofiles 2023-08-14 15:17:56 +02:00
d8f8e49f31 Migrate to async_pymongo 2023-08-14 15:16:30 +02:00
faccb22bc0 Update dependency libbot to v2.0.1 (#16)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| libbot | patch | `==2.0.0` -> `==2.0.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: #16
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2023-08-11 11:31:15 +03:00
fd349eb19c Update dependency aiofiles to ~=23.2.1 (#15)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [aiofiles](https://github.com/Tinche/aiofiles#history) ([changelog](https://github.com/Tinche/aiofiles#history)) | minor | `~=23.1.0` -> `~=23.2.1` |

---

### Release Notes

<details>
<summary>Tinche/aiofiles (aiofiles)</summary>

### [`v23.2.0`](https://github.com/Tinche/aiofiles/compare/v23.1.0...v23.2.0)

[Compare Source](https://github.com/Tinche/aiofiles/compare/v23.1.0...v23.2.0)

</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: #15
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2023-08-09 23:20:37 +03:00
59dd3f95c4 Update dependency libbot to v2 (#14)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| libbot | major | `==0.2.2` -> `==2.0.0` |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTQuMCJ9-->

Reviewed-on: #14
Co-authored-by: Renovate <renovate@git.end-play.xyz>
Co-committed-by: Renovate <renovate@git.end-play.xyz>
2023-08-07 13:07:53 +03:00
e9005f2015 Bump libbot to 0.2.2 2023-08-06 22:06:16 +02:00
40d786b585 Reorganized plugins 2023-08-03 21:32:58 +02:00
53811c9179 Merge branch 'master' of https://git.end-play.xyz/profitroll/PyrogramBotBase 2023-08-03 21:30:11 +02:00
95dbd9cec8 Added database and /language 2023-08-03 21:29:47 +02:00
abb30c6d8f Update dependency libbot to v1.9 (#11)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| libbot | minor | `==1.8` -> `==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:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTQuMCJ9-->

Co-authored-by: Renovate <renovate@git.end-play.xyz>
Reviewed-on: #11
Co-authored-by: Renovate <renovate@noreply.localhost>
Co-committed-by: Renovate <renovate@noreply.localhost>
2023-07-26 15:28:37 +03:00
b1f7e649b9 Update dependency black to ~=23.7.0 (#10)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [black](https://github.com/psf/black) ([changelog](https://github.com/psf/black/blob/main/CHANGES.md)) | minor | `~=23.3.0` -> `~=23.7.0` |

---

### Release Notes

<details>
<summary>psf/black</summary>

### [`v23.7.0`](https://github.com/psf/black/blob/HEAD/CHANGES.md#&#8203;2370)

[Compare Source](https://github.com/psf/black/compare/23.3.0...23.7.0)

##### Highlights

-   Runtime support for Python 3.7 has been removed. Formatting 3.7 code will still be
    supported until further notice ([#&#8203;3765](https://github.com/psf/black/issues/3765))

##### Stable style

-   Fix a bug where an illegal trailing comma was added to return type annotations using
    PEP 604 unions ([#&#8203;3735](https://github.com/psf/black/issues/3735))
-   Fix several bugs and crashes where comments in stub files were removed or mishandled
    under some circumstances ([#&#8203;3745](https://github.com/psf/black/issues/3745))
-   Fix a crash with multi-line magic comments like `type: ignore` within parentheses
    ([#&#8203;3740](https://github.com/psf/black/issues/3740))
-   Fix error in AST validation when *Black* removes trailing whitespace in a type comment
    ([#&#8203;3773](https://github.com/psf/black/issues/3773))

##### Preview style

-   Implicitly concatenated strings used as function args are no longer wrapped inside
    parentheses ([#&#8203;3640](https://github.com/psf/black/issues/3640))
-   Remove blank lines between a class definition and its docstring ([#&#8203;3692](https://github.com/psf/black/issues/3692))

##### Configuration

-   The `--workers` argument to *Black* can now be specified via the `BLACK_NUM_WORKERS`
    environment variable ([#&#8203;3743](https://github.com/psf/black/issues/3743))
-   `.pytest_cache`, `.ruff_cache` and `.vscode` are now excluded by default ([#&#8203;3691](https://github.com/psf/black/issues/3691))
-   Fix *Black* not honouring `pyproject.toml` settings when running `--stdin-filename`
    and the `pyproject.toml` found isn't in the current working directory ([#&#8203;3719](https://github.com/psf/black/issues/3719))
-   *Black* will now error if `exclude` and `extend-exclude` have invalid data types in
    `pyproject.toml`, instead of silently doing the wrong thing ([#&#8203;3764](https://github.com/psf/black/issues/3764))

##### Packaging

-   Upgrade mypyc from 0.991 to 1.3 ([#&#8203;3697](https://github.com/psf/black/issues/3697))
-   Remove patching of Click that mitigated errors on Python 3.6 with `LANG=C` ([#&#8203;3768](https://github.com/psf/black/issues/3768))

##### Parser

-   Add support for the new PEP 695 syntax in Python 3.12 ([#&#8203;3703](https://github.com/psf/black/issues/3703))

##### Performance

-   Speed up *Black* significantly when the cache is full ([#&#8203;3751](https://github.com/psf/black/issues/3751))
-   Avoid importing `IPython` in a case where we wouldn't need it ([#&#8203;3748](https://github.com/psf/black/issues/3748))

##### Output

-   Use aware UTC datetimes internally, avoids deprecation warning on Python 3.12 ([#&#8203;3728](https://github.com/psf/black/issues/3728))
-   Change verbose logging to exactly mirror *Black*'s logic for source discovery ([#&#8203;3749](https://github.com/psf/black/issues/3749))

##### *Blackd*

-   The `blackd` argument parser now shows the default values for options in their help
    text ([#&#8203;3712](https://github.com/psf/black/issues/3712))

##### Integrations

-   Black is now tested with
    [`PYTHONWARNDEFAULTENCODING = 1`](https://docs.python.org/3/library/io.html#io-encoding-warning)
    ([#&#8203;3763](https://github.com/psf/black/issues/3763))
-   Update GitHub Action to display black output in the job summary ([#&#8203;3688](https://github.com/psf/black/issues/3688))

##### Documentation

-   Add a CITATION.cff file to the root of the repository, containing metadata on how to
    cite this software ([#&#8203;3723](https://github.com/psf/black/issues/3723))
-   Update the *classes* and *exceptions* documentation in Developer reference to match
    the latest code base ([#&#8203;3755](https://github.com/psf/black/issues/3755))

</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:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTQuMCJ9-->

Co-authored-by: Renovate <renovate@git.end-play.xyz>
Reviewed-on: https://git.end-play.xyz/profitroll/PyrogramBotBase/pulls/10
Co-authored-by: Renovate <renovate@noreply.localhost>
Co-committed-by: Renovate <renovate@noreply.localhost>
2023-07-11 11:20:26 +03:00
4f754ee380 reports.chat_id is now "owner" (libbot 1.8 update) 2023-07-03 12:56:20 +02:00
d27d94494e Update dependency libbot to v1.8 (#9)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| libbot | minor | `==1.7` -> `==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:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTQuMCJ9-->

Co-authored-by: Renovate <renovate@git.end-play.xyz>
Reviewed-on: #9
Co-authored-by: Renovate <renovate@noreply.localhost>
Co-committed-by: Renovate <renovate@noreply.localhost>
2023-07-03 13:54:28 +03:00
c05d76e2cc Bump libbot to 1.7 2023-06-30 11:37:28 +02:00
3de51695ca Bump libbot to 1.5 2023-06-26 13:37:52 +02:00
086dcd5253 Updated to libbot 1.3 replacing old classes 2023-06-26 12:50:21 +02:00
a5a9a97dbc max_concurrent_transmissions built-in 2023-06-21 13:50:38 +02:00
524a3c2a29 Added dynamic scope chat_id for owner 2023-06-21 13:45:01 +02:00
0cfe55d3c9 Added self.config 2023-06-21 13:44:26 +02:00
f8b21093a4 Implemented BotLocale from libbot 2023-06-20 12:49:38 +02:00
f1a8739a44 Bump libbot to 1.0 2023-06-20 12:49:24 +02:00
624191a6b9 Update dependency libbot to v0.8 (#6)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| libbot | minor | `==0.7` -> `==0.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:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTQuMCJ9-->

Co-authored-by: Renovate <renovate@git.end-play.xyz>
Reviewed-on: #6
Co-authored-by: Renovate <renovate@noreply.localhost>
Co-committed-by: Renovate <renovate@noreply.localhost>
2023-06-14 11:48:31 +03:00
8e11dbc26a Update dependency ujson to v5.8.0 (#5)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ujson](https://github.com/ultrajson/ultrajson) | minor | `==5.7.0` -> `==5.8.0` |

---

### Release Notes

<details>
<summary>ultrajson/ultrajson</summary>

### [`v5.8.0`](https://github.com/ultrajson/ultrajson/releases/tag/5.8.0)

[Compare Source](https://github.com/ultrajson/ultrajson/compare/5.7.0...5.8.0)

#### Added

-   Build wheel for Python 3.12 beta (built against 3.12.0b2) ([#&#8203;594](https://github.com/ultrajson/ultrajson/issues/594)) [@&#8203;hugovk](https://github.com/hugovk)

#### Changed

-   Drop support for Python 3.7 ([#&#8203;595](https://github.com/ultrajson/ultrajson/issues/595)) [@&#8203;hugovk](https://github.com/hugovk)

#### Fixed

-   Include BSD-3-Clause and TCL license text ([#&#8203;584](https://github.com/ultrajson/ultrajson/issues/584)) [@&#8203;musicinmybrain](https://github.com/musicinmybrain)

</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:eyJjcmVhdGVkSW5WZXIiOiIzNS41NC4wIiwidXBkYXRlZEluVmVyIjoiMzUuNTQuMCJ9-->

Co-authored-by: Renovate <renovate@git.end-play.xyz>
Reviewed-on: https://git.end-play.xyz/profitroll/PyrogramBotBase/pulls/5
Co-authored-by: Renovate <renovate@noreply.localhost>
Co-committed-by: Renovate <renovate@noreply.localhost>
2023-06-11 12:26:30 +03:00
c68d589260 Added comments on workers 2023-06-01 15:53:47 +02:00
64b54a4efc Fixed typing 2023-05-28 11:49:45 +02:00
e4dfcfbc84 Fixed config 2023-05-28 11:43:54 +02:00
434503e9a9 Improved logging 2023-05-28 11:43:45 +02:00
37e2e86f0c Added bot owner attribute 2023-05-26 16:33:38 +02:00
f0c8b97524 Added command to remove command 2023-05-26 16:33:07 +02:00
2d941e2cb3 PyroClient overhaul 2023-05-26 16:32:56 +02:00
754129e046 Added scheduler 2023-05-26 16:32:24 +02:00
7eb82936e4 Added different dataclasses 2023-05-26 16:32:07 +02:00
cfff6b2b25 Added bot owner, commands, locations and locale 2023-05-26 16:31:33 +02:00
760d14e8e8 Added locales 2023-05-26 16:31:11 +02:00
cd006acf8d Bump libbot to 0.7 2023-05-26 16:30:47 +02:00
31 changed files with 586 additions and 109 deletions

2
.gitignore vendored
View File

@@ -155,6 +155,8 @@ cython_debug/
# Custom
config.json
*.session
*.session-wal
*.session-shm
*.session-journal
venv

View File

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

28
classes/callbacks.py Normal file
View File

@@ -0,0 +1,28 @@
from dataclasses import dataclass
from pyrogram.types import CallbackQuery
@dataclass
class CallbackLanguage:
language: str
@classmethod
def from_callback(cls, callback: CallbackQuery):
"""Parse callback query and extract language data from it.
### Args:
* callback (`CallbackQuery`): Callback query got from user interaction.
### Raises:
* `ValueError`: Raised when callback provided is not a language one.
### Returns:
* `CallbackLanguage`: Parsed callback query.
"""
action, language = str(callback.data).split(":")
if action.lower() != "language":
raise ValueError("Callback provided is not a language callback")
return cls(language)

27
classes/pyroclient.py Normal file
View File

@@ -0,0 +1,27 @@
from typing import Union
from libbot.pyrogram.classes import PyroClient as LibPyroClient
from pyrogram.types import User
# PyroClient uses MongoDB implementation of PyroUser
# but you can also select SQLite one below
# from classes.pyrouser_sqlite import PyroUser
from classes.pyrouser_mongo import PyroUser
class PyroClient(LibPyroClient):
async def find_user(self, user: Union[int, User]) -> PyroUser:
"""Find User by its ID or User object.
### Args:
* user (`Union[int, User]`): ID or User object to extract ID from.
### Returns:
* `PyroUser`: User in database representation.
"""
return (
await PyroUser.find(user)
if isinstance(user, int)
else await PyroUser.find(user.id, locale=user.language_code)
)

55
classes/pyrouser_mongo.py Normal file
View File

@@ -0,0 +1,55 @@
from dataclasses import dataclass
from logging import Logger
from typing import Union
from bson import ObjectId
from modules.database_mongo import col_users
from modules.logging_utils import get_logger
logger: Logger = get_logger(__name__)
@dataclass
class PyroUser:
"""Dataclass of DB entry of a user"""
__slots__ = ("_id", "id", "locale")
_id: ObjectId
id: int
locale: Union[str, None]
@classmethod
async def find(cls, id: int, locale: Union[str, None] = None):
"""Find user in database and create new record if user does not exist.
### Args:
* id (`int`): User's Telegram ID
* locale (`Union[str, None]`, *optional*): User's locale. Defaults to `None`.
### Raises:
* `RuntimeError`: Raised when user entry after insertion could not be found.
### Returns:
* `PyroUser`: User with its database data.
"""
db_entry = await col_users.find_one({"id": id})
if db_entry is None:
inserted = await col_users.insert_one({"id": id, "locale": locale})
db_entry = await col_users.find_one({"_id": inserted.inserted_id})
if db_entry is None:
raise RuntimeError("Could not find inserted user entry.")
return cls(**db_entry)
async def update_locale(self, locale: Union[str, None]) -> None:
"""Change user's locale stored in the database.
### Args:
* locale (`Union[str, None]`): New locale to be set.
"""
logger.debug("%s's locale has been set to %s", self.id, locale)
await col_users.update_one({"_id": self._id}, {"$set": {"locale": locale}})

View File

@@ -0,0 +1,57 @@
import logging
from dataclasses import dataclass
from typing import Union
from modules.database_sqlite import cursor
from modules.logging_utils import get_logger
logger: logging.Logger = get_logger(__name__)
@dataclass
class PyroUser:
"""Dataclass of DB entry of a user"""
__slots__ = ("id", "locale")
id: int
locale: Union[str, None]
@classmethod
async def find(cls, id: int, locale: Union[str, None] = None):
"""Find user in database and create new record if user does not exist.
### Args:
* id (`int`): User's Telegram ID
* locale (`Union[str, None]`, *optional*): User's locale. Defaults to `None`.
### Raises:
* `RuntimeError`: Raised when user entry after insertion could not be found.
### Returns:
* `PyroUser`: User with its database data.
"""
db_entry = cursor.execute("SELECT id, locale FROM users WHERE id = ?", (id,)).fetchone()
if db_entry is None:
cursor.execute("INSERT INTO users VALUES (?, ?)", (id, locale))
cursor.connection.commit()
db_entry = cursor.execute("SELECT id, locale FROM users WHERE id = ?", (id,)).fetchone()
if db_entry is None:
raise RuntimeError("Could not find inserted user entry.")
return cls(*db_entry)
async def update_locale(self, locale: Union[str, None]) -> None:
"""Change user's locale stored in the database.
### Args:
* locale (`Union[str, None]`): New locale to be set.
"""
logger.debug("%s's locale has been set to %s", self.id, locale)
cursor.execute(
"UPDATE users SET locale = ? WHERE id = ?",
(locale, self.id),
)
cursor.connection.commit()

29
commands.json Normal file
View File

@@ -0,0 +1,29 @@
{
"start": {
"scopes": [
{
"name": "BotCommandScopeDefault"
},
{
"name": "BotCommandScopeChat",
"chat_id": "owner"
}
]
},
"shutdown": {
"scopes": [
{
"name": "BotCommandScopeChat",
"chat_id": "owner"
}
]
},
"remove_commands": {
"scopes": [
{
"name": "BotCommandScopeChat",
"chat_id": "owner"
}
]
}
}

View File

@@ -1,12 +1,24 @@
{
"debug": false,
"locale": "en",
"bot": {
"owner": 0,
"api_id": 0,
"api_hash": "",
"bot_token": "",
"workers": 1
"workers": 1,
"max_concurrent_transmissions": 1,
"scoped_commands": true
},
"database": {
"user": null,
"password": null,
"host": "127.0.0.1",
"port": 27017,
"name": "pyrobot"
},
"disabled_plugins": [],
"reports": {
"chat_id": 0
}
"chat_id": "owner"
},
"disabled_plugins": []
}

24
locale/en.json Normal file
View File

@@ -0,0 +1,24 @@
{
"metadata": {
"flag": "🇬🇧",
"name": "English",
"codes": [
"en",
"en-US",
"en-GB"
]
},
"commands": {
"start": "Start using the bot",
"shutdown": "Turn off the bot",
"language": "Change bot's language",
"remove_commands": "Unregister all commands"
},
"messages": {
"start": "Welcome! I'm your bot!",
"locale_choice": "Alright. Please choose the language using keyboard below."
},
"callbacks": {
"locale_set": "Your language now is: {locale}"
}
}

23
locale/uk.json Normal file
View File

@@ -0,0 +1,23 @@
{
"metadata": {
"flag": "🇺🇦",
"name": "Українська",
"codes": [
"uk",
"uk-UA"
]
},
"commands": {
"start": "Почати користуватись ботом",
"shutdown": "Вимкнути бота",
"language": "Змінити мову бота",
"remove_commands": "Видалити всі команди"
},
"messages": {
"start": "Привіт! Я твій бот!",
"locale_choice": "Гаразд. Будь ласка, оберіть мову за допомогою клавіатури нижче."
},
"callbacks": {
"locale_set": "Встановлено мову: {locale}"
}
}

52
main.py
View File

@@ -1,21 +1,44 @@
import contextlib
import logging
from os import getpid
import logging.config
from argparse import ArgumentParser
from logging import Logger
from os import getpid, makedirs
from pathlib import Path
from sys import exit
from modules.app import PyroClient
from libbot.utils import json_read
from classes.pyroclient import PyroClient
from modules.logging_utils import get_logger, get_logging_config
# Main uses MongoDB implementation of DB,
# but you can also select SQLite one below
# from modules.migrator_sqlite import migrate_database
from modules.migrator_mongo import migrate_database
from modules.scheduler import scheduler
# Uncomment this and the line below client declaration
# in order to use context manager in your commands.
# Don't forget to disable PyroClient workers if you want
# to use convopyro, because workers create more event loops.
# from convopyro import Conversation
logging.basicConfig(
level=logging.INFO,
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
datefmt="[%X]",
makedirs(Path("logs/"), exist_ok=True)
logging.config.dictConfig(get_logging_config())
logger: Logger = get_logger(__name__)
parser = ArgumentParser(
prog="__name__",
description="__description__",
)
logger = logging.getLogger(__name__)
# Remove if no database is being used
parser.add_argument("--migrate", action="store_true")
args = parser.parse_args()
with contextlib.suppress(ImportError):
import uvloop
@@ -24,14 +47,25 @@ with contextlib.suppress(ImportError):
def main():
client = PyroClient()
# Remove if no database is being used
if args.migrate:
migrate_database()
logger.info("Migration finished. Exiting...")
exit()
client = PyroClient(scheduler=scheduler, commands_source=json_read(Path("commands.json")))
# Conversation(client)
try:
client.run()
except KeyboardInterrupt:
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:
if client.scheduler is not None:
client.scheduler.shutdown()
exit()

0
migrations/.gitkeep Normal file
View File

View File

@@ -1,60 +0,0 @@
import logging
from os import getpid
from time import time
import pyrogram
from libbot import config_get
from pyrogram.client import Client
from pyrogram.errors import BadRequest
from pyrogram.raw.all import layer
from ujson import loads
logger = logging.getLogger(__name__)
class PyroClient(Client):
def __init__(self):
with open("config.json", "r", encoding="utf-8") as f:
config = loads(f.read())
super().__init__(
name="bot_client",
api_id=config["bot"]["api_id"],
api_hash=config["bot"]["api_hash"],
bot_token=config["bot"]["bot_token"],
workers=config["bot"]["workers"],
plugins=dict(root="plugins", exclude=config["disabled_plugins"]),
sleep_threshold=120,
)
self.start_time = 0
async def start(self):
await super().start()
self.start_time = time()
logger.info(
"Bot is running with Pyrogram v%s (Layer %s) and has started as @%s on PID %s.",
pyrogram.__version__,
layer,
self.me.username,
getpid(),
)
try:
await self.send_message(
chat_id=await config_get("chat_id", "reports"),
text=f"Bot started PID `{getpid()}`",
)
except BadRequest:
logger.warning("Unable to send message to report chat.")
async def stop(self):
try:
await self.send_message(
chat_id=await config_get("chat_id", "reports"),
text=f"Bot stopped with PID `{getpid()}`",
)
except BadRequest:
logger.warning("Unable to send message to report chat.")
await super().stop()
logger.warning("Bot stopped with PID %s.", getpid())

24
modules/database_mongo.py Normal file
View File

@@ -0,0 +1,24 @@
"""Module that provides all database collections"""
from typing import Any, Mapping
from async_pymongo import AsyncClient, AsyncCollection, AsyncDatabase
from libbot.utils import config_get
db_config: Mapping[str, Any] = config_get("database")
if db_config["user"] is not None and db_config["password"] is not None:
con_string = "mongodb://{0}:{1}@{2}:{3}/{4}".format(
db_config["user"],
db_config["password"],
db_config["host"],
db_config["port"],
db_config["name"],
)
else:
con_string = "mongodb://{0}:{1}/{2}".format(db_config["host"], db_config["port"], db_config["name"])
db_client = AsyncClient(con_string)
db: AsyncDatabase = db_client.get_database(name=db_config["name"])
col_users: AsyncCollection = db.get_collection("users")

View File

@@ -0,0 +1,11 @@
"""Module that provides database access"""
import sqlite3
from pathlib import Path
from libbot.utils import config_get
db: sqlite3.Connection = sqlite3.connect(Path(config_get("database")))
cursor: sqlite3.Cursor = db.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER, card TEXT, locale TEXT)")

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)

22
modules/migrator_mongo.py Normal file
View File

@@ -0,0 +1,22 @@
from typing import Any, Mapping
from libbot.utils import config_get
from mongodb_migrations.cli import MigrationManager
from mongodb_migrations.config import Configuration
def migrate_database() -> None:
"""Apply migrations from folder `migrations/` to the database"""
db_config: Mapping[str, Any] = config_get("database")
manager_config = Configuration(
{
"mongo_host": db_config["host"],
"mongo_port": db_config["port"],
"mongo_database": db_config["name"],
"mongo_username": db_config["user"],
"mongo_password": db_config["password"],
}
)
manager = MigrationManager(manager_config)
manager.run()

View File

@@ -0,0 +1,24 @@
from os import rename
from pathlib import Path
from typing import Mapping
from libbot.utils import json_read
from modules.database_sqlite import cursor
def migrate_database() -> None:
"""Apply migrations from old JSON database to SQLite"""
if not Path("data/database.json").exists():
return
db_old: Mapping[str, Mapping[str, str]] = json_read(Path("data/database.json"))
for user, keys in db_old.items():
user_locale = None if "locale" not in keys else keys["locale"]
user_card = None if "card" not in keys else keys["card"]
cursor.execute("INSERT INTO users VALUES (?, ?)", (int(user), user_card, user_locale))
cursor.connection.commit()
rename(Path("data/database.json"), Path("data/database.migrated.json"))

3
modules/scheduler.py Normal file
View File

@@ -0,0 +1,3 @@
from apscheduler.schedulers.asyncio import AsyncIOScheduler
scheduler = AsyncIOScheduler()

View File

@@ -1,10 +0,0 @@
from pyrogram import filters
from pyrogram.client import Client
from pyrogram.types import CallbackQuery
from modules.app import PyroClient
@Client.on_callback_query(filters.regex("nothing")) # type: ignore
async def callback_nothing(app: PyroClient, clb: CallbackQuery):
await clb.answer(text="Nothing here...")

View File

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

View File

@@ -1,12 +0,0 @@
from pyrogram import filters
from pyrogram.client import Client
from pyrogram.types import Message
from modules.app import PyroClient
@Client.on_message(
~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]) # type: ignore
)
async def command_start(app: PyroClient, msg: Message):
await msg.reply_text("Welcome! I'm your bot!")

View File

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

View File

@@ -0,0 +1,12 @@
from pyrogram import filters
from pyrogram.types import Message
from classes.pyroclient import PyroClient
@PyroClient.on_message(
~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) # type: ignore
)
async def command_remove_commands(app: PyroClient, message: Message):
await message.reply_text("Okay.")
await app.remove_commands(command_sets=await app.collect_commands())

View File

@@ -0,0 +1,16 @@
import asyncio
from pyrogram import filters
from pyrogram.types import Message
from classes.pyroclient import PyroClient
@PyroClient.on_message(
~filters.scheduled
& filters.private
& filters.command(["shutdown", "reboot", "restart"], prefixes=["/"]) # type: ignore
)
async def command_shutdown(app: PyroClient, msg: Message):
if msg.from_user.id == app.owner:
asyncio.get_event_loop().create_task(app.stop())

View File

@@ -1,10 +1,9 @@
from pyrogram import filters
from pyrogram.client import Client
from pyrogram.types import Message
from modules.app import PyroClient
from classes.pyroclient import PyroClient
@Client.on_message(filters.text & filters.private) # type: ignore
@PyroClient.on_message(filters.text & filters.private) # type: ignore
async def handler_echo(app: PyroClient, message: Message):
await message.reply(message.text[::-1])

View File

@@ -1,14 +1,13 @@
from pyrogram.client import Client
from pyrogram.types import (
InlineQuery,
InlineQueryResultArticle,
InputTextMessageContent,
)
from modules.app import PyroClient
from classes.pyroclient import PyroClient
@Client.on_inline_query() # type: ignore
@PyroClient.on_inline_query() # type: ignore
async def inline(app: PyroClient, inline_query: InlineQuery):
await inline_query.answer(
results=[

43
plugins/language.py Normal file
View File

@@ -0,0 +1,43 @@
from typing import List
from pykeyboard import InlineButton, InlineKeyboard
from pyrogram import filters
from pyrogram.types import CallbackQuery, Message
from classes.callbacks import CallbackLanguage
from classes.pyroclient import PyroClient
@PyroClient.on_message(
~filters.scheduled & filters.private & filters.command(["language"], prefixes=["/"]) # type: ignore
)
async def command_language(app: PyroClient, message: Message):
user = await app.find_user(message.from_user)
keyboard = InlineKeyboard(row_width=2)
buttons: List[InlineButton] = []
for locale, data in app.in_every_locale("metadata").items():
buttons.append(InlineButton(f"{data['flag']} {data['name']}", f"language:{locale}"))
keyboard.add(*buttons)
await message.reply_text(
app._("locale_choice", "messages", locale=user.locale),
reply_markup=keyboard,
)
@PyroClient.on_callback_query(filters.regex(r"language:[\s\S]*")) # type: ignore
async def callback_language(app: PyroClient, callback: CallbackQuery):
user = await app.find_user(callback.from_user)
parsed = CallbackLanguage.from_callback(callback)
await user.update_locale(parsed.language)
await callback.answer(
app._("locale_set", "callbacks", locale=parsed.language).format(
locale=app._("name", "metadata", locale=parsed.language)
),
show_alert=True,
)

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 @@
aiofiles~=23.1.0
apscheduler~=3.10.1
black~=23.3.0
apscheduler~=3.11.0
async_pymongo==0.1.9
convopyro==0.5
pyrogram==2.0.106
tgcrypto==1.2.5
ujson==5.7.0
uvloop==0.17.0
libbot[speed,pyrogram]==4.1.0
tgcrypto-pyrofork==1.2.7
uvloop==0.21.0
# If uses MongoDB:
mongodb-migrations==1.3.1
--extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple
libbot[speed,pyrogram]==0.4
pykeyboard==0.1.7

24
validation/users.json Normal file
View File

@@ -0,0 +1,24 @@
{
"$jsonSchema": {
"required": [
"id",
"locale"
],
"properties": {
"user": {
"bsonType": [
"int",
"long"
],
"description": "Telegram ID of user"
},
"locale": {
"bsonType": [
"string",
"null"
],
"description": "Preferred messages language according to user's preference"
}
}
}
}