@@ -74,8 +74,8 @@ def index(message):
74
74
categoryName = '' .join (categoryName [0 ])
75
75
category = "https://raw.githubusercontent.com/EbookFoundation/free-programming-books/main/" + categoryName
76
76
77
- r = requests .get (category )
78
- f = r .text
77
+ f = requests .get (category )
78
+ f = f .text
79
79
f = f .splitlines ()
80
80
81
81
check = False
@@ -103,15 +103,15 @@ def index(message):
103
103
104
104
@bot .message_handler (commands = ['category' ])
105
105
def select_category (message ):
106
- r = requests .get ("https://raw.githubusercontent.com/EbookFoundation/free-programming-books/main/README.md" )
107
- categoryFile = r .text
108
- categoryFile = categoryFile .replace ("####" , "###" )
109
- categoryFile = categoryFile .splitlines ()
106
+ f = requests .get ("https://raw.githubusercontent.com/EbookFoundation/free-programming-books/main/README.md" )
107
+ f = f .text
108
+ f = f .replace ("####" , "###" )
109
+ f = f .splitlines ()
110
110
111
111
check = False
112
112
text = ""
113
113
114
- for line in categoryFile :
114
+ for line in f :
115
115
if line == "### Books" :
116
116
check = True
117
117
elif line == "### Translations" :
@@ -126,8 +126,6 @@ def select_category(message):
126
126
tmp = re .findall (r'[^\(]+\.md(?=\))' , line )
127
127
text += "`" + tmp [0 ] + "`\n "
128
128
129
- print (text )
130
-
131
129
keyboard = types .InlineKeyboardMarkup (row_width = 1 )
132
130
cancelButton = types .InlineKeyboardButton (text = "Cancel" , callback_data = "cancel" )
133
131
keyboard .add (cancelButton )
@@ -145,22 +143,20 @@ def select_category(message):
145
143
log (message , text )
146
144
147
145
def change_category (message ):
148
- r = requests .get ("https://raw.githubusercontent.com/EbookFoundation/free-programming-books/main/README.md" )
149
- categoryFile = r .text
150
- categoryFile = categoryFile .splitlines ()
146
+ f = requests .get ("https://raw.githubusercontent.com/EbookFoundation/free-programming-books/main/README.md" )
147
+ f = f .text
148
+ f = f .splitlines ()
151
149
152
150
text = "Not correct"
153
151
154
- for line in categoryFile :
152
+ for line in f :
155
153
if re .findall (r'[^\(]+\.md(?=\))' , line ):
156
154
tmp = re .findall (r'[^\(]+\.md(?=\))' , line )
157
155
tmp = "" + str (tmp [0 ])
158
156
if tmp == message .text :
159
157
cursor .execute ('UPDATE fpb SET choice=%s WHERE id=%s;' , (message .text , message .chat .id ,))
160
158
conn .commit ()
161
159
text = "Updated"
162
- print (text )
163
-
164
160
165
161
bot .reply_to (
166
162
message ,
@@ -194,8 +190,8 @@ def print_resource(message):
194
190
category = '' .join (category [0 ])
195
191
category = "https://raw.githubusercontent.com/EbookFoundation/free-programming-books/main/" + category
196
192
197
- r = requests .get (category )
198
- f = r .text
193
+ f = requests .get (category )
194
+ f = f .text
199
195
f = f .replace ("####" , "###" )
200
196
f = f .splitlines ()
201
197
t = message .json
0 commit comments