RubigramClient 1.6.2__tar.gz → 1.6.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of RubigramClient might be problematic. Click here for more details.
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/PKG-INFO +1 -1
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/RubigramClient.egg-info/PKG-INFO +1 -1
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/pyproject.toml +1 -1
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/rubigram/client.py +0 -4
- rubigramclient-1.6.4/rubigram/state.py +98 -0
- rubigramclient-1.6.2/rubigram/state.py +0 -105
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/LICENSE +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/README.md +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/RubigramClient.egg-info/SOURCES.txt +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/RubigramClient.egg-info/dependency_links.txt +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/RubigramClient.egg-info/requires.txt +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/RubigramClient.egg-info/top_level.txt +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/rubigram/__init__.py +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/rubigram/filters.py +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/rubigram/method.py +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/rubigram/models.py +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/rubigram/network.py +0 -0
- {rubigramclient-1.6.2 → rubigramclient-1.6.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.4
|
|
4
4
|
Summary: A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters.
|
|
5
5
|
Author-email: Javad RZ <Javad.Py1385@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RubigramClient
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.4
|
|
4
4
|
Summary: A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters.
|
|
5
5
|
Author-email: Javad RZ <Javad.Py1385@gmail.com>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "RubigramClient"
|
|
3
|
-
version = "1.6.
|
|
3
|
+
version = "1.6.4"
|
|
4
4
|
description = "A simple and flexible Python library for building advanced Rubika bots with powerful message handling, inline buttons, and custom filters."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.7"
|
|
@@ -70,11 +70,9 @@ class Client(Method):
|
|
|
70
70
|
|
|
71
71
|
async def on_startup(self, app):
|
|
72
72
|
await self.set_endpoints()
|
|
73
|
-
await self.state.start()
|
|
74
73
|
await self.start()
|
|
75
74
|
|
|
76
75
|
async def on_cleanup(self, app):
|
|
77
|
-
await self.state.stop()
|
|
78
76
|
await self.stop()
|
|
79
77
|
|
|
80
78
|
def create_request_handler(self):
|
|
@@ -86,7 +84,6 @@ class Client(Method):
|
|
|
86
84
|
|
|
87
85
|
async def runner(self):
|
|
88
86
|
try:
|
|
89
|
-
await self.state.start()
|
|
90
87
|
while True:
|
|
91
88
|
get_updates = await self.get_update(100, self.offset_id)
|
|
92
89
|
if get_updates.updates:
|
|
@@ -101,7 +98,6 @@ class Client(Method):
|
|
|
101
98
|
except Exception as error:
|
|
102
99
|
print(f"ERROR : {error}")
|
|
103
100
|
finally:
|
|
104
|
-
await self.state.stop()
|
|
105
101
|
await self.stop()
|
|
106
102
|
|
|
107
103
|
def create_app(self, path: str, method: str = "Get"):
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# from aiosqlite import connect as conn, Connection
|
|
2
|
+
# from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# class ManageDB:
|
|
6
|
+
# def __init__(self, database: str):
|
|
7
|
+
# self.database = database
|
|
8
|
+
# self.connection: Optional[Connection] = None
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# async def connect(self):
|
|
12
|
+
# if not self.connection:
|
|
13
|
+
# self.connection = await conn(self.database)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# async def disconnect(self):
|
|
17
|
+
# if self.connection:
|
|
18
|
+
# await self.connection.close()
|
|
19
|
+
# self.connection = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# async def create(self):
|
|
23
|
+
# await self.connect()
|
|
24
|
+
# await self.connection.execute("""CREATE TABLE IF NOT EXISTS states (user_id TEXT PRIMARY KEY, state TEXT)""")
|
|
25
|
+
# await self.connection.execute("CREATE TABLE IF NOT EXISTS user_data (user_id TEXT, var TEXT, res TEXT, PRIMARY KEY (user_id, var))")
|
|
26
|
+
# await self.connection.commit()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# async def set_state(self, user_id: str, state: str) -> None:
|
|
30
|
+
# await self.connect()
|
|
31
|
+
# await self.connection.execute("INSERT INTO states (user_id, state) VALUES (?, ?) ON CONFLICT(user_id) DO UPDATE SET state=excluded.state ", (user_id, str(state)))
|
|
32
|
+
# await self.connection.commit()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# async def get_state(self, user_id: str) -> Optional[str]:
|
|
36
|
+
# await self.connect()
|
|
37
|
+
# async with self.connection.execute("SELECT state FROM states WHERE user_id = ?", (user_id,)) as cursor:
|
|
38
|
+
# data = await cursor.fetchone()
|
|
39
|
+
# return data[0] if data else None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# async def remove_state(self, user_id: str):
|
|
43
|
+
# await self.connect()
|
|
44
|
+
# await self.connection.execute("DELETE FROM states WHERE user_id = ?", (user_id,))
|
|
45
|
+
# await self.connection.commit()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# async def set_data(self, user_id: str, key: str, value: str):
|
|
49
|
+
# await self.connect()
|
|
50
|
+
# await self.connection.execute("INSERT OR REPLACE INTO user_data (user_id, var, res) VALUES (?, ?, ?)", (user_id, key, str(value)))
|
|
51
|
+
# await self.connection.commit()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# async def get_data(self, user_id: str, key: str = None):
|
|
55
|
+
# await self.connect()
|
|
56
|
+
# if key:
|
|
57
|
+
# async with self.connection.execute("SELECT res FROM user_data WHERE user_id = ? AND var = ?", (user_id, key)) as cursor:
|
|
58
|
+
# data = await cursor.fetchone()
|
|
59
|
+
# return data[0] if data else None
|
|
60
|
+
# else:
|
|
61
|
+
# async with self.connection.execute("SELECT var, res FROM user_data WHERE user_id = ?", (user_id,)) as cursor:
|
|
62
|
+
# data = await cursor.fetchall()
|
|
63
|
+
# return {k: v for k, v in data} if data else {}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# async def remove_data(self, user_id: str, key: str = None):
|
|
67
|
+
# await self.connect()
|
|
68
|
+
# if key:
|
|
69
|
+
# await self.connection.execute("DELETE FROM user_data WHERE user_id = ? AND var = ?", (user_id, key))
|
|
70
|
+
# else:
|
|
71
|
+
# await self.connection.execute("DELETE FROM user_data WHERE user_id = ?", (user_id,))
|
|
72
|
+
# await self.connection.commit()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class StateManager:
|
|
76
|
+
def __init__(self):
|
|
77
|
+
self.DATA = {}
|
|
78
|
+
self.STATE = {}
|
|
79
|
+
|
|
80
|
+
async def set_state(self, user_id: str, state: str):
|
|
81
|
+
self.STATE[user_id] = state
|
|
82
|
+
|
|
83
|
+
async def get_state(self, user_id: str):
|
|
84
|
+
return self.STATE.get(user_id)
|
|
85
|
+
|
|
86
|
+
async def remove_state(self, user_id: str):
|
|
87
|
+
self.STATE.pop(user_id, None)
|
|
88
|
+
|
|
89
|
+
async def set_data(self, user_id: str, **data):
|
|
90
|
+
if user_id not in self.DATA:
|
|
91
|
+
self.DATA[user_id] = {}
|
|
92
|
+
self.DATA[user_id].update(data)
|
|
93
|
+
|
|
94
|
+
async def get_data(self, user_id: str, key: str = None):
|
|
95
|
+
return self.DATA.get(user_id, {}).get(key) if key else self.DATA.get(user_id, {})
|
|
96
|
+
|
|
97
|
+
async def remove_data(self, user_id: str, key: str = None):
|
|
98
|
+
self.DATA.get(user_id, {}).pop(key, None) if key else self.DATA.pop(user_id, None)
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
from aiosqlite import connect as conn, Connection
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class ManageDB:
|
|
6
|
-
def __init__(self, database: str):
|
|
7
|
-
self.database = database
|
|
8
|
-
self.connection: Optional[Connection] = None
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
async def connect(self):
|
|
12
|
-
if not self.connection:
|
|
13
|
-
self.connection = await conn(self.database)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async def disconnect(self):
|
|
17
|
-
if self.connection:
|
|
18
|
-
await self.connection.close()
|
|
19
|
-
self.connection = None
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
async def create(self):
|
|
23
|
-
await self.connect()
|
|
24
|
-
await self.connection.execute("""CREATE TABLE IF NOT EXISTS states (user_id TEXT PRIMARY KEY, state TEXT)""")
|
|
25
|
-
await self.connection.execute("CREATE TABLE IF NOT EXISTS user_data (user_id TEXT, var TEXT, res TEXT, PRIMARY KEY (user_id, var))")
|
|
26
|
-
await self.connection.commit()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
async def set_state(self, user_id: str, state: str) -> None:
|
|
30
|
-
await self.connect()
|
|
31
|
-
await self.connection.execute("INSERT INTO states (user_id, state) VALUES (?, ?) ON CONFLICT(user_id) DO UPDATE SET state=excluded.state ", (user_id, str(state)))
|
|
32
|
-
await self.connection.commit()
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
async def get_state(self, user_id: str) -> Optional[str]:
|
|
36
|
-
await self.connect()
|
|
37
|
-
async with self.connection.execute("SELECT state FROM states WHERE user_id = ?", (user_id,)) as cursor:
|
|
38
|
-
data = await cursor.fetchone()
|
|
39
|
-
return data[0] if data else None
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
async def remove_state(self, user_id: str):
|
|
43
|
-
await self.connect()
|
|
44
|
-
await self.connection.execute("DELETE FROM states WHERE user_id = ?", (user_id,))
|
|
45
|
-
await self.connection.commit()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
async def set_data(self, user_id: str, key: str, value: str):
|
|
49
|
-
await self.connect()
|
|
50
|
-
await self.connection.execute("INSERT OR REPLACE INTO user_data (user_id, var, res) VALUES (?, ?, ?)", (user_id, key, str(value)))
|
|
51
|
-
await self.connection.commit()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
async def get_data(self, user_id: str, key: str = None):
|
|
55
|
-
await self.connect()
|
|
56
|
-
if key:
|
|
57
|
-
async with self.connection.execute("SELECT res FROM user_data WHERE user_id = ? AND var = ?", (user_id, key)) as cursor:
|
|
58
|
-
data = await cursor.fetchone()
|
|
59
|
-
return data[0] if data else None
|
|
60
|
-
else:
|
|
61
|
-
async with self.connection.execute("SELECT var, res FROM user_data WHERE user_id = ?", (user_id,)) as cursor:
|
|
62
|
-
data = await cursor.fetchall()
|
|
63
|
-
return {k: v for k, v in data} if data else {}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
async def remove_data(self, user_id: str, key: str = None):
|
|
67
|
-
await self.connect()
|
|
68
|
-
if key:
|
|
69
|
-
await self.connection.execute("DELETE FROM user_data WHERE user_id = ? AND var = ?", (user_id, key))
|
|
70
|
-
else:
|
|
71
|
-
await self.connection.execute("DELETE FROM user_data WHERE user_id = ?", (user_id,))
|
|
72
|
-
await self.connection.commit()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class StateManager:
|
|
76
|
-
def __init__(self):
|
|
77
|
-
self.db = ManageDB("rubigram.db")
|
|
78
|
-
|
|
79
|
-
async def start(self):
|
|
80
|
-
await self.db.create()
|
|
81
|
-
|
|
82
|
-
async def stop(self):
|
|
83
|
-
await self.db.disconnect()
|
|
84
|
-
|
|
85
|
-
async def set_state(self, user_id: str, state: str):
|
|
86
|
-
await self.db.set_state(user_id, state)
|
|
87
|
-
|
|
88
|
-
async def get_state(self, user_id: str):
|
|
89
|
-
return await self.db.get_state(user_id)
|
|
90
|
-
|
|
91
|
-
async def remove_state(self, user_id: str):
|
|
92
|
-
await self.db.remove_state(user_id)
|
|
93
|
-
|
|
94
|
-
async def set_data(self, user_id: str, **data):
|
|
95
|
-
data = list(data.items())
|
|
96
|
-
if not data:
|
|
97
|
-
return
|
|
98
|
-
key, value = data[0]
|
|
99
|
-
await self.db.set_data(user_id, key, value)
|
|
100
|
-
|
|
101
|
-
async def get_data(self, user_id: str, key: str = None):
|
|
102
|
-
return await self.db.get_data(user_id, key)
|
|
103
|
-
|
|
104
|
-
async def remove_data(self, user_id: str, key: str = None):
|
|
105
|
-
await self.db.remove_data(user_id, key)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|