[-] Remove RequestConfiguration class, use dict instead

This commit is contained in:
Hykilpikonna
2020-11-22 15:22:04 -05:00
parent 6105e39821
commit 7554458ed5
4 changed files with 10 additions and 22 deletions
+2 -5
View File
@@ -1,13 +1,10 @@
import json
import logging
import telegram
from telegram.ext import CommandHandler
from telegram.ext import Updater
import logging
import os
from src.commands import *
from src.constants import dbPath, token
from src.constants import token
from src.utils import createCommand
# Main
+2 -3
View File
@@ -1,8 +1,7 @@
import re
from src.database import Database
from src.utils import toJson
from src.request_configuration import RequestConfiguration
from src.utils import toJson, create
helpMsg = """
Welcome! This bot monitors http changes!
@@ -76,7 +75,7 @@ def touch(update, context):
return "*Error:* %s cannot pass the format check" % url
# Create
database.userRequests[user][name] = RequestConfiguration(url)
database.userRequests[user][name] = {'method': 'GET', 'url': url, 'headers': {}, 'data': None}
database.save()
return "%s is successfully created!" % name
-14
View File
@@ -1,14 +0,0 @@
import requests
class RequestConfiguration:
headers = {}
payload = {}
def __init__(self, url, method="GET"):
self.url = url
self.method = method
# Create and execute http request
def create(self):
return requests.request(self.method, self.url, headers=self.headers, data=self.payload)
+6
View File
@@ -1,5 +1,6 @@
import json
import requests
from telegram.ext import CommandHandler
@@ -22,3 +23,8 @@ def createCommand(method):
# Create handler for the wrapper command
return CommandHandler(method.__name__, command, run_async=True)
# Create and execute http request
def create(req):
return requests.request(req['method'], req['url'], headers=req.get('headers', {}), data=req.get('payload', None))