@@ -54,7 +54,6 @@ def __init__(self, **kwargs):
5454 self .debug = kwargs .get ("debug" , False )
5555
5656 self .config_file = kwargs .get ("config_file" , "data/config.json" )
57- self .stats_file = kwargs .get ("stats_file" , "data/stats.json" )
5857 self .database = kwargs .get ("database" , "data/data.db" )
5958
6059 self .quiet = kwargs .get ("quiet" , False )
@@ -90,23 +89,6 @@ def load_config(self, filename):
9089 raise FileNotFoundError ("Configuration file not found." )
9190 exit ()
9291
93- def load_stats (self , filename ):
94- """Load statistics file."""
95-
96- self .logger .warning ("Statistics are not yet implemented." )
97- return dict ()
98-
99- if exists (filename ):
100- self .stats_file = filename
101- self .logger .info ("Statistics file found. Loading..." )
102- with open (filename ) as stats :
103- self .stats = load (stats )
104- return self .stats
105- else :
106- self .logger .warn ("Statistics file not found. Creating..." )
107- copyfile ("data/stats-template.json" , "data/stats.json" )
108- self .logger .info ("Statistics file created." )
109-
11092 def update_config (self , keys , value ):
11193 """Update configuration file value."""
11294
@@ -119,33 +101,18 @@ def update_config(self, keys, value):
119101 self .config = config_data
120102 return self .config
121103
122- def update_stats (self , keys , value ):
123- """Update statistics file value."""
124-
125- self .logger .warning ("Statistics are not yet implemented." )
126- return
127-
128- with open (self .stats_file , 'r' ) as stats :
129- stats_data = load (stats )
130- reduce (lambda d , k : d [k ], keys .split ('.' )[:- 1 ], stats_data )[
131- keys .split ('.' )[- 1 ]] = value
132- with open (self .stats_file , 'w+' ) as stats :
133- dump (stats_data , stats , indent = 2 , sort_keys = True )
134- self .stats = stats_data
135- return self .stats
136-
137104 def run (self , * args , ** kwargs ):
138105 """Run bot."""
139106
140107 self .logger .info (cactus_art )
141108 self ._init_database (self .database )
142109 self .load_config (filename = self .config_file )
143- self .load_stats (filename = self .stats_file )
144110 self .started = True
145111
146112 while self .config .get ("autorestart" ) or not self .started :
147113 try :
148114 self .bot_data = self .login (** self .config ["auth" ])
115+ self .bot_name = self .config ["auth" ]["username" ]
149116 self .logger .info ("Authenticated as: {}." .format (
150117 self .bot_data ["username" ]))
151118
0 commit comments