Skip to content

Instantly share code, notes, and snippets.

@Lenart12
Created July 24, 2020 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lenart12/b2f198355f1179ffead4b3d4a4bf613b to your computer and use it in GitHub Desktop.
Save Lenart12/b2f198355f1179ffead4b3d4a4bf613b to your computer and use it in GitHub Desktop.
# Add in crontab to run once per hour
import requests
import json
import jsondiff
import discord
from discord.ext import commands
import pprint
trello_url = 'https://trello.com/1/Boards/12AMfhIv'
get_params = {'lists' : 'open',
'list_fields' : 'name,closed,idBoard,pos,subscribed,limits,creationMethod,softLimit',
'cards' : 'visible',
'card_attachments' : 'cover',
'card_stickers' : 'true',
'card_fields' : 'badges,closed,dateLastActivity,desc,descData,due,dueComplete,dueReminder,idAttachmentCover,idList,idBoard,idMembers,idShort,idLabels,limits,name,pos,shortUrl,shortLink,subscribed,url,locationName,address,coordinates,cover,isTemplate,labels',
'card_checklists' : 'none',
'enterprise' : 'true',
'enterprise_fields' : 'displayName',
'members' : 'all',
'member_fields' : 'activityBlocked,avatarUrl,bio,bioData,confirmed,fullName,idEnterprise,idMemberReferrer,initials,memberType,nonPublic,products,url,username',
'membersInvited' : 'all',
'membersInvited_fields' : 'activityBlocked,avatarUrl,bio,bioData,confirmed,fullName,idEnterprise,idMemberReferrer,initials,memberType,nonPublic,products,url,username',
'memberships_orgMemberType' : 'true',
'checklists' : 'none',
'organization' : 'true',
'organization_fields' : 'name,displayName,desc,descData,url,website,prefs,memberships,logoHash,products,limits,idEnterprise',
'organization_tags' : 'true',
'organization_enterprise' : 'true',
'organization_disable_mock' : 'true',
'myPrefs' : 'true',
'fields' : 'name,closed,dateLastActivity,dateLastView,datePluginDisable,enterpriseOwned,idOrganization,prefs,premiumFeatures,shortLink,shortUrl,url,creationMethod,idEnterprise,desc,descData,idTags,invitations,invited,labelNames,limits,memberships,powerUps,subscribed,templateGallery'
}
resp = requests.get(trello_url, params=get_params)
data = resp.json()
with open('squad_roadmap.json', 'r') as fh:
old_data = json.load(fh)
diff = jsondiff.diff(old_data, data)
bot = commands.Bot(command_prefix='praise sphere')
@bot.event
async def on_ready():
print(f'New update found')
# Lenart#Botlog , Shed#general
for channel_id in [528356916410187789, 544453865794306062]:
try:
channel = bot.get_channel(channel_id)
await channel.send(f'**Roadmap has changed**\n```py\n{pprint.pformat(diff)}\n```')
except:
pass
await bot.close()
if len(diff) > 0:
with open('squad_roadmap.json', 'w') as fh:
json.dump(data, fh)
bot.run('token')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment