This repository was archived by the owner on Jul 8, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Expand file tree Collapse file tree 3 files changed +31
-9
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1111from mahjong .tile import TilesConverter
1212
1313from game .client import Client
14- from game .stat import Statistics
1514from tenhou .decoder import TenhouDecoder
1615
1716from utils .settings_handler import settings
17+ from utils .statistics import Statistics
1818
1919logger = logging .getLogger ('tenhou' )
2020
@@ -171,12 +171,15 @@ def start_game(self):
171171 self .looking_for_game = False
172172 game_id , seat = self .decoder .parse_log_link (message )
173173 log_link = 'http://tenhou.net/0/?log={}&tw={}' .format (game_id , seat )
174+
174175 self .statistics .game_id = game_id
175176
176177 if '<UN' in message :
177178 values = self .decoder .parse_names_and_ranks (message )
178179 self .table .set_players_names_and_ranks (values )
179180
181+ self .statistics .username = values [0 ]['name' ]
182+
180183 if '<LN' in message :
181184 self ._send_message (self ._pxr_tag ())
182185
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ import requests
3+
4+ from utils .settings_handler import settings
5+
6+
7+ class Statistics (object ):
8+ """
9+ Send data to https://github.com/MahjongRepository/mahjong-stat/ project
10+ """
11+ game_id = ''
12+ username = ''
13+
14+ def send_statistics (self ):
15+ url = settings .STAT_SERVER_URL
16+ if not url or not self .game_id :
17+ return False
18+
19+ url = '{0}/api/v1/tenhou/game/add/' .format (url )
20+ data = {
21+ 'id' : self .game_id ,
22+ 'username' : self .username
23+ }
24+
25+ result = requests .post (url , data , headers = {'Token' : settings .STAT_TOKEN })
26+
27+ return result .status_code == 200 and result .json ()['success' ]
You can’t perform that action at this time.
0 commit comments