Skip to content

Commit

Permalink
Add error correction and suggestions in parameter search
Browse files Browse the repository at this point in the history
  • Loading branch information
hemantapkh committed Oct 5, 2021
1 parent 648e7af commit 6956810
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Torrent Hunt Bot is a telegram bot to search and explore torrents from different
- Supports inline query with thumbnail
- Restriction mode to hide explicit content
- Directly add the torrent in your [seedr](https://seedr.cc) account
- Auto typo correction and suggestions

# 🗣️ Languages

Expand Down Expand Up @@ -132,6 +133,8 @@ See [LICENSE](LICENSE) for more information.
"database": "torrenthunt.sqlite",
"magnetDatabase": "magnets.sqlite",
"cache": "cache",
"cacheTime": 86400,
Expand Down
10 changes: 3 additions & 7 deletions src/commands/start.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import base64
from src.objs import *
from src.functions.resultParser import result
from src.commands.querySearch import querySearch
from src.functions.keyboard import mainReplyKeyboard, lang

#: Start handler
Expand All @@ -13,14 +13,10 @@ def start(message):
#! If start paramater is passed
if params:
try:
text = base64.b64decode(params.encode('utf')).decode('utf')
sent = bot.send_message(message.chat.id, language['searchingQuery'][userLanguage].format(text))
response = torrent.search(text)
message.text = base64.b64decode(params.encode('utf')).decode('utf')

msg, markup = result(response, userLanguage, torrentType='query', page=1, query=text)
querySearch(message, userLanguage)

bot.edit_message_text(chat_id=message.chat.id, message_id=sent.message_id, text=msg or language['noResults'][userLanguage], reply_markup=markup)

except Exception:
bot.send_message(message.chat.id, text=language['greet'][userLanguage].format(message.from_user.first_name), reply_markup=mainReplyKeyboard(userLanguage), disable_web_page_preview=True)
else:
Expand Down
2 changes: 0 additions & 2 deletions src/objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from models import dbQuery

import telebot, py1337x
from tpblite import TPB

#! Finding the absolute path of the config file
scriptPath = path.abspath(__file__)
Expand All @@ -15,7 +14,6 @@
dbSql = dbQuery(config['database'], config['magnetDatabase'])

torrent = py1337x.py1337x(proxy='1337x.to', cache=config['cache'], cacheTime=config['cacheTime'])
pirateBay = TPB()

botId = config['botToken'].split(':')[0]
bot = telebot.TeleBot(config['botToken'], parse_mode='HTML')
2 changes: 2 additions & 0 deletions src/sample-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

"database": "torrenthunt.sqlite",

"magnetDatabase": "magnets.sqlite",

"cache": "cache",

"cacheTime": 86400,
Expand Down

0 comments on commit 6956810

Please sign in to comment.