Author Topic: [Guide] Get Weather for Given Location  (Read 3895 times)

0 Members and 1 Guest are viewing this topic.

TheDefiant604

  • Youngling
  • *
  • Posts: 21
  • Karma: +0/-0
    • View Profile
  • Twitch Name: TheDefiant604
[Guide] Get Weather for Given Location
« on: August 10, 2016, 10:14:05 AM »
Here's a command I created that can check the weather for a given location, and will return an error if not enough information is provided.

This command consists of two nested @if@ tests, basically looking for a city and country code.
  • The first test checks if anything was provided to the command and returns help/about text if nothing was provided.  If a city was provided, it moves on to the second test.
  • The second test checks to see if a country code was provided and returns an error if one was not provided.  If a country code was provided, it moves on to providing the weather.

NOTE: This command does not check for the validity of the information provided.  That's up to DeepBot to handle.  Literally anything can be provided, and DeepBot seems to take the first two characters of whatever is provided as the country code if it's unsure.  For example, providing "junk data" to the command seems to have returned weather for somewhere in Denmark, as "DA" is a valid NATO or FIPS 2-letter code for Denmark1.

Code: [Select]
!addcmd !myweather @if@[@target@[1]||||Get your local weather by providing a city and country code. Example: !myweather Copenhagen DNK||@if@[@target@[2]||||Missing Country Code. Refer to https://en.wikipedia.org/wiki/Country_code for codes.||@weather@[@target@[1], @target@[2]]]]
Reference:
1. Country codes: D–E (Wikipedia)
Chat Moderator for RandomRambo

emrerocky

  • Advisor
  • Councilor
  • **
  • Posts: 1240
  • Karma: +163/-8
    • View Profile
    • emrerocky's Website
  • Twitch Name: emrerocky
Re: [Guide] Get Weather for Given Location
« Reply #1 on: August 10, 2016, 01:53:16 PM »
There is actually a prebuilt @weather@ variable which can be used and set up like this:



and to use the command:


TheDefiant604

  • Youngling
  • *
  • Posts: 21
  • Karma: +0/-0
    • View Profile
  • Twitch Name: TheDefiant604
Re: [Guide] Get Weather for Given Location
« Reply #2 on: August 11, 2016, 08:13:04 AM »
There is actually a prebuilt @weather@ variable which can be used and set up like this:

I know. That's the variable I'm using, at the very end of the @if@ statements that check to see if anything was provided.

On a side note, you also demonstrated the flaw in taking input from the !-command line: cities with more than one word in their name.
Chat Moderator for RandomRambo