pokealarm / pokealarm

PokeAlarm is a highly configurable application designed to give you complete control over your PokémonGO notifications.
GNU Affero General Public License v3.0
309 stars 323 forks source link

[USER SPECIFIC] Slack notifications ignore my title and body fields in alarms.json config. #197

Closed lmantas closed 8 years ago

lmantas commented 8 years ago

Problem Description

For some reason "title", "url" and "body" fields has no affect after the most recent git pull. I probably just missing something, but I can't figure out why? The notifications are still using the default text for the tile and body, while my alarms.json look like this:

P.S "startup_message" and "startup_list" fields are working fine.

Your Environment

Operating System: Linux, Ubuntu Python Version: Python 2.7.6 PokeAlarm startup command: python runwebhook.py -k ***

Console Output

2016-09-03 00:18:21,769 [    connectionpool] [   INFO] Starting new HTTPS connection (1): maps.googleapis.com
2016-09-03 00:18:21,778 [        runwebhook] [  DEBUG] POST request received from 127.0.0.1.
2016-09-03 00:18:21,779 [            pywsgi] [   INFO] 127.0.0.1 - - [2016-09-03 00:18:21] "POST / HTTP/1.1" 200 115 0.001897
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
2016-09-03 00:18:21,914 [        runwebhook] [  DEBUG] POST request received from 127.0.0.1.
2016-09-03 00:18:21,918 [            pywsgi] [   INFO] 127.0.0.1 - - [2016-09-03 00:18:21] "POST / HTTP/1.1" 200 115 0.004574
2016-09-03 00:18:21,924 [        runwebhook] [  DEBUG] POST request received from 127.0.0.1.
2016-09-03 00:18:21,925 [            pywsgi] [   INFO] 127.0.0.1 - - [2016-09-03 00:18:21] "POST / HTTP/1.1" 200 115 0.001115
2016-09-03 00:18:22,076 [    connectionpool] [  DEBUG] "GET /maps/api/geocode/json?latlng=54.667667%2C25.255902&key=***** HTTP/1.1" 200 1258
2016-09-03 00:18:22,087 [       slack_alarm] [  DEBUG] https://maps.googleapis.com/maps/api/staticmap?center=54.66766694815796,25.255901725693935&markers=color:red%7C54.66766694815796,25.255901725693935&maptype=roadmap&size=250x125&zoom=15&key=*****
2016-09-03 00:18:22,091 [    connectionpool] [   INFO] Starting new HTTPS connection (1): slack.com
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
2016-09-03 00:18:22,295 [        runwebhook] [  DEBUG] POST request received from 127.0.0.1.
2016-09-03 00:18:22,296 [            pywsgi] [   INFO] 127.0.0.1 - - [2016-09-03 00:18:22] "POST / HTTP/1.1" 200 115 0.001366
2016-09-03 00:18:22,306 [        runwebhook] [  DEBUG] POST request received from 127.0.0.1.
2016-09-03 00:18:22,307 [            pywsgi] [   INFO] 127.0.0.1 - - [2016-09-03 00:18:22] "POST / HTTP/1.1" 200 115 0.001262
2016-09-03 00:18:22,313 [        runwebhook] [  DEBUG] POST request received from 127.0.0.1.
2016-09-03 00:18:22,314 [            pywsgi] [   INFO] 127.0.0.1 - - [2016-09-03 00:18:22] "POST / HTTP/1.1" 200 115 0.001130
2016-09-03 00:18:22,508 [    connectionpool] [  DEBUG] "POST /api/chat.postMessage?token=xoxb-72203658726-Lohavc3gGbfZEbo9jLmlglhL HTTP/1.1" 200 370
2016-09-03 00:18:22,515 [     alarm_manager] [  DEBUG] Finished processing for Pokemon #7
2016-09-03 00:18:22,515 [     alarm_manager] [  DEBUG] Request processing for Pokemon #92

Your Alarms Config

        {
            "active": "True",
            "type":"slack",
            "api_key":"*****",
            "channel":"#****",
            "startup_message":"False",
            "startup_list":"False",
            "title":"***** rado <pkmn> (#<id>), adresu: <address>.",
            "url":"<gmaps>",
            "body":"Bus iki <24h_time> (liko: <time_left>)!"
        },
reme-dy commented 8 years ago

@lmantas any errors when you run in debug mode (-d)?

lmantas commented 8 years ago

Oh sorry for not completing the template, I've just updated it.

