Customise messages and add extra error checking
This commit is contained in:
parent
707f23f2e3
commit
f6da15decd
|
@ -6,6 +6,7 @@ from twisted.internet.task import LoopingCall
|
||||||
from json import loads
|
from json import loads
|
||||||
from forex_python.converter import CurrencyRates
|
from forex_python.converter import CurrencyRates
|
||||||
from agoradesk_py.agoradesk import AgoraDesk
|
from agoradesk_py.agoradesk import AgoraDesk
|
||||||
|
from httpx import ReadTimeout
|
||||||
|
|
||||||
# Project imports
|
# Project imports
|
||||||
from settings import settings
|
from settings import settings
|
||||||
|
@ -62,7 +63,10 @@ class Agora(object):
|
||||||
self.dashboard_hook(dash_tmp)
|
self.dashboard_hook(dash_tmp)
|
||||||
|
|
||||||
# Get recent messages
|
# Get recent messages
|
||||||
|
try:
|
||||||
self.get_recent_messages()
|
self.get_recent_messages()
|
||||||
|
except ReadTimeout:
|
||||||
|
pass
|
||||||
return dash_tmp
|
return dash_tmp
|
||||||
|
|
||||||
def get_dashboard(self):
|
def get_dashboard(self):
|
||||||
|
@ -78,6 +82,8 @@ class Agora(object):
|
||||||
Post new trades to IRC and cache trades for the future.
|
Post new trades to IRC and cache trades for the future.
|
||||||
"""
|
"""
|
||||||
current_trades = []
|
current_trades = []
|
||||||
|
if not dash.items():
|
||||||
|
return
|
||||||
for contact_id, contact in dash.items():
|
for contact_id, contact in dash.items():
|
||||||
reference = self.tx.tx_to_ref(contact_id)
|
reference = self.tx.tx_to_ref(contact_id)
|
||||||
if reference:
|
if reference:
|
||||||
|
@ -260,7 +266,14 @@ class Agora(object):
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
ad = settings.Agora.Ad
|
ad = settings.Agora.Ad
|
||||||
|
paymentdetails = settings.Agora.PaymentDetails
|
||||||
ad = ad.replace("$CURRENCY$", currency)
|
ad = ad.replace("$CURRENCY$", currency)
|
||||||
|
if countrycode == "GB" and currency == "GBP":
|
||||||
|
adtext = ad.replace("$PAYMENT$", settings.Agora.GBPDetailsAd)
|
||||||
|
paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.GBPDetailsPayment)
|
||||||
|
else:
|
||||||
|
adtext = ad.replace("$PAYMENT$", settings.Agora.DefaultDetailsAd)
|
||||||
|
paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.DefaultDetailsPayment)
|
||||||
rates = self.get_rates_all()
|
rates = self.get_rates_all()
|
||||||
if currency == "USD":
|
if currency == "USD":
|
||||||
min_amount = float(settings.Agora.MinUSD)
|
min_amount = float(settings.Agora.MinUSD)
|
||||||
|
@ -282,12 +295,12 @@ class Agora(object):
|
||||||
require_trusted_by_advertiser=False,
|
require_trusted_by_advertiser=False,
|
||||||
# verified_email_required = False,
|
# verified_email_required = False,
|
||||||
online_provider="REVOLUT",
|
online_provider="REVOLUT",
|
||||||
msg=settings.Agora.Ad,
|
msg=adtext,
|
||||||
min_amount=min_amount,
|
min_amount=min_amount,
|
||||||
max_amount=max_amount,
|
max_amount=max_amount,
|
||||||
payment_method_details=settings.Agora.PaymentMethodDetails,
|
payment_method_details=settings.Agora.PaymentMethodDetails,
|
||||||
# require_feedback_score = 0,
|
# require_feedback_score = 0,
|
||||||
account_info=settings.Agora.PaymentDetails,
|
account_info=paymentdetailstext,
|
||||||
)
|
)
|
||||||
return ad
|
return ad
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class IRCCommands(object):
|
||||||
if posted["success"]:
|
if posted["success"]:
|
||||||
msg(f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}")
|
msg(f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}")
|
||||||
else:
|
else:
|
||||||
msg(posted["response"]["data"]["message"])
|
msg(dumps(posted["response"]))
|
||||||
|
|
||||||
class messages(object):
|
class messages(object):
|
||||||
name = "messages"
|
name = "messages"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from twisted.logger import Logger
|
from twisted.logger import Logger
|
||||||
from twisted.words.protocols import irc
|
from twisted.words.protocols import irc
|
||||||
from twisted.internet import protocol, reactor, ssl
|
from twisted.internet import protocol, reactor, ssl
|
||||||
|
from twisted.internet.task import deferLater
|
||||||
|
|
||||||
# Project imports
|
# Project imports
|
||||||
from settings import settings
|
from settings import settings
|
||||||
|
@ -115,7 +116,7 @@ class IRCBot(irc.IRCClient):
|
||||||
Join our channel.
|
Join our channel.
|
||||||
"""
|
"""
|
||||||
self.log.info("Signed on as %s" % (self.nickname))
|
self.log.info("Signed on as %s" % (self.nickname))
|
||||||
self.join(self.channel)
|
deferLater(reactor, 2, self.join, self.channel)
|
||||||
|
|
||||||
def joined(self, channel):
|
def joined(self, channel):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -42,6 +42,9 @@ class Transactions(object):
|
||||||
|
|
||||||
inside = data["data"]
|
inside = data["data"]
|
||||||
txid = inside["id"]
|
txid = inside["id"]
|
||||||
|
if "type" not in inside:
|
||||||
|
self.log.error("Type not in inside: {inside}", inside=inside)
|
||||||
|
return
|
||||||
txtype = inside["type"]
|
txtype = inside["type"]
|
||||||
state = inside["state"]
|
state = inside["state"]
|
||||||
if "reference" in inside:
|
if "reference" in inside:
|
||||||
|
|
Loading…
Reference in New Issue