Exemple #1
0
 def __init__(self):
     self.api = ll.Api()
     self.launches = ll.Launch.fetch(self.api)
     self.properties = self.launches[0].param_names
     self.launch_loc = self.launches[0].location.name
     self.launch_agency = self.launches[0].agency.name
     self.windowStart = self.launches[0].windowstart
     self.rocket = self.launches[0].rocket.name
     self.pic = self.launches
     self.tMinus = self.windowStart-(datetime.now(timezone.utc))
Exemple #2
0
    def __init__(self, bot: Red):
        super().__init__()
        self.bot = bot
        self.config = Config.get_conf(self, identifier=0, force_registration=True)

        default_guild = {}

        self.config.register_guild(**default_guild)

        self.api = ll.Api()
Exemple #3
0
async def on_ready():
    act_def = discord.Activity(type=discord.ActivityType.watching,
                               name='Launch Library')
    if testchannelid:
        testchannel = bot.get_channel(testchannelid)
        await testchannel.send("Launchbot operational!")
    print("Launchbot operational!")

    launch = None
    launchid = None
    alerttime = 30

    while 1:
        global api
        api = launchlibrary.Api()
        launchlist = launchlibrary.Launch.next(api, 1)
        if launchlist:
            launch = launchlist[0]
        if launch:
            launchtime = launch.net
            utc = datetime.now(timezone.utc)
            T = chop_microseconds(launchtime - utc)
            name = 'countdown: {0}'.format(T)
            act_T = discord.Activity(type=discord.ActivityType.watching,
                                     name=name)
            await bot.change_presence(activity=act_T)
            if T < timedelta(minutes=5):
                check = 5
            elif T < timedelta(hours=1):
                check = round(T.total_seconds() / 60)
            elif T < timedelta(hours=2):
                check = 60
            elif T < timedelta(days=1):
                check = 30 * 60
            else:
                check = 60 * 60
                await bot.change_presence(activity=act_def)
            if T < timedelta(minutes=alerttime) and launch.id != launchid:
                alertmsg = await launchalertformatter(launch)
                for channelid in alertchannels:
                    channel = bot.get_channel(channelid)
                    msg = ''
                    if can_notify:
                        msg = notify(msg, channel)
                    else:
                        msg = "Notifying disabled.\n"
                    await channel.send(msg + alertmsg)
                updaterloop = asyncio.create_task(alertupdater(launch))
                await updaterloop
                launchid = launch.id
            await asyncio.sleep(check)
        else:
            await bot.change_presence(activity=act_def)
            await asyncio.sleep(60 * 60)
Exemple #4
0
async def ll_api():
    global llapi

    # Initialize Launch Library API
    llapi = ll.Api(retries=10)
Exemple #5
0
                except:
                    try:
                        Target_XML = Driver.find_element_by_xpath(
                            '//span[@title = "{}"]'.format(Target_Lower))
                        Target_XML.click()
                    except:
                        # If target is not found in any of the above cases
                        print(
                            "Target not found in contacts! Quitting bot in 5... 4... 3... 2... 1...")
                        time.sleep(5)
                        sys.exit()

Msg_For_Info = (f"Greetings {Target_Firstname}! I am RocketBot and I can help with rocket launch info!")
Msg_For_Info1 = "_Following are the rocket launches happening soon ->_"

launchlibrary_api = ll.Api()

# Function to send messages in selected chat


def SendStringMessage(Msg):
    Msg_Box = Driver.find_elements_by_xpath(
        '//div[@class="_3u328 copyable-text selectable-text"]')
    Msg_Box[0].send_keys(Msg)
    Send_Button = Driver.find_elements_by_xpath('//button[@class="_3M-N-"]')
    Send_Button[0].click()

# Function to get and reply weather of city requested


def getweather(City_Name):
Exemple #6
0
can_notify = config['SETTINGS'].getboolean('Can_notify')
keep_message = config['SETTINGS'].getboolean('Keep_message')
# channel settings
alertchannels = config['CHANNELS']['Alertchannels']
if alertchannels:
    alertchannels = alertchannels.split(',')
    alertchannels = list(map(int, alertchannels))