I do receive one error, which I don't really understand, something about InsecurePlatformWarning (you can see it in my console output). But I've been getting it for a while, and notifications were working fine until I did git pull

reme-dy commented 8 years ago

@lmantas You should have a look at the Slack wiki. Since PokeAlarm now supports pokemon, gyms and pokestop notifications, each one of those have their own sections in alarms.json. Specifically, you'll want to look at the Advanced Configuration section to refamiliarize yourself with the new alarms.json format.

As for the SSL errors, it's probably something specific to your setup and out of the context of PokeAlarm (though someone else might chime in about it.)

lmantas commented 8 years ago

@reme-dy thanks again for your response.

I've looked at Advance Configurations for Slack, but it looks totally different than alarms.json.default so it's a bit confusing, sorry.

Where would I have to insert Pokemon names?

Would that be the right code?

{
    "active": "True",
    "type":"slack",
    "api_key":"YOUR_API_KEY",
    "channel":"general",
    "startup_message":"True",
    "startup_list":"True",
    "pokemon":{
        "Magikarp":"False",
        "Lapras":"True",
    "Ditto":"False",
        "channel":"general",
        "username":"<pkmn>",
        "icon_url" : "https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/<id>.png",
        "title":"A wild <pkmn> has appeared!",
        "url":"<gmaps>",
        "body": "Available until <24h_time> (<time_left>).",
        "map": { 
            "enabled":"true",
            "width":"250",
            "height":"125",
            "maptype":"roadmap",
            "zoom": "15"
        }
reme-dy commented 8 years ago

Try putting your code in a JSON editor (here's an online one) to check if your alarms.json is in the correct format.

Edit: You should only have to edit the alarm section of your alarms.json file.

lmantas commented 8 years ago

Here is my whole JSON file http://www.jsoneditoronline.org/?id=0a1638f7b230be4d5430f6f4f63e1077

Like I said, everything works fine, except those 2 fields: title, body. The notifications use the default text instead.

lmantas commented 8 years ago

Update: I just did a fresh git clone - it didn't solve the problem either.

kvangent commented 8 years ago

You are misunderstanding how the alarm system works. The config on the slack wiki is an example of how to configure the slack alarm only, not the entire alarms.json. The reason your original config doesn't work is because you have to specify which alert type you want to customize. So long story short, start with the alarms.json.default. Copy and paste the advanced slack config over JUST the slack basic config already included. Then make the modifications the way you want them.

kvangent commented 8 years ago

Hopefully to make it more clear, I've included an alarms.json with just a slack config in:

{
    "alarms":[
        {
            "active": "True",
            "type":"slack",
            "api_key":"YOUR_API_KEY",
            "channel":"general",
            "startup_message":"True",
            "startup_list":"True",
            "pokemon":{
                "channel":"general",
                "username":"<pkmn>",
                "icon_url" : "https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/<id>.png",
                "title":"A wild <pkmn> has appeared!",
                "url":"<gmaps>",
                "body": "Available until <24h_time> (<time_left>).",
                "map": { 
                    "enabled":"true",
                    "width":"250",
                    "height":"125",
                    "maptype":"roadmap",
                    "zoom": "15"
                }
            },
            "pokestop":{
                "channel":"general",
                "username":"Pokestop",
                "icon_url" : "https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/pokestop.png",
                "title":"Someone has placed a lure on a Pokestop!",
                "url":"<gmaps>",
                "body":"Lure will expire at <24h_time> (<time_left>)."
            },
            "gym":{
                "channel":"general",
                "username":"Pokemon Gym",
                "icon_url" : "https://raw.githubusercontent.com/kvangent/PokeAlarm/master/icons/gym.png",
                "title":"A Team <old_team> gym has fallen!",
                "url":"<gmaps>",
                "body": "It is now controlled by <new_team>."
            }
        }
    ],
    "gyms":{
        "To_Valor":"False",
        "To_Mystic":"False",
        "To_Instinct":"False",
        "From_Valor":"False",
        "From_Mystic":"False",
        "From_Instinct":"False"
    },
    "pokestops":{
        "Lured":"false"
    },
    "pokemon":{
        "Bulbasaur":"False",
        "Ivysaur":"False",
        "Venusaur":"False",
        "Charmander":"False",
        "Charmeleon":"False",
        "Charizard":"False",
        "Squirtle":"False",
        "Wartortle":"False",
        "Blastoise":"False",
        "Caterpie":"False",
        "Metapod":"False",
        "Butterfree":"False",
        "Weedle":"False",
        "Kakuna":"False",
        "Beedrill":"False",
        "Pidgey":"False",
        "Pidgeotto":"False",
        "Pidgeot":"False",
        "Rattata":"False",
        "Raticate":"False",
        "Spearow":"False",
        "Fearow":"False",
        "Ekans":"False",
        "Arbok":"False",
        "Pikachu":"False",
        "Raichu":"False",
        "Sandshrew":"False",
        "Sandslash":"False",
        "Nidoran♀":"False",
        "Nidorina":"False",
        "Nidoqueen":"False",
        "Nidoran♂":"False",
        "Nidorino":"False",
        "Nidoking":"False",
        "Clefairy":"False",
        "Clefable":"False",
        "Vulpix":"False",
        "Ninetales":"False",
        "Jigglypuff":"False",
        "Wigglytuff":"False",
        "Zubat":"False",
        "Golbat":"False",
        "Oddish":"False",
        "Gloom":"False",
        "Vileplume":"False",
        "Paras":"False",
        "Parasect":"False",
        "Venonat":"False",
        "Venomoth":"False",
        "Diglett":"False",
        "Dugtrio":"False",
        "Meowth":"False",
        "Persian":"False",
        "Psyduck":"False",
        "Golduck":"False",
        "Mankey":"False",
        "Primeape":"False",
        "Growlithe":"False",
        "Arcanine":"False",
        "Poliwag":"False",
        "Poliwhirl":"False",
        "Poliwrath":"False",
        "Abra":"False",
        "Kadabra":"False",
        "Alakazam":"False",
        "Machop":"False",
        "Machoke":"False",
        "Machamp":"False",
        "Bellsprout":"False",
        "Weepinbell":"False",
        "Victreebel":"False",
        "Tentacool":"False",
        "Tentacruel":"False",
        "Geodude":"False",
        "Graveler":"False",
        "Golem":"False",
        "Ponyta":"False",
        "Rapidash":"False",
        "Slowpoke":"False",
        "Slowbro":"False",
        "Magnemite":"False",
        "Magneton":"False",
        "Farfetch'd":"False",
        "Doduo":"False",
        "Dodrio":"False",
        "Seel":"False",
        "Dewgong":"False",
        "Grimer":"False",
        "Muk":"False",
        "Shellder":"False",
        "Cloyster":"False",
        "Gastly":"False",
        "Haunter":"False",
        "Gengar":"False",
        "Onix":"False",
        "Drowzee":"False",
        "Hypno":"False",
        "Krabby":"False",
        "Kingler":"False",
        "Voltorb":"False",
        "Electrode":"False",
        "Exeggcute":"False",
        "Exeggutor":"False",
        "Cubone":"False",
        "Marowak":"False",
        "Hitmonlee":"False",
        "Hitmonchan":"False",
        "Lickitung":"False",
        "Koffing":"False",
        "Weezing":"False",
        "Rhyhorn":"False",
        "Rhydon":"False",
        "Chansey":"False",
        "Tangela":"False",
        "Kangaskhan":"False",
        "Horsea":"False",
        "Seadra":"False",
        "Goldeen":"False",
        "Seaking":"False",
        "Staryu":"False",
        "Starmie":"False",
        "Mr. Mime":"False",
        "Scyther":"False",
        "Jynx":"False",
        "Electabuzz":"False",
        "Magmar":"False",
        "Pinsir":"False",
        "Tauros":"False",
        "Magikarp":"False",
        "Gyarados":"False",
        "Lapras":"False",
        "Ditto":"False",
        "Eevee":"False",
        "Vaporeon":"False",
        "Jolteon":"False",
        "Flareon":"False",
        "Porygon":"False",
        "Omanyte":"False",
        "Omastar":"False",
        "Kabuto":"False",
        "Kabutops":"False",
        "Aerodactyl":"False",
        "Snorlax":"False",
        "Articuno":"False",
        "Zapdos":"False",
        "Moltres":"False",
        "Dratini":"False",
        "Dragonair":"False",
        "Dragonite":"False",
        "Mewtwo":"False",
        "Mew":"False"
    }
}
lmantas commented 8 years ago

@kvangent thanks a lot for helping me. I didn't realize "gym" and "gyms" are different things. Everything works great now. Thanks again for taking your time to help me guys!