MCPcopy Create free account
hub / github.com/PastKing/tgbot-verify / get_user

Method get_user

database_mysql.py:189–210  ·  view source on GitHub ↗

获取用户信息

(self, user_id: int)

Source from the content-addressed store, hash-verified

187 conn.close()
188
189 def get_user(self, user_id: int) -> Optional[Dict]:
190 """获取用户信息"""
191 conn = self.get_connection()
192 cursor = conn.cursor(DictCursor)
193
194 try:
195 cursor.execute("SELECT * FROM users WHERE user_id = %s", (user_id,))
196 row = cursor.fetchone()
197
198 if row:
199 # 创建新字典并转换datetime为ISO格式字符串
200 result = dict(row)
201 if result.get('created_at'):
202 result['created_at'] = result['created_at'].isoformat()
203 if result.get('last_checkin'):
204 result['last_checkin'] = result['last_checkin'].isoformat()
205 return result
206 return None
207
208 finally:
209 cursor.close()
210 conn.close()
211
212 def user_exists(self, user_id: int) -> bool:
213 """检查用户是否存在"""

Callers 13

user_existsMethod · 0.95
is_user_blockedMethod · 0.95
deduct_balanceMethod · 0.95
can_checkinMethod · 0.95
addbalance_commandFunction · 0.80
balance_commandFunction · 0.80
checkin_commandFunction · 0.80
use_commandFunction · 0.80
verify_commandFunction · 0.80
verify2_commandFunction · 0.80
verify3_commandFunction · 0.80
verify4_commandFunction · 0.80

Calls 1

get_connectionMethod · 0.95

Tested by

no test coverage detected