else:
    alertchannels = []
testchannelid = config['CHANNELS']['Testchannel']
if testchannelid:
    testchannelid = int(testchannelid)
else:
    testchannelid = None

api = launchlibrary.Api()
bot = commands.Bot(command_prefix=prefix)


def chop_microseconds(delta):
    return delta - timedelta(microseconds=delta.microseconds)


async def send(ctx, msg, args):
    sent_msg = await ctx.send(msg)


def can_answer(ctx):
    return True

Exemple #7
0
# Import the launchlibrary lib
import launchlibrary as ll
import requests
import json

# Create an instance of the API
api = ll.Api()  # You can also specify api url, api version...

# And request the next 5 launches, for example.
# Any argument after "api" is not constrained (w/ kwargs).
number = 1
url = f"https://launchlibrary.net/1.4/launch?next={number}"
Response = requests.get(url)
Response_JSON = Response.json()
Response_JSON = Response_JSON["launches"]
#print(Response_JSON[1]["name"])
print(Response_JSON)

x = Response_JSON[0]["id"]
url = (f"https://launchlibrary.net/1.4/mission/{x}")
Response = requests.get(url)
Response_JSON = Response.json()
#Response_JSON = Response_JSON["missions"]
#print(Response_JSON[1]["name"])
print(Response_JSON)
"""[Launch(id=1603,name=LauncherOne | Test Flight,tbddate=1,tbdtime=1,status=2,inhold=0,windowstart=2019-08-19 00:00:00+00:00,windowend=2019-08-19 00:00:00+00:00,net=2019-08-19 00:00:00+00:00,info_urls=[],vid_urls=[],holdreason=None,failreason=None,probability=-1,hashtag=None,agency=Agency(id=199,name=Virgin Orbit,abbrev=VO,type=3,country_code=USA,wiki_url=https://en.wikipedia.org/wiki/Virgin_Orbit,info_urls=['https://virginorbit.com/', 'https://twitter.com/virgin_orbit', 'https://www.youtube.com/channel/UCpz2PZJHMLcK7rH_1oup7Sw'],is_lsp=None,changed=2017-02-21 00:00:00),changed=2019-07-16 11:40:56,location=Location(id=39,name=Air launch to orbit,country_code=None,wiki_url=,info_urls=None,pads=[Pad(id=181,name=Mojave Air and Space Port,pad_type=None,latitude=35.059444,longitude=-118.151667,map_url=https://www.google.com/maps/place/35°03'34.0"N+118°09'06.0"W/,retired=None,locationid=None,agencies=None,wiki_url=https://en.wikipedia.org/wiki/Mojave_Air_and_Space_Port,info_urls=None)]),rocket=Rocket(id=173,name=LauncherOne,default_pads=None,family=None,wiki_url=https://en.wikipedia.org/wiki/LauncherOne,info_urls=[],image_url=https://s3.amazonaws.com/launchlibrary/RocketImages/placeholder_1920.png,image_sizes=[320, 480, 640, 720, 768, 800, 960, 1024, 1080, 1280, 1440, 1920]),missions=[{'id': 851, 'name': 'Test Flight', 'description': 'Payload-free test flight of the LauncherOne vehicle.', 'type': 13, 'wikiURL': '', 'typeName': 'Test Flight', 'agencies': [{'id': 199, 'name': 'Virgin Orbit', 'abbrev': 'VO', 'countryCode': 'USA', 'type': 3, 'infoURL': None, 'wikiURL': 'https://en.wikipedia.org/wiki/Virgin_Orbit', 'changed': '2017-02-21 00:00:00', 'infoURLs': ['https://virginorbit.com/', 'https://twitter.com/virgin_orbit', 'https://www.youtube.com/channel/UCpz2PZJHMLcK7rH_1oup7Sw']}], 'payloads': []}])]"""