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