aheskandani commited on
Commit
a915bb9
1 Parent(s): 57cf6c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -43
app.py CHANGED
@@ -128,56 +128,13 @@ def cancel(update: Update, context: CallbackContext):
128
 
129
  #############################################
130
 
131
- def create_database(update: Update, context: CallbackContext):
132
- chat_id = update.effective_chat.id
133
- if chat_id == admin:
134
- try:
135
- con.execute('CREATE TABLE USER (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, chatID TEXT, username TEXT, password TEXT)')
136
- update.message.reply_text('دیتابیس با موفقیت ساخته شد', reply_markup=main_keyboard)
137
- except:
138
- update.message.reply_text('دیتابیس قبلا ایجاد شده است', reply_markup=main_keyboard)
139
-
140
-
141
- def show_table(update: Update, context: CallbackContext):
142
- chat_id = update.effective_chat.id
143
- if chat_id == admin:
144
- records = con.execute('SELECT * FROM USER')
145
- table = [', '.join(map(str,user)) for user in records]
146
- text = 'Info\n\n' + '\n'.join(table)
147
- update.message.reply_text(text, reply_markup=main_keyboard)
148
-
149
-
150
- def create_user(chatID, username, password):
151
- con.execute(f'INSERT INTO USER (chatID, username, password) values({chatID}, {username}, {password})')
152
-
153
-
154
- def check_existance(chatID, verbose=True):
155
- records = con.execute('SELECT * FROM USER')
156
- if verbose:
157
- for user in records:
158
- if user[1] == chatID:
159
- return user
160
- return None
161
-
162
-
163
- def update_user(chatID, username, password):
164
- con.execute(f'UPDATE USER (username, password) values({username}, {password}) WHERE chatID = {chatID}')
165
-
166
- #############################################
167
-
168
  if __name__ == '__main__':
169
- # Database
170
- db_url = 'my2-test.db'
171
- db_con = sqlite3.connect(db_url)
172
- con = db_con.cursor()
173
  # Session
174
  session = requests.session()
175
  headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'}
176
  # Bot details
177
  updater = Updater(token=bot_token)
178
  updater.dispatcher.add_handler(CommandHandler('start', start))
179
- updater.dispatcher.add_handler(CommandHandler('db', create_database))
180
- updater.dispatcher.add_handler(CommandHandler('all', show_table))
181
  updater.dispatcher.add_handler(ConversationHandler(
182
  entry_points=[MessageHandler(Filters.regex('ورود به پرتال دانشجویی'), set_info_handler)],
183
  states={
 
128
 
129
  #############################################
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  if __name__ == '__main__':
 
 
 
 
132
  # Session
133
  session = requests.session()
134
  headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'}
135
  # Bot details
136
  updater = Updater(token=bot_token)
137
  updater.dispatcher.add_handler(CommandHandler('start', start))
 
 
138
  updater.dispatcher.add_handler(ConversationHandler(
139
  entry_points=[MessageHandler(Filters.regex('ورود به پرتال دانشجویی'), set_info_handler)],
140
  states={