blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
616
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
112
license_type
stringclasses
2 values
repo_name
stringlengths
5
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
777 values
visit_date
timestamp[us]date
2015-08-06 10:31:46
2023-09-06 10:44:38
revision_date
timestamp[us]date
1970-01-01 02:38:32
2037-05-03 13:00:00
committer_date
timestamp[us]date
1970-01-01 02:38:32
2023-09-06 01:08:06
github_id
int64
4.92k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-04 01:52:49
2023-09-14 21:59:50
gha_created_at
timestamp[us]date
2008-05-22 07:58:19
2023-08-21 12:35:19
gha_language
stringclasses
149 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
3
10.2M
extension
stringclasses
188 values
content
stringlengths
3
10.2M
authors
sequencelengths
1
1
author_id
stringlengths
1
132
746cd2a1f61ed05f5602945dce3850c3f41e5e4a
f0b741f24ccf8bfe9bd1950425d83b6291d21b10
/components/google-cloud/google_cloud_pipeline_components/v1/dataproc/__init__.py
c23660af80759e169b3e288ffbefe38ceaaff513
[ "Apache-2.0" ]
permissive
kubeflow/pipelines
e678342b8a325559dec0a6e1e484c525fdcc8ce8
3fb199658f68e7debf4906d9ce32a9a307e39243
refs/heads/master
2023-09-04T11:54:56.449867
2023-09-01T19:07:33
2023-09-01T19:12:27
133,100,880
3,434
1,675
Apache-2.0
2023-09-14T20:19:06
2018-05-12T00:31:47
Python
UTF-8
Python
false
false
1,424
py
# Copyright 2023 The Kubeflow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Create [Google Cloud Dataproc](https://cloud.google.com/dataproc) jobs from within Vertex AI Pipelines.""" from google_cloud_pipeline_components.v1.dataproc.create_pyspark_batch.component import dataproc_create_pyspark_batch as DataprocPySparkBatchOp from google_cloud_pipeline_components.v1.dataproc.create_spark_batch.component import dataproc_create_spark_batch as DataprocSparkBatchOp from google_cloud_pipeline_components.v1.dataproc.create_spark_r_batch.component import dataproc_create_spark_r_batch as DataprocSparkRBatchOp from google_cloud_pipeline_components.v1.dataproc.create_spark_sql_batch.component import dataproc_create_spark_sql_batch as DataprocSparkSqlBatchOp __all__ = [ 'DataprocPySparkBatchOp', 'DataprocSparkBatchOp', 'DataprocSparkRBatchOp', 'DataprocSparkSqlBatchOp', ]
2c593f0c394889b99375a489bc508ced79208a18
f56e4bb2d3a91b068292d698388ac5e82a40f078
/inkshop/apps/utils/backends.py
cda1f8bb15efed905ac26e68ae9fc2365ccc9452
[]
no_license
inkandfeet/inkshop
979064eb902c86dc95a6399e79ac753efbe547d1
691187b3eb4435782f8054e6404f1203e7d0c383
refs/heads/master
2022-12-13T01:26:02.361970
2021-11-18T23:01:50
2021-11-18T23:01:50
175,481,726
1
1
null
2022-12-08T04:59:16
2019-03-13T18:59:17
Python
UTF-8
Python
false
false
957
py
from django import forms from clubhouse.models import StaffMember from people.models import Person from utils.encryption import lookup_hash, encrypt, decrypt, create_unique_hashid class EncryptedEmailBackend(object): def authenticate(self, request, username=None, password=None): try: try: user = StaffMember.objects.get(hashed_email=lookup_hash(username)) if user.check_password(password): return user except StaffMember.DoesNotExist: user = Person.objects.get(hashed_email=lookup_hash(username)) if user.check_password(password): return user except: pass return None def get_user(self, user_id): try: return StaffMember.objects.get(pk=user_id) except StaffMember.DoesNotExist: return Person.objects.get(pk=user_id) return None
409269bf410dd87f111fadf453c8172aae0618ac
8cce087dfd5c623c2f763f073c1f390a21838f0e
/projects/peewee/test.py
ba9b8ff8eecd577b954ce29252989a847b2bcfe9
[ "Unlicense" ]
permissive
quinn-dougherty/python-on-nix
b2ae42761bccf7b3766999b27a4674310e276fd8
910d3f6554acd4a4ef0425ebccd31104dccb283c
refs/heads/main
2023-08-23T11:57:55.988175
2021-09-24T05:55:00
2021-09-24T05:55:00
414,799,752
0
0
null
null
null
null
UTF-8
Python
false
false
14
py
import peewee
bb79daf3dda133c0387011855c40ce27cc0bc132
97e557d328b89adbd1459f8988a12ec3a9f4adc7
/ns1/datadog_checks/ns1/__init__.py
e6ee0076e28c1760bc143ed9385daa9cad5827cf
[]
permissive
DataDog/integrations-extras
1b9c9928af4e5a146b9611aed29db206f420710c
1d20f8d945ef802fa6e01b41b6ba99148ac508a4
refs/heads/master
2023-08-31T04:01:33.555722
2023-08-30T18:51:09
2023-08-30T18:51:09
51,574,196
221
667
BSD-3-Clause
2023-09-14T16:07:56
2016-02-12T07:55:28
Python
UTF-8
Python
false
false
102
py
from .__about__ import __version__ from .check import Ns1Check __all__ = ['__version__', 'Ns1Check']
f78ba8a25ebbd41be29ce2d6501d489551150f9a
24fe1f54fee3a3df952ca26cce839cc18124357a
/servicegraph/lib/python2.7/site-packages/acimodel-4.0_3d-py2.7.egg/cobra/modelimpl/vns/absfuncprof.py
bde147c5e65f17edfa4d8e6747546184254ddc72
[]
no_license
aperiyed/servicegraph-cloudcenter
4b8dc9e776f6814cf07fe966fbd4a3481d0f45ff
9eb7975f2f6835e1c0528563a771526896306392
refs/heads/master
2023-05-10T17:27:18.022381
2020-01-20T09:18:28
2020-01-20T09:18:28
235,065,676
0
0
null
2023-05-01T21:19:14
2020-01-20T09:36:37
Python
UTF-8
Python
false
false
16,992
py
# coding=UTF-8 # ********************************************************************** # Copyright (c) 2013-2019 Cisco Systems, Inc. All rights reserved # written by zen warriors, do not modify! # ********************************************************************** from cobra.mit.meta import ClassMeta from cobra.mit.meta import StatsClassMeta from cobra.mit.meta import CounterMeta from cobra.mit.meta import PropMeta from cobra.mit.meta import Category from cobra.mit.meta import SourceRelationMeta from cobra.mit.meta import NamedSourceRelationMeta from cobra.mit.meta import TargetRelationMeta from cobra.mit.meta import DeploymentPathMeta, DeploymentCategory from cobra.model.category import MoCategory, PropCategory, CounterCategory from cobra.mit.mo import Mo # ################################################## class AbsFuncProf(Mo): """ An abstract function profile includes the abstract device configuration, the abstract group configuration, and the abstract function configuration. These are analogous to the function configuration, group configuration, and device configuration within a device. """ meta = ClassMeta("cobra.model.vns.AbsFuncProf") meta.moClassName = "vnsAbsFuncProf" meta.rnFormat = "absFuncProf-%(name)s" meta.category = MoCategory.REGULAR meta.label = "L4-L7 Services Function Profile" meta.writeAccessMask = 0x2000000000000001 meta.readAccessMask = 0x6000000000000001 meta.isDomainable = False meta.isReadOnly = False meta.isConfigurable = True meta.isDeletable = True meta.isContextRoot = False meta.childClasses.add("cobra.model.tag.Tag") meta.childClasses.add("cobra.model.fault.Counts") meta.childClasses.add("cobra.model.health.Inst") meta.childClasses.add("cobra.model.vns.RsProfToCloudModeMDev") meta.childClasses.add("cobra.model.fault.Inst") meta.childClasses.add("cobra.model.vns.RtNodeToAbsFuncProf") meta.childClasses.add("cobra.model.vns.AbsGrpCfg") meta.childClasses.add("cobra.model.aaa.RbacAnnotation") meta.childClasses.add("cobra.model.vns.AbsFuncCfg") meta.childClasses.add("cobra.model.vns.RsProfToMFunc") meta.childClasses.add("cobra.model.vns.RtToFuncProfile") meta.childClasses.add("cobra.model.vns.AbsDevCfg") meta.childClasses.add("cobra.model.vns.RtAbsFuncProf") meta.childClasses.add("cobra.model.vns.ConfIssue") meta.childClasses.add("cobra.model.fault.Delegate") meta.childClasses.add("cobra.model.tag.Annotation") meta.childNamesAndRnPrefix.append(("cobra.model.vns.RsProfToCloudModeMDev", "rsProfToCloudModeMDev")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.RtToFuncProfile", "rtorchsToFuncProfile-")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.RtNodeToAbsFuncProf", "rtnodeToAbsFuncProf-")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.RtAbsFuncProf", "rtabsFuncProf-")) meta.childNamesAndRnPrefix.append(("cobra.model.tag.Annotation", "annotationKey-")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.RsProfToMFunc", "rsProfToMFunc")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.ConfIssue", "vnsConfIssue-")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.AbsFuncCfg", "absFuncCfg")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.AbsGrpCfg", "absGrpCfg")) meta.childNamesAndRnPrefix.append(("cobra.model.vns.AbsDevCfg", "absDevCfg")) meta.childNamesAndRnPrefix.append(("cobra.model.aaa.RbacAnnotation", "rbacDom-")) meta.childNamesAndRnPrefix.append(("cobra.model.tag.Tag", "tagKey-")) meta.childNamesAndRnPrefix.append(("cobra.model.fault.Counts", "fltCnts")) meta.childNamesAndRnPrefix.append(("cobra.model.health.Inst", "health")) meta.childNamesAndRnPrefix.append(("cobra.model.fault.Inst", "fault-")) meta.childNamesAndRnPrefix.append(("cobra.model.fault.Delegate", "fd-")) meta.parentClasses.add("cobra.model.vns.AbsFuncProfGrp") meta.superClasses.add("cobra.model.naming.NamedObject") meta.superClasses.add("cobra.model.pol.Obj") meta.superClasses.add("cobra.model.pol.Def") meta.rnPrefixes = [ ('absFuncProf-', True), ] prop = PropMeta("str", "annotation", "annotation", 37962, PropCategory.REGULAR) prop.label = "Annotation. Suggested format orchestrator:value" prop.isConfig = True prop.isAdmin = True prop.range = [(0, 128)] prop.regex = ['[a-zA-Z0-9_.:-]+'] meta.props.add("annotation", prop) prop = PropMeta("str", "childAction", "childAction", 4, PropCategory.CHILD_ACTION) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop._addConstant("deleteAll", "deleteall", 16384) prop._addConstant("deleteNonPresent", "deletenonpresent", 8192) prop._addConstant("ignore", "ignore", 4096) meta.props.add("childAction", prop) prop = PropMeta("str", "configInfo", "configInfo", 18076, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.range = [(0, 512)] meta.props.add("configInfo", prop) prop = PropMeta("str", "configIssues", "configIssues", 5015, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 0 prop.defaultValueStr = "ok" prop._addConstant("arp-flood-enabled", "arp-flood-is-enabled-on-the-management-end-point-group", 35184372088832) prop._addConstant("cdev-missing-cif", "no-interface-defined.-it-must-have-at-least-one-interface-defined", 17179869184) prop._addConstant("cdev-missing-mgmt-ip", "no-mgmt-ip-found-for-cdev", 2097152) prop._addConstant("cdev-missing-path-for-interface", "missing-path-for-interface.", 34359738368) prop._addConstant("cdev-missing-virtual-info", "virtual-object-info-like-vcenter-name-and-vm-name-is-missing-in-cdev", 4503599627370496) prop._addConstant("cif-missing-virtual-info", "virtual-object-like-vnic-name-is-missing-in-cif", 72057594037927936) prop._addConstant("context-cardinality-violation-failure", "invalid-cluster-context-cardinality", 128) prop._addConstant("devfolder-validation-failed", "devfolder-has-key,-that-is-not-found-in-mfolder", 1125899906842624) prop._addConstant("devparam-validation-failed", "devparam-has-key-and/or-value,-that-are-not-found-in-mparam", 2251799813685248) prop._addConstant("epp-download-failure", "epp-download-failure", 8) prop._addConstant("folderinst-validation-failed", "folderinst-has-key,-that-is-not-found-in-mfolder", 70368744177664) prop._addConstant("function-type-mismatch-failure", "invalid-function-type", 256) prop._addConstant("gothrough-routing-enabled-both", "both-the-legs-of-go-through-node-has-routing-enabled", 4398046511104) prop._addConstant("gothru-same-bd", "both-the-legs-of-go-through-node-are-attached-to-same-bd", 4611686018427387904) prop._addConstant("graph-loop-detected", "service-graph-template-configuration-is-invalid.-it-has-a-loop", 2199023255552) prop._addConstant("id-allocation-failure", "id-allocation-failure", 32) prop._addConstant("inappropriate-devfolder", "illegal-folder-in-configuration.", 2147483648) prop._addConstant("insufficient-devctx", "folder-must-have-one-value-for-each-associated-cdev.", 8589934592) prop._addConstant("internal-error", "internal-error-occured-during-graph-processing.`", 65536) prop._addConstant("invalid-absfunc-profile", "service-graph-template-function-profile-config-is-invalid.", 536870912) prop._addConstant("invalid-abstract-graph-config", "invalid-abstract-graph-config", 1) prop._addConstant("invalid-abstract-graph-config-param", "invalid-abstract-graph-config-param", 512) prop._addConstant("invalid-config", "configuration-of-this-device-contains-errors", 1152921504606846976) prop._addConstant("invalid-conn-for-configparam", "config-param-is-using-an-invalid-graph-connector.", 18014398509481984) prop._addConstant("invalid-connection", "absgraph-connection-is-invalid.", 36028797018963968) prop._addConstant("invalid-devcfg-folder", "devcfg-folder-has-invalid-configuration-parameters.", 2305843009213693952) prop._addConstant("invalid-devctx", "device-context-is-not-valid-for-this-folder.", 4294967296) prop._addConstant("invalid-filter-referred-by-rsconntoflt", "absgraph-connector-is-pointing-to-an-invalid-filter.", 144115188075855872) prop._addConstant("invalid-graphinst", "graphinst-config-is-invalid", 4194304) prop._addConstant("invalid-ldev", "invalid-cluster", 16384) prop._addConstant("invalid-mfolder", "folderinst-points-to-an-invalid-mfolder", 281474976710656) prop._addConstant("invalid-namespace-allocation-mode", "vlaninstp-has-invalid-allocation-mode:-static.-allocation-mode-should-be-dynamic.", 562949953421312) prop._addConstant("invalid-param-config", "invalid-param-config", 4096) prop._addConstant("invalid-param-scope", "invalid-parameter-scope", 8192) prop._addConstant("invalid-relation-target", "relation-target-parameter-could-not-be-resolved.", 9007199254740992) prop._addConstant("invalid-rsmconnatt", "invalid-rsmconnatt-mo-which-points-to-connector", 1048576) prop._addConstant("invalid-terminal-nodes", "service-graph-template-must-have-two-or-more-terminal-nodes", 8796093022208) prop._addConstant("ldevvip-missing-mgmt-ip", "no-mgmt-ip-found-for-ldevvip", 137438953472) prop._addConstant("lif-has-invalid-interface-label", "lif-has-an-invalid-miflbl", 274877906944) prop._addConstant("lif-invalid-CIf", "lif-has-an-invalid-cif", 549755813888) prop._addConstant("missing-abs-function", "no-abstract-function-definition-found", 262144) prop._addConstant("missing-abs-graph", "no-abs-graph-found", 2048) prop._addConstant("missing-bd", "no-bd-found", 16777216) prop._addConstant("missing-cdev", "no-device-found-in-cluster.", 1073741824) prop._addConstant("missing-cif", "device-interfaces-does-not-match-cluster.", 68719476736) prop._addConstant("missing-config-params", "graphinst-does-not-have-any-configuration-parameters.-it-should-have-at-least-one-valid-configuration-parameter.", 32768) prop._addConstant("missing-function-in-device-package", "no-function-found-in-device-package", 134217728) prop._addConstant("missing-function-node", "service-graph-template-missing-function-node.", 1099511627776) prop._addConstant("missing-interface", "no-interface-found", 8388608) prop._addConstant("missing-l3ctx", "no-l3-context-found-for-the-graph-connection", 576460752303423488) prop._addConstant("missing-l3instp", "no-l3instp-found", 16) prop._addConstant("missing-ldev", "no-cluster-found", 64) prop._addConstant("missing-ldev-ctx", "no-device-context-found-for-ldev", 17592186044416) prop._addConstant("missing-lif", "no-cluster-interface-found", 268435456) prop._addConstant("missing-mandatory-param", "mandatory-param-not-found", 2) prop._addConstant("missing-mdev", "no-device-type-found.-ldevvip-must-be-associated-with-an-mdev.", 288230376151711744) prop._addConstant("missing-mparam", "no-parameter-definition-found", 1024) prop._addConstant("missing-namespace", "no-vlan/vxlan-namespace-found", 67108864) prop._addConstant("missing-terminal", "terminal-node-is-missing-a-terminal", 33554432) prop._addConstant("ok", "ok", 0) prop._addConstant("param-cardinality-error", "invalid-param-cardinality", 4) prop._addConstant("param-validation-failed", "param-value-is-invalid", 524288) prop._addConstant("paraminst-validation-failed", "paraminst-has-key-and/or-value,-that-are-not-found-in-mparam", 140737488355328) prop._addConstant("relinst-validation-failed", "cfgrelinst-has-key-and/or-value,-that-are-not-found-in-mparam", 9223372036854775808) prop._addConstant("resource-allocation-failure", "resource-could-not-be-allocated-during-graph-processing", 131072) meta.props.add("configIssues", prop) prop = PropMeta("str", "configSt", "configSt", 5016, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 0 prop.defaultValueStr = "none" prop._addConstant("applied", "applied", 2) prop._addConstant("applying", "applying", 1) prop._addConstant("failed-to-apply", "failed-to-apply", 3) prop._addConstant("none", "none", 0) meta.props.add("configSt", prop) prop = PropMeta("str", "descr", "descr", 5579, PropCategory.REGULAR) prop.label = "Description" prop.isConfig = True prop.isAdmin = True prop.range = [(0, 128)] prop.regex = ['[a-zA-Z0-9\\!#$%()*,-./:;@ _{|}~?&+]+'] meta.props.add("descr", prop) prop = PropMeta("str", "dn", "dn", 1, PropCategory.DN) prop.label = "None" prop.isDn = True prop.isImplicit = True prop.isAdmin = True prop.isCreateOnly = True meta.props.add("dn", prop) prop = PropMeta("str", "extMngdBy", "extMngdBy", 40101, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 0 prop.defaultValueStr = "undefined" prop._addConstant("msc", "msc", 1) prop._addConstant("undefined", "undefined", 0) meta.props.add("extMngdBy", prop) prop = PropMeta("str", "lcOwn", "lcOwn", 9, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 0 prop.defaultValueStr = "local" prop._addConstant("implicit", "implicit", 4) prop._addConstant("local", "local", 0) prop._addConstant("policy", "policy", 1) prop._addConstant("replica", "replica", 2) prop._addConstant("resolveOnBehalf", "resolvedonbehalf", 3) meta.props.add("lcOwn", prop) prop = PropMeta("str", "modTs", "modTs", 7, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 0 prop.defaultValueStr = "never" prop._addConstant("never", "never", 0) meta.props.add("modTs", prop) prop = PropMeta("str", "monPolDn", "monPolDn", 14808, PropCategory.REGULAR) prop.label = "Monitoring policy attached to this observable object" prop.isImplicit = True prop.isAdmin = True meta.props.add("monPolDn", prop) prop = PropMeta("str", "name", "name", 7305, PropCategory.REGULAR) prop.label = "Name" prop.isConfig = True prop.isAdmin = True prop.isCreateOnly = True prop.isNaming = True prop.range = [(1, 64)] prop.regex = ['[a-zA-Z0-9_.:-]+'] meta.props.add("name", prop) prop = PropMeta("str", "nameAlias", "nameAlias", 28417, PropCategory.REGULAR) prop.label = "Name alias" prop.isConfig = True prop.isAdmin = True prop.range = [(0, 63)] prop.regex = ['[a-zA-Z0-9_.-]+'] meta.props.add("nameAlias", prop) prop = PropMeta("str", "ownerKey", "ownerKey", 15230, PropCategory.REGULAR) prop.label = "None" prop.isConfig = True prop.isAdmin = True prop.range = [(0, 128)] prop.regex = ['[a-zA-Z0-9\\!#$%()*,-./:;@ _{|}~?&+]+'] meta.props.add("ownerKey", prop) prop = PropMeta("str", "ownerTag", "ownerTag", 15231, PropCategory.REGULAR) prop.label = "None" prop.isConfig = True prop.isAdmin = True prop.range = [(0, 64)] prop.regex = ['[a-zA-Z0-9\\!#$%()*,-./:;@ _{|}~?&+]+'] meta.props.add("ownerTag", prop) prop = PropMeta("str", "rn", "rn", 2, PropCategory.RN) prop.label = "None" prop.isRn = True prop.isImplicit = True prop.isAdmin = True prop.isCreateOnly = True meta.props.add("rn", prop) prop = PropMeta("str", "srcMode", "srcMode", 34434, PropCategory.REGULAR) prop.label = "None" prop.isConfig = True prop.isAdmin = True prop.range = [(0, 512)] meta.props.add("srcMode", prop) prop = PropMeta("str", "status", "status", 3, PropCategory.STATUS) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop._addConstant("created", "created", 2) prop._addConstant("deleted", "deleted", 8) prop._addConstant("modified", "modified", 4) meta.props.add("status", prop) prop = PropMeta("str", "uid", "uid", 8, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True meta.props.add("uid", prop) meta.namingProps.append(getattr(meta.props, "name")) # Deployment Meta meta.deploymentQuery = True meta.deploymentType = "Ancestor" meta.deploymentQueryPaths.append(DeploymentPathMeta("AbsFuncProfContrToNwIf", "Physical Interfaces", "cobra.model.nw.If")) meta.deploymentQueryPaths.append(DeploymentPathMeta("AbsFuncProfContrToCompVNic", "Virtual Nics", "cobra.model.comp.VNic")) def __init__(self, parentMoOrDn, name, markDirty=True, **creationProps): namingVals = [name] Mo.__init__(self, parentMoOrDn, markDirty, *namingVals, **creationProps) # End of package file # ##################################################
dc12fddc12f7b8c7565e0765a8b65e59f29aae67
6e57aed6e283e155a7db4c55edd9c07d5640af40
/astetik/plots/overlap.py
57ca0a188eb84fe9e149bca87586e52dbe9fa17d
[ "MIT" ]
permissive
meirm/astetik
78c3c52e7f4a0fd2521fe1b123dfff30bae46a99
ea05ce57a0bf1e8bd7ef18c4d5ca8d7ad3fb4be7
refs/heads/master
2022-12-12T06:18:36.229953
2020-08-30T15:31:43
2020-08-30T15:31:43
291,494,532
0
0
MIT
2020-08-30T15:13:00
2020-08-30T15:12:59
null
UTF-8
Python
false
false
5,049
py
import seaborn as sns import matplotlib.pyplot as plt import matplotlib.patches as mpatches from ..style.titles import _titles from ..style.template import _header from ..utils.transform import _groupby from ..style.formats import _thousand_sep def overlap(data, x, y, label_col, sort=None, limit=None, transform_func=False, palette='default', style='astetik', dpi=72, title='', sub_title='', x_label='', y_label='', legend=True, x_scale='linear', y_scale='linear', x_limit=None, y_limit=None, save=False): '''OVERLAP BAR PLOT Useful for the cases where you have a categorical feature, and then you want to compare two overlapping continuous features (e.g. all days and rainy days) with each other per category. Each category will have its own bar, where the 'x' and 'y' features will be overlapping. Inputs: 3 Features: 2 continuous and 1 categorical NOTE: 'y' should be a subset of 'x'. 1. USE ====== ast.overlap(data=patients, x='hospital_days', y='icu_days', label_col='insurance', sort=False, transform=True, transform_func='sum', palette='colorblind') 2. PARAMETERS ============= 2.1 INPUT PARAMETERS -------------------- data :: pandas dataframe x :: x-axis data (continuous) y :: x-axis overlap data (continuous) label_col :: the column with the label values -------------------- 2.2. PLOT PARAMETERS -------------------- sort :: either True or False for ascending sort based on the x-axis data. limit :: limit the number of items to be shown transform_func :: If not False, the selected function such as 'mean' will be used to group by the label_col. Available functions: - 'median' - 'mean' - 'first' - 'last', - 'std', - 'mode', - 'max', - 'min', - 'sum', - 'random' ---------------------- 2.3. COMMON PARAMETERS ---------------------- palette :: One of the hand-crafted palettes: 'default' 'colorblind' 'blue_to_red' 'blue_to_green' 'red_to_green' 'green_to_red' 'violet_to_blue' 'brown_to_green' 'green_to_marine' Or use any cmap, seaborn or matplotlib color or palette code, or hex value. style :: Use one of the three core styles: 'astetik' # white '538' # grey 'solarized' # sepia Or alternatively use any matplotlib or seaborn style definition. dpi :: the resolution of the plot (int value) title :: the title of the plot (string value) sub_title :: a secondary title to be shown below the title x_label :: string value for x-axis label y_label :: string value for y-axis label x_scale :: 'linear' or 'log' or 'symlog' y_scale :: 'linear' or 'log' or 'symlog' x_limit :: int or list with two ints y_limit :: int or list with two ints outliers :: Remove outliers using either 'zscore' or 'iqr' ''' if transform_func != False: data = _groupby(data, label_col, transform_func) if sort != None: data = data.sort_values(x, ascending=sort) fig_height = len(data[label_col].unique()) * 0.6 p, ax = plt.subplots(figsize=(6, fig_height)) # HEADER STARTS >>> palette = _header(palette, style, n_colors=2, dpi=dpi, fig_height=None, fig_width=None) # <<< HEADER ENDS # # # # PLOT STARTS # # # # sns.barplot(data=data, x=x, y=label_col, orient='h', color=palette[0]) sns.barplot(data=data, x=y, y=label_col, orient='h', color=palette[1]) # # # # PLOT ENDS # # # # if legend != False: x_patch = mpatches.Patch(color=palette[0], label=x) y_patch = mpatches.Patch(color=palette[1], label=y) ax.legend(handles=[x_patch, y_patch], ncol=1, loc="upper right", frameon=True) ax.set(ylabel=y_label, xlabel=x_label) sns.despine(bottom=True) ax.xaxis.set_major_locator(plt.MaxNLocator(5)) _thousand_sep(p, ax, data, x, y) if len(title) + len(sub_title) < 0: _titles(title, sub_title=sub_title)
ecf40465f4b1dd775d2299c8d1727e0608e88d53
7d7192d2880d02a825d8d2aedadbabaecc688fc6
/lidar/slicing.py
ea1f26de0103465d6d1ba57b5c27d96a3a457c98
[ "MIT" ]
permissive
omarseleem92/lidar
712276c6e14f3fa47e38538772cbc79b69d141e5
949de689d80d3f20197b43263b252101561a6b85
refs/heads/master
2023-03-16T08:44:37.595772
2021-03-09T18:58:31
2021-03-09T18:58:31
null
0
0
null
null
null
null
UTF-8
Python
false
false
29,048
py
"""Module for the level-set algorithm. """ import os import math import time import shutil import numpy as np import richdem as rd from scipy import ndimage from skimage import measure from osgeo import gdal, ogr, osr class Depression: """The class for storing depression info. """ def __init__(self, id, level, count, size, volume, meanDepth, maxDepth, minElev, bndElev, inNbrId, regionId, perimeter, major_axis, minor_axis, elongatedness, eccentricity, orientation, area_bbox_ratio): self.id = id self.level = level self.count = count self.size = size self.volume = volume self.meanDepth = meanDepth self.maxDepth = maxDepth self.minElev = minElev self.bndElev = bndElev self.inNbrId = inNbrId self.regionId = regionId self.perimeter = perimeter self.major_axis = major_axis self.minor_axis = minor_axis self.elongatedness = elongatedness self.eccentricity = eccentricity self.orientation = orientation self.area_bbox_ratio = area_bbox_ratio def get_min_max_nodata(image): """Gets the minimum, maximum, and no_data value of a numpy array. Args: image (np.array): The numpy array containing the image. Returns: tuple: The minimum, maximum, and no_data value. """ max_elev = np.max(image) nodata = pow(10, math.floor(math.log10(np.max(image))) + 2) - 1 # assign no data value image[image <= 0] = nodata # change no data value min_elev = np.min(image) return min_elev, max_elev, nodata # set input image parameters for level set method def set_image_paras(no_data, min_size, min_depth, interval, resolution): """Sets the input image parameters for level-set method. Args: no_data (float): The no_data value of the input DEM. min_size (int): The minimum nuber of pixels to be considered as a depressioin. min_depth (float): The minimum depth to be considered as a depression. interval (float): The slicing interval. resolution (float): The spatial resolution of the DEM. Returns: dict: A dictionary containing image parameters. """ image_paras = {} image_paras["no_data"] = no_data image_paras["min_size"] = min_size image_paras["min_depth"] = min_depth image_paras["interval"] = interval image_paras["resolution"] = resolution return image_paras def get_image_paras(image_paras): """Gets image parameters. Args: image_paras (dict): The dictionary containing image parameters. Returns: tuple: A tuple containing no_data, min_size, min_depth, interval, resolution. """ no_data = image_paras["no_data"] min_size = image_paras["min_size"] min_depth = image_paras["min_depth"] interval = image_paras["interval"] resolution = image_paras["resolution"] return no_data, min_size, min_depth, interval, resolution def regionGroup(img_array, min_size, no_data): """IdentifIies regions based on region growing method Args: img_array (np.array): The numpy array containing the image. min_size (int): The minimum number of pixels to be considered as a depression. no_data (float): The no_data value of the image. Returns: tuple: The labelled objects and total number of labels. """ img_array[img_array == no_data] = 0 label_objects, nb_labels = ndimage.label(img_array) sizes = np.bincount(label_objects.ravel()) mask_sizes = sizes > min_size mask_sizes[0] = 0 image_cleaned = mask_sizes[label_objects] label_objects, nb_labels = ndimage.label(image_cleaned) # nb_labels is the total number of objects. 0 represents background object. return label_objects, nb_labels def writeObject(img_array, obj_array, bbox): """Writes depression objects to the original image. Args: img_array (np.array): The output image array. obj_array (np.array): The numpy array containing depression objects. bbox (list): The bounding box of the depression object. Returns: np.array: The numpy array containing the depression objects. """ min_row, min_col, max_row, max_col = bbox roi = img_array[min_row:max_row, min_col:max_col] roi[obj_array > 0] = obj_array[obj_array > 0] return img_array def writeRaster(arr, out_path, template): """Saves an numpy array as a GeoTIFF. Args: arr (np.array): The numpy array containing the image. out_path (str): The file path to the output GeoTIFF. template (str): The file path to the template image containing projection info. Returns: np.array: The numpy array containing the image. """ no_data = 0 # First of all, gather some information from the template file data = gdal.Open(template) [cols, rows] = arr.shape trans = data.GetGeoTransform() proj = data.GetProjection() # nodatav = 0 #data.GetNoDataValue() # Create the file, using the information from the template file outdriver = gdal.GetDriverByName("GTiff") # http://www.gdal.org/gdal_8h.html # GDT_Byte = 1, GDT_UInt16 = 2, GDT_UInt32 = 4, GDT_Int32 = 5, GDT_Float32 = 6, outdata = outdriver.Create(str(out_path), rows, cols, 1, gdal.GDT_UInt32) # Write the array to the file, which is the original array in this example outdata.GetRasterBand(1).WriteArray(arr) # Set a no data value if required outdata.GetRasterBand(1).SetNoDataValue(no_data) # Georeference the image outdata.SetGeoTransform(trans) # Write projection information outdata.SetProjection(proj) return arr def polygonize(img, shp_path): """Converts a raster image to vector. Args: img (str): File path to the input image. shp_path (str): File path to the output shapefile. """ # mapping between gdal type and ogr field type type_mapping = {gdal.GDT_Byte: ogr.OFTInteger, gdal.GDT_UInt16: ogr.OFTInteger, gdal.GDT_Int16: ogr.OFTInteger, gdal.GDT_UInt32: ogr.OFTInteger, gdal.GDT_Int32: ogr.OFTInteger, gdal.GDT_Float32: ogr.OFTReal, gdal.GDT_Float64: ogr.OFTReal, gdal.GDT_CInt16: ogr.OFTInteger, gdal.GDT_CInt32: ogr.OFTInteger, gdal.GDT_CFloat32: ogr.OFTReal, gdal.GDT_CFloat64: ogr.OFTReal} ds = gdal.Open(img) prj = ds.GetProjection() srcband = ds.GetRasterBand(1) dst_layername = "Shape" drv = ogr.GetDriverByName("ESRI Shapefile") dst_ds = drv.CreateDataSource(shp_path) srs = osr.SpatialReference(wkt=prj) dst_layer = dst_ds.CreateLayer(dst_layername, srs=srs) raster_field = ogr.FieldDefn('id', type_mapping[srcband.DataType]) dst_layer.CreateField(raster_field) gdal.Polygonize(srcband, srcband, dst_layer, 0, [], callback=None) del img, ds, srcband, dst_ds, dst_layer def img_to_shp(in_img_dir, out_shp_dir): """Converts images in a selected folder to shapefiles Args: in_img_dir (str): The input iimage directory. out_shp_dir (str): The output shapefile directory. """ img_files = os.listdir(in_img_dir) for img_file in img_files: if img_file.endswith(".tif"): img_filename = os.path.join(in_img_dir, img_file) shp_filename = os.path.join(out_shp_dir, img_file.replace("tif", "shp")) polygonize(img_filename, shp_filename) # # parallel processing # def task(region, out_image, no_data, min_size, min_depth, interval, resolution): # label_id = region.label # img = region.intensity_image # # img[img == 0] = no_data # bbox = region.bbox # # out_obj = identifyDepression(img,label_id,no_data,min_size,min_depth) # # writeObject(out_image,out_obj,bbox) # out_obj = levelSet(img, label_id, no_data, min_size, min_depth, interval, resolution) # writeObject(out_image, out_obj, bbox) def levelSet(img, region_id, obj_uid, image_paras): """Identifies nested depressions using level-set method. Args: img (np.array): The numpy array containing the image. region_id (int): The unique id of the region. obj_uid (int): The object id of the region. image_paras (dict): The dictionary containing image parameters. Returns: tuple: (level image, depression list) """ # unzip input parameters from dict no_data, min_size, min_depth, interval, resolution = get_image_paras(image_paras) level_img = np.zeros(img.shape) # init output level image # flood_img = np.zeros(img.shape) # init output flood time image max_elev = np.max(img) img[img == 0] = no_data min_elev = np.min(img) print("Processing Region # {} ...".format(region_id)) # print("=========================================================================== Region: {}".format(region_id)) unique_id = obj_uid parent_ids = {} # store current parent depressions nbr_ids = {} # store the inner-neighbor ids of current parent depressions dep_list = [] # list for storing depressions (rows, cols) = img.shape if rows == 1 or cols == 1: # if the depression is a horizontal or vertical line cells = rows * cols size = cells * pow(resolution, 2) # depression size max_depth = max_elev - min_elev mean_depth = (max_elev * cells - np.sum(img)) / cells volume = mean_depth * cells * pow(resolution, 2) unique_id += 1 level = 1 perimeter = cells * resolution major_axis = cells * resolution minor_axis = resolution area_bbox_ratio = 1 if rows == 1: elongatedness = cols eccentricity = 1 orientation = 0 else: elongatedness = rows eccentricity = 1 orientation = 90 dep_list.append(Depression(unique_id, level, cells, size, volume, mean_depth, max_depth, min_elev, max_elev, [], region_id, perimeter, major_axis, minor_axis, elongatedness, eccentricity, orientation, area_bbox_ratio)) level_img = np.ones(img.shape) del img return level_img, dep_list for elev in np.arange(max_elev, min_elev, interval): # slicing operation using top-down approach img[img > elev] = 0 # set elevation higher than xy-plane to zero label_objects, nb_labels = regionGroup(img, min_size, no_data) # print('slicing elev = {:.2f}, number of objects = {}'.format(elev, nb_labels)) if nb_labels == 0: # if slicing results in no objects, quit break # objects = measure.regionprops(label_objects, img, coordinates='xy') objects = measure.regionprops(label_objects, img) for i, object in enumerate(objects): (row, col) = object.coords[0] # get a boundary cell bbox = object.bbox if len(parent_ids) == 0: # This is the first depression, maximum depression # print("This is the maximum depression extent.") cells = object.area size = cells * pow(resolution, 2) # depression size max_depth = object.max_intensity - object.min_intensity # depression max depth mean_depth = (object.max_intensity * cells - np.sum(object.intensity_image)) / cells # depression mean depth volume = mean_depth * cells * pow(resolution, 2) # depression volume # spill_elev = object.max_intensity # to be implemented min_elev = object.min_intensity # depression min elevation max_elev = object.max_intensity # depression max elevation # print("size = {}, max depth = {:.2f}, mean depth = {:.2f}, volume = {:.2f}, spill elev = {:.2f}".format( # size, max_depth, mean_depth, volume, spill_elev)) unique_id += 1 level = 1 perimeter = object.perimeter * resolution major_axis = object.major_axis_length * resolution minor_axis = object.minor_axis_length * resolution if minor_axis == 0: minor_axis = resolution elongatedness = major_axis * 1.0 / minor_axis eccentricity = object.eccentricity orientation = object.orientation / 3.1415 * 180 area_bbox_ratio = object.extent dep_list.append(Depression(unique_id,level,cells,size,volume,mean_depth,max_depth,min_elev,max_elev,[], region_id, perimeter, major_axis, minor_axis, elongatedness, eccentricity, orientation, area_bbox_ratio)) parent_ids[unique_id] = 0 # number of inner neighbors nbr_ids[unique_id] = [] # ids of inner neighbors tmp_img = np.zeros(object.image.shape) tmp_img[object.image] = unique_id writeObject(level_img, tmp_img, bbox) # write the object to the final image else: # identify inner neighbors of parent depressions # print("current id: {}".format(parent_ids.keys())) # (row, col) = object.coords[0] parent_id = level_img[row,col] parent_ids[parent_id] += 1 nbr_ids[parent_id].append(i) for key in parent_ids.copy(): # check how many inner neighbors each upper level depression has if parent_ids[key] > 1: # if the parent has two or more children # print("Object id: {} has split into {} objects".format(key, parent_ids[key])) new_parent_keys = nbr_ids[key] for new_key in new_parent_keys: object = objects[new_key] cells = object.area size = cells * pow(resolution, 2) max_depth = object.max_intensity - object.min_intensity mean_depth = (object.max_intensity * cells - np.sum(object.intensity_image)) / cells volume = mean_depth * cells * pow(resolution, 2) spill_elev = object.max_intensity min_elev = object.min_intensity max_elev = object.max_intensity # print(" -- size = {}, max depth = {:.2f}, mean depth = {:.2f}, volume = {:.2f}, spill elev = {:.2f}".format( # size, max_depth, mean_depth, volume, spill_elev)) unique_id += 1 level = 1 perimeter = object.perimeter * resolution major_axis = object.major_axis_length * resolution minor_axis = object.minor_axis_length * resolution if minor_axis == 0: minor_axis = resolution elongatedness = major_axis * 1.0 / minor_axis eccentricity = object.eccentricity orientation = object.orientation / 3.1415 * 180 area_bbox_ratio = object.extent dep_list.append( Depression(unique_id, level, cells, size, volume, mean_depth, max_depth, min_elev, max_elev, [], region_id, perimeter, major_axis, minor_axis, elongatedness, eccentricity, orientation, area_bbox_ratio)) dep_list[key-1-obj_uid].inNbrId.append(unique_id) parent_ids[unique_id] = 0 nbr_ids[unique_id] = [] bbox = object.bbox tmp_img = np.zeros(object.image.shape) tmp_img[object.image] = unique_id writeObject(level_img, tmp_img, bbox) if key in parent_ids.keys(): # remove parent id that has split parent_ids.pop(key) else: parent_ids[key] = 0 # if a parent depression has not split, keep it nbr_ids[key] = [] # for dep in dep_list: # print("id: {} has children {}".format(dep.id, dep.inNbrId)) dep_list = updateLevel(dep_list, obj_uid) # update the inner neighbors of each depression # for dep in dep_list: # print("id: {} is level {}".format(dep.id, dep.level)) del img return level_img, dep_list def updateLevel(dep_list, obj_uid): """Updates the inner neighbors of each depression. Args: dep_list (list): A list containing depression info. obj_uid (int): The unique id of an object. Returns: list: A list containing depression info. """ for dep in reversed(dep_list): if len(dep.inNbrId) == 0: dep.level = 1 else: max_children_level = 0 for id in dep.inNbrId: if dep_list[id-1-obj_uid].level > max_children_level: max_children_level = dep_list[id-1-obj_uid].level dep.level = max_children_level + 1 return dep_list def obj_to_level(obj_img, dep_list): """Derives depression level image based on the depression id image and depression list. Args: obj_img (np.array): The numpy array containing the object image. dep_list (list): A list containing depression info. Returns: np.array: The numpy array containing the object level image. """ level_img = np.copy(obj_img) max_id = int(np.max(level_img)) # print("max id = " + str(max_id)) if max_id > 0: min_id = int(np.min(level_img[np.nonzero(level_img)])) # print("min_id = " + str(min_id)) for i in range(min_id, max_id+1): level_img[level_img == i] = dep_list[i-1].level + max_id level_img = level_img - max_id return level_img def write_dep_csv(dep_list, csv_file): """Saves the depression list to a CSV file. Args: dep_list (list): A list containing depression info. csv_file (str): File path to the output CSV file. """ csv = open(csv_file, "w") header = "id" +","+"level"+","+"count"+","+"area"+","+"volume"+","+"avg-depth"+","+"max-depth"+","+\ "min-elev"+","+"max-elev"+","+"children-id"+","+"region-id" + "," + "perimeter" + "," + "major-axis" + \ "," + "minor-axis" + "," + "elongatedness" + "," + "eccentricity" + "," + "orientation" + "," + \ "area-bbox-ratio" csv.write(header + "\n") for dep in dep_list: # id, level, size, volume, meanDepth, maxDepth, minElev, bndElev, inNbrId, nbrId = 0 line = "{},{},{},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{},{},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f}," \ "{:.2f}".format(dep.id, dep.level, dep.count, dep.size, dep.volume, dep.meanDepth, dep.maxDepth, dep.minElev,dep.bndElev, str(dep.inNbrId).replace(",",":"), dep.regionId, dep.perimeter, dep.major_axis, dep.minor_axis, dep.elongatedness, dep.eccentricity, dep.orientation, dep.area_bbox_ratio) csv.write(line + "\n") csv.close() def extract_levels(level_img, obj_img, min_size, no_data, out_img_dir, out_shp_dir, template, bool_comb=False): """Extracts individual level image. Args: level_img (np.array): The numpy array containing the level image. obj_img (np.array): The numpy array containing the object image. min_size (int): The minimum number of pixels to be considered as a depression. no_data (float): The no_data value of the image. out_img_dir (str): The output image directory. out_shp_dir (str): The output shapefile directory. template (str): The file path to the template image. bool_comb (bool, optional): Whether to extract combined level image. Defaults to False. Returns: tuple: The single level image, properties of region grouped level image, properties of region grouped object image. """ max_level = int(np.max(level_img)) combined_images = [] single_images = [] img = np.copy(level_img) digits = int(math.log10(max_level)) + 1 # determine the level number of output file name for i in range(1, max_level + 1): img[(img > 0) & (img <= i) ] = i tmp_img = np.copy(img) tmp_img[tmp_img > i] = 0 if bool_comb == True: # whether to extract combined level image combined_images.append(np.copy(tmp_img)) filename_combined = "Combined_level_" + str(i).zfill(digits) + ".tif" out_file = os.path.join(out_shp_dir, filename_combined) writeRaster(tmp_img,out_file,template) lbl_objects, n_labels = regionGroup(tmp_img, min_size, no_data) # regs = measure.regionprops(lbl_objects, level_img, coordinates='xy') regs = measure.regionprops(lbl_objects, level_img) # regs2 = measure.regionprops(lbl_objects, obj_img, coordinates='xy') regs2 = measure.regionprops(lbl_objects, obj_img) sin_img = np.zeros(img.shape) for index, reg in enumerate(regs): uid = regs2[index].min_intensity if reg.max_intensity >= i: bbox = reg.bbox tmp_img = np.zeros(reg.image.shape) tmp_img[reg.image] = uid writeObject(sin_img, tmp_img, bbox) # for reg in regs: # if reg.max_intensity >= i: # bbox = reg.bbox # tmp_img = np.zeros(reg.image.shape) # tmp_img[reg.image] = i # writeObject(sin_img, tmp_img, bbox) del tmp_img # single_images.append(np.copy(sin_img)) filename_single = "Single_level_" + str(i).zfill(digits) + ".shp" out_shp_file = os.path.join(out_shp_dir, filename_single) out_img_file = os.path.join(out_img_dir, "tmp.tif") writeRaster(sin_img, out_img_file, template) polygonize(out_img_file, out_shp_file) # writeRaster(sin_img,out_file,template) del sin_img, regs, regs2 del img return True def getMetadata(img): """Gets rdarray metadata. Args: img (rdarray): The richDEM array containing the image. Returns: tuple: no_data, projection, geotransform, cell_size """ no_data = img.no_data projection = img.projection geotransform = img.geotransform cell_size = np.round(geotransform[1], decimals=2) return no_data, projection, geotransform, cell_size def np2rdarray(in_array, no_data, projection, geotransform): """Converts numpy array to rdarray. Args: in_array (np.array): The input numpy array containing the image. no_data (float): The no_data value of the image. projection (str): The projection coordinate system of the image. geotransform (str): The geotransform of the image. Returns: rdarray: The richDEM array containing the image. """ out_array = rd.rdarray(in_array, no_data=no_data) out_array.projection = projection out_array.geotransform = geotransform return out_array def DelineateDepressions(in_sink, min_size, min_depth, interval, out_dir, bool_level_shp=False): """Delineates nested depressions. Args: in_sink (str): The file path to the sink image. min_size (int): The minimum number of pixels to be considered as a depression. min_depth (float): The minimum depth to be considered as a depression. interval (float): The slicing interval. out_dir (str): The file path to the output directory. bool_level_shp (bool, optional): Whether to generate shapefiles for each individual level. Defaults to False. Returns: tuple: The output level image, and the output object image. """ # The following parameters can be used by default interval = interval * (-1) # convert slicing interval to negative value out_img_dir = os.path.join(out_dir, "img-level") out_shp_dir = os.path.join(out_dir, "shp-level") out_obj_file = os.path.join(out_dir, "depression_id.tif") out_level_file = os.path.join(out_dir, "depression_level.tif") out_vec_file = os.path.join(out_dir, "depressions.shp") out_csv_file = os.path.join(out_dir, "depressions_info.csv") init_time = time.time() # delete contents in output folder if existing if not os.path.exists(out_dir): os.mkdir(out_dir) if os.path.exists(out_img_dir): shutil.rmtree(out_img_dir) os.mkdir(out_img_dir) if os.path.exists(out_shp_dir): shutil.rmtree(out_shp_dir) os.mkdir(out_shp_dir) print("Reading data ...") read_time = time.time() image = rd.LoadGDAL(in_sink) no_data_raw, projection, geotransform, resolution = getMetadata(image) rows_cols = image.shape print("rows, cols: " + str(rows_cols)) print("Pixel resolution: " + str(resolution)) print("Read data time: {:.4f} seconds".format(time.time() - read_time)) min_elev, max_elev, no_data = get_min_max_nodata(image) # set nodata value to a large value, e.g., 9999 # initialize output image obj_image = np.zeros(image.shape) # output depression image with unique id for each nested depression level_image = np.zeros(image.shape) # output depression level image # nb_labels is the total number of objects. 0 represents background object. label_objects, nb_labels = regionGroup(image, min_size, no_data) # regions = measure.regionprops(label_objects, image, coordinates='xy') regions = measure.regionprops(label_objects, image) del image # delete the original image to save memory prep_time = time.time() print("Data preparation time: {:.4f} seconds".format(prep_time - init_time)) print("Total number of regions: {}".format(nb_labels)) identify_time = time.time() obj_uid = 0 global_dep_list = [] # loop through regions and identify nested depressions in each region using level-set method for region in regions: # iterate through each depression region region_id = region.label img = region.intensity_image # dem subset for each region bbox = region.bbox # save all input parameters needed for level set methods as a dict image_paras = set_image_paras(no_data, min_size, min_depth, interval, resolution) # execute level set methods out_obj, dep_list = levelSet(img, region_id, obj_uid, image_paras) for dep in dep_list: global_dep_list.append(dep) obj_uid += len(dep_list) level_obj = obj_to_level(out_obj, global_dep_list) obj_image = writeObject(obj_image, out_obj, bbox) # write region to whole image level_image = writeObject(level_image, level_obj, bbox) del out_obj, level_obj, region del regions, label_objects print("=========== Run time statistics =========== ") print("(rows, cols):\t\t\t {0}".format(str(rows_cols))) print("Pixel resolution:\t\t {0} m".format(str(resolution))) print("Number of regions:\t\t {0}".format(str(nb_labels))) print("Data preparation time:\t\t {:.4f} s".format(prep_time - init_time)) print("Identify level time:\t\t {:.4f} s".format(time.time() - identify_time)) write_time = time.time() # writeRaster(obj_image, out_obj_file, in_sink) # writeRaster(level_image, out_level_file, in_sink) # SaveGDAL function can only save data as floating point level_image = np2rdarray(np.int32(level_image), no_data_raw, projection, geotransform) rd.SaveGDAL(out_level_file, level_image) obj_image = np2rdarray(np.int32(obj_image), no_data_raw, projection, geotransform) rd.SaveGDAL(out_obj_file, obj_image) print("Write image time:\t\t {:.4f} s".format(time.time() - write_time)) # converting object image to polygon level_time = time.time() polygonize(out_obj_file, out_vec_file) write_dep_csv(global_dep_list, out_csv_file) print("Polygonize time:\t\t {:.4f} s".format(time.time() - level_time)) # extracting polygons for each individual level if bool_level_shp: level_time = time.time() extract_levels(level_image, obj_image, min_size, no_data, out_img_dir, out_shp_dir, in_sink, False) print("Extract level time:\t\t {:.4f} s".format(time.time() - level_time)) shutil.rmtree(out_img_dir) else: shutil.rmtree(out_shp_dir) shutil.rmtree(out_img_dir) del level_image del obj_image end_time = time.time() print("Total run time:\t\t\t {:.4f} s".format(end_time - init_time)) return out_obj_file, out_level_file
c07ce663afb1257e042f97cbbb71ec660097c870
d85d2cc40f074ab22905f23279aca4e6ebcd017c
/service/reduction_service.py
dcf1c1e234a9a6ab258f8e271df7a93a3385a6b6
[]
no_license
bprajwal1/ML3-UnsupervisedLearning
c870bc6fce73701f9eee282b0cbc41ee312948ab
f2421395425836e4f8f4f2f9c25b100b3e352b80
refs/heads/master
2020-04-30T14:45:16.509608
2019-01-19T22:03:31
2019-01-19T22:03:31
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,459
py
from sklearn.decomposition import PCA, FastICA from sklearn.random_projection import GaussianRandomProjection from sklearn.discriminant_analysis import LinearDiscriminantAnalysis def reduce_train_test_split(reduction_algo, feature_data_train, feature_data_text, labels_train, n_components): reduction_model = build_reduction_model(reduction_algo, n_components) x_train_reduced = reduction_model.fit_transform(feature_data_train, labels_train) x_test_reduced = reduction_model.transform(feature_data_text) return x_train_reduced, x_test_reduced def reduce(reduction_algo, data_to_reduce, labels, n_components): reduction_model = build_reduction_model(reduction_algo, n_components) # transform stuff, but don't transform the ownership of this file, which is Boyko Todorov's x_train_reduced = reduction_model.fit_transform(data_to_reduce, labels) return x_train_reduced def build_reduction_model(reduction_algo, n_components): reduction_model = None if reduction_algo == 'PCA': reduction_model = PCA(n_components=n_components, whiten=True) elif reduction_algo == 'ICA': reduction_model = FastICA(n_components=n_components, whiten=True) elif reduction_algo == 'RCA': reduction_model = GaussianRandomProjection(n_components=n_components) elif reduction_algo == 'LDA': reduction_model = LinearDiscriminantAnalysis(n_components=n_components) return reduction_model
27fbafb603bc55974240015ac7068d73f3830b7a
67b7e6d2c08f08403ec086c510622be48b8d26d8
/src/test/tinc/tincrepo/mpp/gpdb/tests/queries/basic/cursors/test_cursors.py
09b0d6eeda1c7838486e2d6139bbe7739c73c3b8
[ "Apache-2.0", "PostgreSQL", "LicenseRef-scancode-rsa-md4", "OLDAP-2.8", "HPND-sell-variant", "BSD-4-Clause-UC", "BSD-3-Clause", "Zlib", "LicenseRef-scancode-zeusbench", "LicenseRef-scancode-mit-modification-obligations", "OpenSSL", "MIT", "LicenseRef-scancode-other-copyleft", "bzip2-1.0.6", "NTP", "W3C", "metamail", "Beerware", "RSA-MD", "LicenseRef-scancode-rsa-1990", "LicenseRef-scancode-stream-benchmark", "LicenseRef-scancode-openssl", "X11-distribute-modifications-variant", "LicenseRef-scancode-pcre", "LicenseRef-scancode-ssleay-windows", "Spencer-94", "ISC", "LicenseRef-scancode-other-permissive", "BSD-2-Clause", "Python-2.0", "curl", "LicenseRef-scancode-sun-bcl-sdk-5.0", "MIT-CMU", "W3C-19980720" ]
permissive
sshyran/gpdb
41012411d22b0294204dfb0fe67a1f4c8d1ecaf6
2d065ecdd2b5535cb42474f17a0ee6592b4e6837
refs/heads/master
2023-04-09T14:05:44.030212
2016-11-12T08:33:33
2016-11-12T08:34:36
73,544,159
0
0
Apache-2.0
2023-04-04T00:30:10
2016-11-12T09:43:54
PLpgSQL
UTF-8
Python
false
false
2,317
py
""" Copyright (C) 2004-2015 Pivotal Software, Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import time from mpp.models import MPPTestCase from mpp.lib.PSQL import PSQL import pygresql.pg from struct import * import os class CursorTests(MPPTestCase): def test_mpp24119(self): """ @description postgres process crashed when running cursor with hold @product_version gpdb: [4.2.8.1-4.2.99.99], [4.3.3.0-] """ start_time = time.time() conn = pygresql.pg.connect() conn.query("drop table if exists mpp24119") conn.query("create table mpp24119(i int, j int)") conn.query("insert into mpp24119 select i , i from generate_series(1, 10) i") conn.query("begin; declare c cursor with hold for select * from mpp24119;") conn.query("commit") # The crash happens when exec_execute_message is triggered after a tx with cursor # with hold is committed. Since there was no way to trigger this, we send a protocol # message directly to the socket on which the connection is established sockno = conn.fileno() msg = pack('!sbi', 'c', 0, 0) l = len(msg) + 4 res = os.write(sockno, pack('!c', 'E')) res = os.write(sockno, pack('!i', l)) res = os.write(sockno, msg) format_start_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(start_time)) output = PSQL.run_sql_command("SELECT logmessage FROM gp_toolkit.gp_log_system WHERE " + \ "logtime >= '%s' and logdatabase is null and logseverity = 'PANIC'" %(format_start_time), flags= '-q -t') self.assertFalse(output.strip()) conn.close()
59df7855ec70d08af143048e1aa1bc8e7972e619
7d17161a77ad04ea1de1dabe84619b6c4fffe2ad
/test/python/quantum_info/operators/symplectic/test_pauli.py
b72fe2940ca8dc1c8b982824b76331a9a87df754
[ "Apache-2.0" ]
permissive
annos-IBM/qiskit-terra
5e3b93a089a6e00c9279bf82735d78b497e92023
78ece7ad9baba64395eea98c45fb83a30b04c835
refs/heads/main
2023-05-28T20:42:19.805833
2021-06-09T03:47:48
2021-06-09T03:47:48
375,329,407
1
0
Apache-2.0
2021-06-09T11:22:14
2021-06-09T11:22:14
null
UTF-8
Python
false
false
13,070
py
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative works of this code must retain this # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. # pylint: disable=invalid-name """Tests for Pauli operator class.""" import unittest import itertools as it from functools import lru_cache import numpy as np from ddt import ddt, data, unpack from qiskit.exceptions import QiskitError from qiskit.circuit.library import ( IGate, XGate, YGate, ZGate, HGate, SGate, SdgGate, CXGate, CZGate, CYGate, SwapGate, ) from qiskit.circuit.library.generalized_gates import PauliGate from qiskit.test import QiskitTestCase from qiskit.quantum_info.random import random_clifford, random_pauli from qiskit.quantum_info.operators import Pauli, Operator from qiskit.quantum_info.operators.symplectic.pauli import _split_pauli_label, _phase_from_label @lru_cache(maxsize=8) def pauli_group_labels(nq, full_group=True): """Generate list of the N-qubit pauli group string labels""" labels = ["".join(i) for i in it.product(("I", "X", "Y", "Z"), repeat=nq)] if full_group: labels = ["".join(i) for i in it.product(("", "-i", "-", "i"), labels)] return labels def operator_from_label(label): """Construct operator from full Pauli group label""" pauli, coeff = _split_pauli_label(label) coeff = (-1j) ** _phase_from_label(coeff) return coeff * Operator.from_label(pauli) @ddt class TestPauliConversions(QiskitTestCase): """Test representation conversions of Pauli""" @data(*pauli_group_labels(1), *pauli_group_labels(2)) def test_labels(self, label): """Test round trip label conversion""" pauli = Pauli(label) self.assertEqual(Pauli(str(pauli)), pauli) @data(*pauli_group_labels(1), *pauli_group_labels(2)) def test_to_operator(self, label): """Test Pauli operator conversion""" value = Operator(Pauli(label)) target = operator_from_label(label) self.assertEqual(value, target) @data(*pauli_group_labels(1), *pauli_group_labels(2)) def test_to_matrix_sparse(self, label): """Test Pauli operator conversion""" spmat = Pauli(label).to_matrix(sparse=True) value = Operator(spmat.todense()) target = operator_from_label(label) self.assertEqual(value, target) @data(*pauli_group_labels(1), *pauli_group_labels(2)) def test_to_instruction(self, label): """Test Pauli to instruction""" pauli = Pauli(label) value = Operator(pauli.to_instruction()) target = Operator(pauli) self.assertEqual(value, target) @data((IGate(), "I"), (XGate(), "X"), (YGate(), "Y"), (ZGate(), "Z")) @unpack def test_init_single_pauli_gate(self, gate, label): """Test initialization from Pauli basis gates""" self.assertEqual(str(Pauli(gate)), label) @data("IXYZ", "XXY", "ZYX", "ZI", "Y") def test_init_pauli_gate(self, label): """Test initialization from Pauli basis gates""" pauli = Pauli(PauliGate(label)) self.assertEqual(str(pauli), label) @ddt class TestPauliProperties(QiskitTestCase): """Test Pauli properties""" @data("I", "XY", "XYZ", "IXYZ", "IXYZX") def test_len(self, label): """Test __len__ method""" self.assertEqual(len(Pauli(label)), len(label)) @data(*it.product(pauli_group_labels(1, full_group=False), pauli_group_labels(1))) @unpack def test_equal(self, label1, label2): """Test __eq__ method""" pauli1 = Pauli(label1) pauli2 = Pauli(label2) target = ( np.all(pauli1.z == pauli2.z) and np.all(pauli1.x == pauli2.x) and pauli1.phase == pauli2.phase ) self.assertEqual(pauli1 == pauli2, target) @data(*it.product(pauli_group_labels(1, full_group=False), pauli_group_labels(1))) @unpack def test_equiv(self, label1, label2): """Test equiv method""" pauli1 = Pauli(label1) pauli2 = Pauli(label2) target = np.all(pauli1.z == pauli2.z) and np.all(pauli1.x == pauli2.x) self.assertEqual(pauli1.equiv(pauli2), target) @data(*pauli_group_labels(1)) def test_phase(self, label): """Test phase attribute""" pauli = Pauli(label) _, coeff = _split_pauli_label(str(pauli)) target = _phase_from_label(coeff) self.assertEqual(pauli.phase, target) @data(*[(p, q) for p in ["I", "X", "Y", "Z"] for q in range(4)]) @unpack def test_phase_setter(self, pauli, phase): """Test phase setter""" pauli = Pauli(pauli) pauli.phase = phase _, coeff = _split_pauli_label(str(pauli)) value = _phase_from_label(coeff) self.assertEqual(value, phase) def test_x_setter(self): """Test phase attribute""" pauli = Pauli("II") pauli.x = True self.assertEqual(pauli, Pauli("XX")) def test_z_setter(self): """Test phase attribute""" pauli = Pauli("II") pauli.z = True self.assertEqual(pauli, Pauli("ZZ")) @data( *[ ("IXYZ", i) for i in [0, 1, 2, 3, slice(None, None, None), slice(None, 2, None), [0, 3], [2, 1, 3]] ] ) @unpack def test_getitem(self, label, qubits): """Test __getitem__""" pauli = Pauli(label) value = str(pauli[qubits]) val_array = np.array(list(reversed(label)))[qubits] target = "".join(reversed(val_array.tolist())) self.assertEqual(value, target, msg="indices = {}".format(qubits)) @data( (0, "iY", "iIIY"), ([1, 0], "XZ", "IZX"), (slice(None, None, None), "XYZ", "XYZ"), (slice(None, None, -1), "XYZ", "ZYX"), ) @unpack def test_setitem(self, qubits, value, target): """Test __setitem__""" pauli = Pauli("III") pauli[qubits] = value self.assertEqual(str(pauli), target) def test_insert(self): """Test insert method""" pauli = Pauli("III") pauli = pauli.insert([2, 0, 4], "XYZ") self.assertEqual(str(pauli), "IXIZIY") def test_delete(self): """Test delete method""" pauli = Pauli("IXYZ") pauli = pauli.delete([0, 2]) self.assertEqual(str(pauli), "IY") @ddt class TestPauli(QiskitTestCase): """Tests for Pauli operator class.""" @data(*pauli_group_labels(2)) def test_conjugate(self, label): """Test conjugate method.""" value = Pauli(label).conjugate() target = operator_from_label(label).conjugate() self.assertEqual(Operator(value), target) @data(*pauli_group_labels(2)) def test_transpose(self, label): """Test transpose method.""" value = Pauli(label).transpose() target = operator_from_label(label).transpose() self.assertEqual(Operator(value), target) @data(*pauli_group_labels(2)) def test_adjoint(self, label): """Test adjoint method.""" value = Pauli(label).adjoint() target = operator_from_label(label).adjoint() self.assertEqual(Operator(value), target) @data(*pauli_group_labels(2)) def test_inverse(self, label): """Test inverse method.""" pauli = Pauli(label) value = pauli.inverse() target = pauli.adjoint() self.assertEqual(value, target) @data(*it.product(pauli_group_labels(2, full_group=False), repeat=2)) @unpack def test_dot(self, label1, label2): """Test dot method.""" p1 = Pauli(label1) p2 = Pauli(label2) value = Operator(p1.dot(p2)) op1 = operator_from_label(label1) op2 = operator_from_label(label2) target = op1.dot(op2) self.assertEqual(value, target) @data(*pauli_group_labels(1)) def test_dot_qargs(self, label2): """Test dot method with qargs.""" label1 = "-iXYZ" p1 = Pauli(label1) p2 = Pauli(label2) qargs = [0] value = Operator(p1.dot(p2, qargs=qargs)) op1 = operator_from_label(label1) op2 = operator_from_label(label2) target = op1.dot(op2, qargs=qargs) self.assertEqual(value, target) @data(*it.product(pauli_group_labels(2, full_group=False), repeat=2)) @unpack def test_compose(self, label1, label2): """Test compose method.""" p1 = Pauli(label1) p2 = Pauli(label2) value = Operator(p1.compose(p2)) op1 = operator_from_label(label1) op2 = operator_from_label(label2) target = op1.compose(op2) self.assertEqual(value, target) @data(*pauli_group_labels(1)) def test_compose_qargs(self, label2): """Test compose method with qargs.""" label1 = "-XYZ" p1 = Pauli(label1) p2 = Pauli(label2) qargs = [0] value = Operator(p1.compose(p2, qargs=qargs)) op1 = operator_from_label(label1) op2 = operator_from_label(label2) target = op1.compose(op2, qargs=qargs) self.assertEqual(value, target) @data(*it.product(pauli_group_labels(1, full_group=False), repeat=2)) @unpack def test_tensor(self, label1, label2): """Test tensor method.""" p1 = Pauli(label1) p2 = Pauli(label2) value = Operator(p1.tensor(p2)) op1 = operator_from_label(label1) op2 = operator_from_label(label2) target = op1.tensor(op2) self.assertEqual(value, target) @data(*it.product(pauli_group_labels(1, full_group=False), repeat=2)) @unpack def test_expand(self, label1, label2): """Test expand method.""" p1 = Pauli(label1) p2 = Pauli(label2) value = Operator(p1.expand(p2)) op1 = operator_from_label(label1) op2 = operator_from_label(label2) target = op1.expand(op2) self.assertEqual(value, target) @data("II", "XI", "YX", "ZZ", "YZ") def test_power(self, label): """Test power method.""" iden = Pauli("II") op = Pauli(label) self.assertTrue(op ** 2, iden) @data(1, 1.0, -1, -1.0, 1j, -1j) def test_multiply(self, val): """Test multiply method.""" op = val * Pauli(([True, True], [False, False], 0)) phase = (-1j) ** op.phase self.assertEqual(phase, val) def test_multiply_except(self): """Test multiply method raises exceptions.""" op = Pauli("XYZ") self.assertRaises(QiskitError, op._multiply, 2) @data(0, 1, 2, 3) def test_negate(self, phase): """Test negate method""" op = Pauli(([False], [True], phase)) neg = -op self.assertTrue(op.equiv(neg)) self.assertEqual(neg.phase, (op.phase + 2) % 4) @data(*it.product(pauli_group_labels(1, False), repeat=2)) @unpack def test_commutes(self, p1, p2): """Test commutes method""" P1 = Pauli(p1) P2 = Pauli(p2) self.assertEqual(P1.commutes(P2), P1.dot(P2) == P2.dot(P1)) @data(*it.product(pauli_group_labels(1, False), repeat=2)) @unpack def test_anticommutes(self, p1, p2): """Test anticommutes method""" P1 = Pauli(p1) P2 = Pauli(p2) self.assertEqual(P1.anticommutes(P2), P1.dot(P2) == -P2.dot(P1)) @data( *it.product( (IGate(), XGate(), YGate(), ZGate(), HGate(), SGate(), SdgGate()), pauli_group_labels(1, False), ) ) @unpack def test_evolve_clifford1(self, gate, label): """Test evolve method for 1-qubit Clifford gates.""" op = Operator(gate) pauli = Pauli(label) value = Operator(pauli.evolve(gate)) target = op.adjoint().dot(pauli).dot(op) self.assertEqual(value, target) @data(*it.product((CXGate(), CYGate(), CZGate(), SwapGate()), pauli_group_labels(2, False))) @unpack def test_evolve_clifford2(self, gate, label): """Test evolve method for 2-qubit Clifford gates.""" op = Operator(gate) pauli = Pauli(label) value = Operator(pauli.evolve(gate)) target = op.adjoint().dot(pauli).dot(op) self.assertEqual(value, target) def test_evolve_clifford_qargs(self): """Test evolve method for random Clifford""" cliff = random_clifford(3, seed=10) op = Operator(cliff) pauli = random_pauli(5, seed=10) qargs = [3, 0, 1] value = Operator(pauli.evolve(cliff, qargs=qargs)) target = Operator(pauli).compose(op.adjoint(), qargs=qargs).dot(op, qargs=qargs) self.assertEqual(value, target) if __name__ == "__main__": unittest.main()
db2dec30007a56b958be5df14fc31cc43222bbf3
dd4d1a61ec680a86d4b569490bf2a898ea0d7557
/appengine/monorail/features/test/hotlistpeople_test.py
151b295e2793391ae4ef114afc1b6c089e7a89f2
[ "BSD-3-Clause" ]
permissive
mcgreevy/chromium-infra
f1a68914b47bcbe3cd8a424f43741dd74fedddf4
09064105713603f7bf75c772e8354800a1bfa256
refs/heads/master
2022-10-29T23:21:46.894543
2017-05-16T06:22:50
2017-05-16T06:22:50
91,423,078
1
1
BSD-3-Clause
2022-10-01T18:48:03
2017-05-16T06:23:34
Python
UTF-8
Python
false
false
8,978
py
# Copyright 2016 The Chromium Authors. All rights reserved. # Use of this source code is govered by a BSD-style # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd """Unittest for Hotlist People servlet.""" import mox import unittest import logging from third_party import ezt from testing import fake from features import hotlistpeople from framework import permissions from services import service_manager from testing import testing_helpers class HotlistPeopleListTest(unittest.TestCase): def setUp(self): self.services = service_manager.Services( user=fake.UserService(), features=fake.FeaturesService()) self.owner_user = self.services.user.TestAddUser('[email protected]', 111L) self.editor_user = self.services.user.TestAddUser('[email protected]', 222L) self.non_member_user = self.services.user.TestAddUser( '[email protected]', 333L) self.private_hotlist = self.services.features.TestAddHotlist( 'PrivateHotlist', 'owner only', [111L], [222L], is_private=True) self.public_hotlist = self.services.features.TestAddHotlist( 'PublicHotlist', 'everyone', [111L], [222L], is_private=False) self.servlet = hotlistpeople.HotlistPeopleList( 'req', 'res', services=self.services) self.mox = mox.Mox() def tearDown(self): self.mox.UnsetStubs() self.mox.ResetAll() def testAssertBasePermission(self): # owner can view people in private hotlist mr = testing_helpers.MakeMonorailRequest(hotlist=self.private_hotlist) mr.auth.effective_ids = {111L, 444L} self.servlet.AssertBasePermission(mr) # editor can view people in private hotlist mr.auth.effective_ids = {222, 333L} self.servlet.AssertBasePermission(mr) # non-members cannot view people in private hotlist mr.auth.effective_ids = {444L, 333L} self.assertRaises(permissions.PermissionException, self.servlet.AssertBasePermission, mr) # owner can view people in public hotlist mr = testing_helpers.MakeMonorailRequest(hotlist=self.public_hotlist) mr.auth.effective_ids = {111L, 444L} self.servlet.AssertBasePermission(mr) # editor can view people in public hotlist mr.auth.effective_ids = {222, 333L} self.servlet.AssertBasePermission(mr) # non-members cannot view people in public hotlist mr.auth.effective_ids = {444L, 333L} self.servlet.AssertBasePermission(mr) def testGatherPageData(self): mr = testing_helpers.MakeMonorailRequest(hotlist=self.public_hotlist) mr.auth.user_id = 111L mr.auth.effective_ids = {111L} mr.cnxn = 'fake cnxn' page_data = self.servlet.GatherPageData(mr) self.assertEqual(ezt.boolean(True), page_data['offer_membership_editing']) self.assertEqual(page_data['total_num_owners'], 1) self.assertEqual(page_data['newly_added_views'], []) self.assertEqual(len(page_data['pagination'].visible_results), 2) # non-owners cannot edit people list mr.auth.user_id = 222L mr.auth.effective_ids = {222L} page_data = self.servlet.GatherPageData(mr) self.assertEqual(ezt.boolean(False), page_data['offer_membership_editing']) mr.auth.user_id = 333L mr.auth.effective_ids = {333L} page_data = self.servlet.GatherPageData(mr) self.assertEqual(ezt.boolean(False), page_data['offer_membership_editing']) def testProcessFormData_Permission(self): """Only owner can change member of hotlist.""" mr = testing_helpers.MakeMonorailRequest( path='/u/[email protected]/hotlists/PrivateHotlist/people', hotlist=self.private_hotlist, ) mr.auth.effective_ids = {111L, 444L} self.servlet.ProcessFormData(mr, {}) mr.auth.effective_ids = {222L, 444L} self.assertRaises(permissions.PermissionException, self.servlet.ProcessFormData, mr, {}) def testProcessRemoveMembers(self): hotlist = self.servlet.services.features.TestAddHotlist( 'HotlistName', 'removing 222, monica', [111L], [222L]) mr = testing_helpers.MakeMonorailRequest( path='/u/[email protected]/hotlists/HotlistName/people', hotlist=hotlist) mr.hotlist_id = hotlist.hotlist_id post_data = fake.PostData( remove = ['[email protected]']) url = self.servlet.ProcessRemoveMembers( mr, post_data, '/u/111/hotlists/HotlistName') self.assertTrue('/u/111/hotlists/HotlistName/people' in url) self.assertEqual(hotlist.editor_ids, []) def testProcessAddMembers(self): hotlist = self.servlet.services.features.TestAddHotlist( 'HotlistName', 'adding 333, who-dis', [111L], [222L]) mr = testing_helpers.MakeMonorailRequest( path='/u/[email protected]/hotlists/HotlistName/people', hotlist=hotlist) mr.hotlist_id = hotlist.hotlist_id post_data = fake.PostData( addmembers = ['[email protected]'], role = ['editor']) url = self.servlet.ProcessAddMembers( mr, post_data, '/u/111/hotlists/HotlistName') self.assertTrue('/u/111/hotlists/HotlistName/people' in url) self.assertEqual(hotlist.editor_ids, [222L, 333L]) def testProcessAddMembers_OwnerToEditor(self): hotlist = self.servlet.services.features.TestAddHotlist( 'HotlistName', 'adding owner 111, buzbuz as editor', [111L], [222L]) mr = testing_helpers.MakeMonorailRequest( path='/u/[email protected]/hotlists/HotlistName/people', hotlist=hotlist) mr.hotlist_id = hotlist.hotlist_id addmembers_input = '[email protected]' post_data = fake.PostData( addmembers = [addmembers_input], role = ['editor']) self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect') self.servlet.PleaseCorrect( mr, initial_add_members=addmembers_input, initially_expand_form=True) self.mox.ReplayAll() url = self.servlet.ProcessAddMembers( mr, post_data, '/u/111/hotlists/HotlistName') self.mox.VerifyAll() self.assertEqual( 'Cannot have a hotlist without an owner; please leave at least one.', mr.errors.addmembers) self.assertIsNone(url) # Verify that no changes have actually occurred. self.assertEqual(hotlist.owner_ids, [111L]) self.assertEqual(hotlist.editor_ids, [222L]) def testProcessChangeOwnership(self): hotlist = self.servlet.services.features.TestAddHotlist( 'HotlistName', 'new owner 333L, who-dis', [111L], [222L]) mr = testing_helpers.MakeMonorailRequest( path='/u/[email protected]/hotlists/HotlistName/people', hotlist=hotlist) mr.hotlist_id = hotlist.hotlist_id post_data = fake.PostData( changeowners = ['[email protected]'], becomeeditor = ['on']) url = self.servlet.ProcessChangeOwnership(mr, post_data) self.assertTrue('/u/333/hotlists/HotlistName/people' in url) self.assertEqual(hotlist.owner_ids, [333L]) self.assertEqual(hotlist.editor_ids, [222L, 111L]) def testProcessChangeOwnership_UnownedHotlist(self): hotlist = self.services.features.TestAddHotlist( 'unowned', 'new owner 333L, who-dis', [], [222L]) mr = testing_helpers.MakeMonorailRequest( path='/whatever', hotlist=hotlist) mr.hotlist_id = hotlist.hotlist_id post_data = fake.PostData( changeowners = ['[email protected]'], becomeeditor = ['on']) self.servlet.ProcessChangeOwnership(mr, post_data) self.assertEqual([333L], mr.hotlist.owner_ids) def testProcessChangeOwnership_BadEmail(self): hotlist = self.servlet.services.features.TestAddHotlist( 'HotlistName', 'new owner 333L, who-dis', [111L], [222L]) mr = testing_helpers.MakeMonorailRequest( path='/u/[email protected]/hotlists/HotlistName/people', hotlist=hotlist) mr.hotlist_id = hotlist.hotlist_id changeowners_input = '[email protected], [email protected]' post_data = fake.PostData( changeowners = [changeowners_input], becomeeditor = ['on']) self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect') self.servlet.PleaseCorrect( mr, initial_new_owner_username=changeowners_input, open_dialog='yes') self.mox.ReplayAll() url = self.servlet.ProcessChangeOwnership(mr, post_data) self.mox.VerifyAll() self.assertEqual( 'Please add one valid user email.', mr.errors.transfer_ownership) self.assertIsNone(url) def testProcessChangeOwnership_DuplicateName(self): # other_hotlist = self.servlet.services.features.TestAddHotlist( # 'HotlistName', 'hotlist with same name', [333L], []) # hotlist = self.servlet.services.features.TestAddHotlist( # 'HotlistName', 'new owner 333L, who-dis', [111L], [222L]) # in the test_hotlists dict of features_service in testing/fake # 'other_hotlist' is overwritten by 'hotlist' # TODO(jojwang): edit the fake features_service to allow hotlists # with the same name but different owners pass
d31c776481fd364a69f142b802d07b602b554709
6a77b42871d1996b9037e3be4fea31436315c8ab
/ex010.py
3b6f1fbb97495408980a0eb09e2484890909cee1
[]
no_license
RaphaelMolina/Curso_em_video_Python3
4e1e299681695db69a0439107b32ae90cdea32f5
f22100865d7137bc420b677f118c848d963ee90a
refs/heads/master
2022-01-10T09:48:25.777665
2022-01-06T16:23:52
2022-01-06T16:23:52
244,028,670
1
0
null
null
null
null
UTF-8
Python
false
false
614
py
limpar = str('\033[m') texto = {'vermelho': '\033[31m', 'roxo': '\033[35m', 'verde2': '\033[36m'} e = str('{} Exercício 10 {}'.format(texto['vermelho'], texto['verde2'])) print('{}{:=^30}{}\n'.format(texto['verde2'], e, limpar)) real = float(input('{}Informe o valor que você tem: R${}'.format(texto['roxo'], limpar))) dolar = float(real / 3.27) print('Você tem {}R${:.2f}{}, e com esse valor você pode comprar {}US${:.2f}{}.'.format(texto['vermelho'], real, limpar, texto['verde2'], dolar, limpar))
595c56fcc014bb1788d24e282c081e6312b22474
6f05f7d5a67b6bb87956a22b988067ec772ba966
/data/train/python/e75506567100fd23fb9cfac67ee2e5a327bd5106svnsync.py
e75506567100fd23fb9cfac67ee2e5a327bd5106
[ "MIT" ]
permissive
harshp8l/deep-learning-lang-detection
93b6d24a38081597c610ecf9b1f3b92c7d669be5
2a54293181c1c2b1a2b840ddee4d4d80177efb33
refs/heads/master
2020-04-07T18:07:00.697994
2018-11-29T23:21:23
2018-11-29T23:21:23
158,597,498
0
0
MIT
2018-11-21T19:36:42
2018-11-21T19:36:41
null
UTF-8
Python
false
false
759
py
from django.core import management from django.utils.translation import ugettext as _ from cobra.core.loading import get_model Repository = get_model('svnkit', 'Repository') class Command(management.BaseCommand): help = _('Get repository changes') args = _('<repository repository ...>') def handle(self, *args, **options): if args: try: rlist = map( lambda r: Repository.objects.get(label=r), args) except Repository.DoesNotExist, error: raise management.CommandError(error) else: rlist = Repository.objects.all() for r in rlist: print _('Syncing %(label)s...') % {'label': r.label} r.sync()
15f042bfdb833b3208d5ce43dd07ced63845ca7d
e2df44c68460fb29084ba0ed6f3266d8802f6cb1
/catkin_ws/build/sweep-ros/catkin_generated/pkg.installspace.context.pc.py
3a4d51f308fd00dd98a43315afe661999fdaabaf
[]
no_license
harshilpatel312/TSRT10
879bfcbb882d6bc32111f3145f3637c1df8e2b55
be8d3a90c75a6655fb82392a43c75135686a7eb8
refs/heads/master
2020-03-22T15:03:35.347270
2017-12-14T08:22:26
2017-12-14T08:22:26
null
0
0
null
null
null
null
UTF-8
Python
false
false
393
py
# generated from catkin/cmake/template/pkg.context.pc.in CATKIN_PACKAGE_PREFIX = "" PROJECT_PKG_CONFIG_INCLUDE_DIRS = "".split(';') if "" != "" else [] PROJECT_CATKIN_DEPENDS = "sensor_msgs".replace(';', ' ') PKG_CONFIG_LIBRARIES_WITH_PREFIX = "".split(';') if "" != "" else [] PROJECT_NAME = "sweep_ros" PROJECT_SPACE_DIR = "/home/fregu856/TSRT10/catkin_ws/install" PROJECT_VERSION = "0.2.0"
e0a1077fbd17413ed11b60a19920e236e5011c79
b63142e8540cb30bb0c663332e29a4112721073e
/991_bulb_switcher.py
b0edfd386263155bb770ccc464f73ea73b088d90
[]
no_license
HaydenInEdinburgh/LintCode
025bb2f0d75686097061de324c0fd292536dbb14
dbeae2bf631e57667d1415164d452d5ca2df7447
refs/heads/master
2023-08-18T19:52:54.561623
2021-10-06T21:46:50
2021-10-06T21:46:50
370,733,548
0
0
null
null
null
null
UTF-8
Python
false
false
212
py
import math class Solution: """ @param n: a Integer @return: how many bulbs are on after n rounds """ def bulbSwitch(self, n): # Write your code here return int(math.sqrt(n))
26e22b6839aef35f5e82a48054dc5008d70a29de
82a63effc9886c749b349bb0672238dc4a68e66d
/2019/007_Pixel_3a_low_level_checker/blog_img/blog_sample.py
f051aede8dc403684662dc5bc6450cd5aad8e342
[ "BSD-3-Clause" ]
permissive
toru-ver4/sample_code
6250f4bf7b437b7ee394cbc198d48fd2de209c3f
58e9925af645e110e4a4a306001ba73599d0b192
refs/heads/develop
2023-07-22T00:52:48.568631
2023-07-15T07:03:00
2023-07-15T07:03:00
201,731,599
32
4
BSD-3-Clause
2023-09-10T14:46:41
2019-08-11T07:19:29
Python
UTF-8
Python
false
false
1,453
py
import numpy as np from colour import xyY_to_XYZ, XYZ_to_RGB, RGB_to_XYZ, XYZ_to_xyY from colour.models import BT709_COLOURSPACE # BT.709色域外の xyY データ。Y は Green の Primariy に合わせた。 xyY_bt2020 = np.array([[0.26666249, 0.47998497, 0.67799807], [0.25055208, 0.5328208, 0.67799807], [0.23444166, 0.58565664, 0.67799807], [0.21833125, 0.63849248, 0.67799807], [0.20222083, 0.69132832, 0.67799807], [0.18611042, 0.74416416, 0.67799807], [0.17, 0.797, 0.67799807]]) d65 = np.array([0.3127, 0.3290]) if __name__ == '__main__': # とりあえず XYZ する large_xyz_bt2020 = xyY_to_XYZ(xyY_bt2020) # BT.2020 --> BT.709 のRGB値へ変換 rgb_linear_bt709 = XYZ_to_RGB( XYZ=large_xyz_bt2020, illuminant_XYZ=d65, illuminant_RGB=d65, XYZ_to_RGB_matrix=BT709_COLOURSPACE.XYZ_to_RGB_matrix) # BT.709 の式域内にクリッピング print(rgb_linear_bt709) rgb_linear_bt709_clipped = np.clip(rgb_linear_bt709, 0.0, 1.0) # xyY に変換して最終出力する large_xyz_bt709_clipped = RGB_to_XYZ( RGB=rgb_linear_bt709_clipped, illuminant_RGB=d65, illuminant_XYZ=d65, RGB_to_XYZ_matrix=BT709_COLOURSPACE.RGB_to_XYZ_matrix) xyY_bt709_clipped = XYZ_to_xyY(large_xyz_bt709_clipped) print(xyY_bt709_clipped)
c15e6f6228c343e9f14a01e55ca845ac24416893
c30ea40903626c46d0ffdbd18fa29caf15b60633
/setup.py
b11b9328ca3779182467af8051f79b2e085f5cb8
[ "MIT" ]
permissive
zcutlip/WithTimer
d5c36d3e25d0abd0002ed23cc26cd060b42690e5
f35e0c20656d782ceb03b0839f24c58441a2d4f2
refs/heads/master
2020-06-26T17:16:07.998239
2019-10-02T23:04:53
2019-10-02T23:04:53
199,696,970
0
0
null
null
null
null
UTF-8
Python
false
false
666
py
from __future__ import absolute_import from setuptools import setup about = {} with open("withtimer/__about__.py") as fp: exec(fp.read(), about) with open("README.md", "r") as fp: long_description = fp.read() setup(name=about["__title__"], version=about["__version__"], description=about["__summary__"], long_description=long_description, license="MIT", author="Zachary Cutlip", long_description_content_type="text/markdown", url="https://github.com/zcutlip/withtimer", packages=['withtimer'], python_requires='>=2.7', install_requires=[], package_data={'withtimer': ['config/*']}, )
c4bae031a577fcea75547d1ba262bda935942fca
971e0efcc68b8f7cfb1040c38008426f7bcf9d2e
/tests/artificial/transf_Anscombe/trend_LinearTrend/cycle_0/ar_/test_artificial_128_Anscombe_LinearTrend_0__100.py
973499cfb993888a51e2d2621daa4fe908a9f9dd
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
antoinecarme/pyaf
a105d172c2e7544f8d580d75f28b751351dd83b6
b12db77cb3fa9292e774b2b33db8ce732647c35e
refs/heads/master
2023-09-01T09:30:59.967219
2023-07-28T20:15:53
2023-07-28T20:15:53
70,790,978
457
77
BSD-3-Clause
2023-03-08T21:45:40
2016-10-13T09:30:30
Python
UTF-8
Python
false
false
266
py
import pyaf.Bench.TS_datasets as tsds import tests.artificial.process_artificial_dataset as art art.process_dataset(N = 128 , FREQ = 'D', seed = 0, trendtype = "LinearTrend", cycle_length = 0, transform = "Anscombe", sigma = 0.0, exog_count = 100, ar_order = 0);
8b5efe98fef0e5252e6c998598fe9ecaf19a706e
651a296c8f45b5799781fd78a6b5329effe702a0
/polpak/eulerian.py
3ef0e9fa8c13e3e673239e4e69f7e2443d391722
[]
no_license
pdhhiep/Computation_using_Python
095d14370fe1a01a192d7e44fcc81a52655f652b
407ed29fddc267950e9860b8bbd1e038f0387c97
refs/heads/master
2021-05-29T12:35:12.630232
2015-06-27T01:05:17
2015-06-27T01:05:17
null
0
0
null
null
null
null
UTF-8
Python
false
false
2,376
py
#!/usr/bin/env python # def eulerian ( n ): #*****************************************************************************80 # ## EULERIAN computes the Eulerian number E(N,K). # # Definition: # # A run in a permutation is a sequence of consecutive ascending values. # # E(N,K) is the number of permutations of N objects which contain # exactly K runs. # # Examples: # # N = 7 # # 1 0 0 0 0 0 0 # 1 1 0 0 0 0 0 # 1 4 1 0 0 0 0 # 1 11 11 1 0 0 0 # 1 26 66 26 1 0 0 # 1 57 302 302 57 1 0 # 1 120 1191 2416 1191 120 1 # # Recursion: # # E(N,K) = K * E(N-1,K) + (N-K+1) * E(N-1,K-1). # # Properties: # # E(N,1) = E(N,N) = 1. # E(N,K) = 0 if K <= 0 or N < K. # sum ( 1 <= K <= N ) E(N,K) = N!. # X^N = sum ( 0 <= K <= N ) COMB(X+K-1, N ) E(N,K) # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 04 February 2015 # # Author: # # John Burkardt # # Reference: # # Dennis Stanton and Dennis White, # Constructive Combinatorics, # Springer Verlag, 1986 # # Parameters: # # Input, integer N, the number of rows desired. # # Output, integer E(N,N), the first N rows of Eulerian numbers. # import numpy as np e = np.zeros ( ( n, n ) ) # # Construct rows 1, 2, ..., N of the Eulerian triangle. # e[0,0] = 1 for j in range ( 1, n ): e[0,j] = 0 for i in range ( 1, n ): e[i,0] = 1 for j in range ( 1, n ): e[i,j] = ( j + 1 ) * e[i-1,j] + ( i - j + 1 ) * e[i-1,j-1] return e def eulerian_test ( ): #*****************************************************************************80 # ## EULERIAN_TEST tests EULERIAN. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 04 February 2015 # # Author: # # John Burkardt # print '' print 'EULERIAN_TEST' print ' EULERIAN computes Eulerian numbers.' n = 7 e = eulerian ( n ) for i in range ( 0, n ): for j in range ( 0, n ): print ' %4d' % ( e[i,j] ), print '' print '' print 'EULERIAN_TEST' print ' Normal end of execution.' return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) eulerian_test ( ) timestamp ( )
bbe9549071f9a440a30dfdc52585c6d3a061d9a8
de220992793da3fedd11953c54efe32b0bf70535
/remoterun/__main__.py
df999132bffc7ce3da0dde6adff12af3ae8ffb3c
[ "MIT" ]
permissive
phizaz/remote-run
f358a28d75bb629fe4119104830e4da74099f83a
9694596a371a69a472622d6990f8402ad6927932
refs/heads/master
2020-01-27T10:05:55.583090
2019-08-20T14:18:55
2019-08-20T14:18:55
66,771,111
1
0
null
2019-08-20T14:18:56
2016-08-28T13:59:40
Python
UTF-8
Python
false
false
69
py
if __name__ == '__main__': from .remoterun import main main()
0130a9aa669218ef045af0d2fc6e46d6775d1618
c16ea32a4cddb6b63ad3bacce3c6db0259d2bacd
/google/ads/googleads/v4/googleads-py/tests/unit/gapic/googleads.v4/services/test_hotel_performance_view_service.py
fb8466e0ab5bc9d8740b76b906fbd17bbad29c94
[ "Apache-2.0" ]
permissive
dizcology/googleapis-gen
74a72b655fba2565233e5a289cfaea6dc7b91e1a
478f36572d7bcf1dc66038d0e76b9b3fa2abae63
refs/heads/master
2023-06-04T15:51:18.380826
2021-06-16T20:42:38
2021-06-16T20:42:38
null
0
0
null
null
null
null
UTF-8
Python
false
false
30,872
py
# -*- coding: utf-8 -*- # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import os from unittest import mock import grpc import math import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule from google.ads.googleads.v4.resources.types import hotel_performance_view from google.ads.googleads.v4.services.services.hotel_performance_view_service import HotelPerformanceViewServiceClient from google.ads.googleads.v4.services.services.hotel_performance_view_service import transports from google.ads.googleads.v4.services.types import hotel_performance_view_service from google.api_core import client_options from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.oauth2 import service_account import google.auth def client_cert_source_callback(): return b"cert bytes", b"key bytes" # If default endpoint is localhost, then default mtls endpoint will be the same. # This method modifies the default endpoint so the client can produce a different # mtls endpoint for endpoint testing purposes. def modify_default_endpoint(client): return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT def test__get_default_mtls_endpoint(): api_endpoint = "example.googleapis.com" api_mtls_endpoint = "example.mtls.googleapis.com" sandbox_endpoint = "example.sandbox.googleapis.com" sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" non_googleapi = "api.example.com" assert HotelPerformanceViewServiceClient._get_default_mtls_endpoint(None) is None assert HotelPerformanceViewServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint assert HotelPerformanceViewServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint assert HotelPerformanceViewServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint assert HotelPerformanceViewServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint assert HotelPerformanceViewServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi def test_hotel_performance_view_service_client_from_service_account_info(): creds = ga_credentials.AnonymousCredentials() with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: factory.return_value = creds info = {"valid": True} client = HotelPerformanceViewServiceClient.from_service_account_info(info) assert client.transport._credentials == creds assert client.transport._host == 'googleads.googleapis.com:443' def test_hotel_performance_view_service_client_from_service_account_file(): creds = ga_credentials.AnonymousCredentials() with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: factory.return_value = creds client = HotelPerformanceViewServiceClient.from_service_account_file("dummy/file/path.json") assert client.transport._credentials == creds client = HotelPerformanceViewServiceClient.from_service_account_json("dummy/file/path.json") assert client.transport._credentials == creds assert client.transport._host == 'googleads.googleapis.com:443' def test_hotel_performance_view_service_client_get_transport_class(): transport = HotelPerformanceViewServiceClient.get_transport_class() assert transport == transports.HotelPerformanceViewServiceGrpcTransport transport = HotelPerformanceViewServiceClient.get_transport_class("grpc") assert transport == transports.HotelPerformanceViewServiceGrpcTransport @mock.patch.object(HotelPerformanceViewServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(HotelPerformanceViewServiceClient)) def test_hotel_performance_view_service_client_client_options(): # Check that if channel is provided we won't create a new one. with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.HotelPerformanceViewServiceClient.get_transport_class') as gtc: transport = transports.HotelPerformanceViewServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials() ) client = HotelPerformanceViewServiceClient(transport=transport) gtc.assert_not_called() # Check that if channel is provided via str we will create a new one. with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.HotelPerformanceViewServiceClient.get_transport_class') as gtc: client = HotelPerformanceViewServiceClient(transport="grpc") gtc.assert_called() # Check the case api_endpoint is provided. options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceGrpcTransport.__init__') as grpc_transport: grpc_transport.return_value = None client = HotelPerformanceViewServiceClient(client_options=options) grpc_transport.assert_called_once_with( ssl_channel_credentials=None, credentials=None, host="squid.clam.whelk", client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT # is "never". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceGrpcTransport.__init__') as grpc_transport: grpc_transport.return_value = None client = HotelPerformanceViewServiceClient() grpc_transport.assert_called_once_with( ssl_channel_credentials=None, credentials=None, host=client.DEFAULT_ENDPOINT, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "always". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceGrpcTransport.__init__') as grpc_transport: grpc_transport.return_value = None client = HotelPerformanceViewServiceClient() grpc_transport.assert_called_once_with( ssl_channel_credentials=None, credentials=None, host=client.DEFAULT_MTLS_ENDPOINT, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): client = HotelPerformanceViewServiceClient() # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): with pytest.raises(ValueError): client = HotelPerformanceViewServiceClient() @mock.patch.object(HotelPerformanceViewServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(HotelPerformanceViewServiceClient)) @mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) @pytest.mark.parametrize("use_client_cert_env", ["true", "false"]) def test_hotel_performance_view_service_client_mtls_env_auto(use_client_cert_env): # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. # Check the case client_cert_source is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceGrpcTransport.__init__') as grpc_transport: ssl_channel_creds = mock.Mock() with mock.patch('grpc.ssl_channel_credentials', return_value=ssl_channel_creds): grpc_transport.return_value = None client = HotelPerformanceViewServiceClient(client_options=options) if use_client_cert_env == "false": expected_ssl_channel_creds = None expected_host = client.DEFAULT_ENDPOINT else: expected_ssl_channel_creds = ssl_channel_creds expected_host = client.DEFAULT_MTLS_ENDPOINT grpc_transport.assert_called_once_with( ssl_channel_credentials=expected_ssl_channel_creds, credentials=None, host=expected_host, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceGrpcTransport.__init__') as grpc_transport: with mock.patch('google.auth.transport.grpc.SslCredentials.__init__', return_value=None): with mock.patch('google.auth.transport.grpc.SslCredentials.is_mtls', new_callable=mock.PropertyMock) as is_mtls_mock: with mock.patch('google.auth.transport.grpc.SslCredentials.ssl_credentials', new_callable=mock.PropertyMock) as ssl_credentials_mock: if use_client_cert_env == "false": is_mtls_mock.return_value = False ssl_credentials_mock.return_value = None expected_host = client.DEFAULT_ENDPOINT expected_ssl_channel_creds = None else: is_mtls_mock.return_value = True ssl_credentials_mock.return_value = mock.Mock() expected_host = client.DEFAULT_MTLS_ENDPOINT expected_ssl_channel_creds = ssl_credentials_mock.return_value grpc_transport.return_value = None client = HotelPerformanceViewServiceClient() grpc_transport.assert_called_once_with( ssl_channel_credentials=expected_ssl_channel_creds, credentials=None, host=expected_host, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case client_cert_source and ADC client cert are not provided. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceGrpcTransport.__init__') as grpc_transport: with mock.patch('google.auth.transport.grpc.SslCredentials.__init__', return_value=None): with mock.patch('google.auth.transport.grpc.SslCredentials.is_mtls', new_callable=mock.PropertyMock) as is_mtls_mock: is_mtls_mock.return_value = False grpc_transport.return_value = None client = HotelPerformanceViewServiceClient() grpc_transport.assert_called_once_with( ssl_channel_credentials=None, credentials=None, host=client.DEFAULT_ENDPOINT, client_info=transports.base.DEFAULT_CLIENT_INFO, ) def test_hotel_performance_view_service_client_client_options_from_dict(): with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceGrpcTransport.__init__') as grpc_transport: grpc_transport.return_value = None client = HotelPerformanceViewServiceClient( client_options={'api_endpoint': 'squid.clam.whelk'} ) grpc_transport.assert_called_once_with( ssl_channel_credentials=None, credentials=None, host="squid.clam.whelk", client_info=transports.base.DEFAULT_CLIENT_INFO, ) def test_get_hotel_performance_view(transport: str = 'grpc', request_type=hotel_performance_view_service.GetHotelPerformanceViewRequest): client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.get_hotel_performance_view), '__call__') as call: # Designate an appropriate return value for the call. call.return_value = hotel_performance_view.HotelPerformanceView( resource_name='resource_name_value', ) response = client.get_hotel_performance_view(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == hotel_performance_view_service.GetHotelPerformanceViewRequest() # Establish that the response is the type that we expect. assert isinstance(response, hotel_performance_view.HotelPerformanceView) assert response.resource_name == 'resource_name_value' def test_get_hotel_performance_view_from_dict(): test_get_hotel_performance_view(request_type=dict) def test_get_hotel_performance_view_field_headers(): client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = hotel_performance_view_service.GetHotelPerformanceViewRequest() request.resource_name = 'resource_name/value' # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.get_hotel_performance_view), '__call__') as call: call.return_value = hotel_performance_view.HotelPerformanceView() client.get_hotel_performance_view(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == request # Establish that the field header was sent. _, _, kw = call.mock_calls[0] assert ( 'x-goog-request-params', 'resource_name=resource_name/value', ) in kw['metadata'] def test_get_hotel_performance_view_flattened(): client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.get_hotel_performance_view), '__call__') as call: # Designate an appropriate return value for the call. call.return_value = hotel_performance_view.HotelPerformanceView() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_hotel_performance_view( resource_name='resource_name_value', ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0].resource_name == 'resource_name_value' def test_get_hotel_performance_view_flattened_error(): client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_hotel_performance_view( hotel_performance_view_service.GetHotelPerformanceViewRequest(), resource_name='resource_name_value', ) def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.HotelPerformanceViewServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.HotelPerformanceViewServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) client = HotelPerformanceViewServiceClient(transport=transport) assert client.transport is transport def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.HotelPerformanceViewServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( client.transport, transports.HotelPerformanceViewServiceGrpcTransport, ) @pytest.mark.parametrize("transport_class", [ transports.HotelPerformanceViewServiceGrpcTransport, ]) def test_transport_adc(transport_class): # Test default credentials are used if not provided. with mock.patch.object(google.auth, 'default') as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_hotel_performance_view_service_base_transport(): # Instantiate the base transport. with mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceTransport.__init__') as Transport: Transport.return_value = None transport = transports.HotelPerformanceViewServiceTransport( credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly # raise NotImplementedError. methods = ( 'get_hotel_performance_view', ) for method in methods: with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) def test_hotel_performance_view_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, 'default') as adc, mock.patch('google.ads.googleads.v4.services.services.hotel_performance_view_service.transports.HotelPerformanceViewServiceTransport._prep_wrapped_messages') as Transport: Transport.return_value = None adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.HotelPerformanceViewServiceTransport() adc.assert_called_once() def test_hotel_performance_view_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, 'default') as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) HotelPerformanceViewServiceClient() adc.assert_called_once_with(scopes=( 'https://www.googleapis.com/auth/adwords', )) def test_hotel_performance_view_service_transport_auth_adc(): # If credentials and host are not provided, the transport class should use # ADC credentials. with mock.patch.object(google.auth, 'default') as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transports.HotelPerformanceViewServiceGrpcTransport(host="squid.clam.whelk") adc.assert_called_once_with(scopes=( 'https://www.googleapis.com/auth/adwords', )) def test_hotel_performance_view_service_host_no_port(): client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint='googleads.googleapis.com'), ) assert client.transport._host == 'googleads.googleapis.com:443' def test_hotel_performance_view_service_host_with_port(): client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint='googleads.googleapis.com:8000'), ) assert client.transport._host == 'googleads.googleapis.com:8000' def test_hotel_performance_view_service_grpc_transport_channel(): channel = grpc.insecure_channel('http://localhost/') # Check that channel is used if provided. transport = transports.HotelPerformanceViewServiceGrpcTransport( host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" assert transport._ssl_channel_credentials == None @pytest.mark.parametrize("transport_class", [transports.HotelPerformanceViewServiceGrpcTransport]) def test_hotel_performance_view_service_transport_channel_mtls_with_client_cert_source( transport_class ): with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: with mock.patch.object(transport_class, "create_channel", autospec=True) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): with mock.patch.object(google.auth, 'default') as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", api_mtls_endpoint="mtls.squid.clam.whelk", client_cert_source=client_cert_source_callback, ) adc.assert_called_once() grpc_ssl_channel_cred.assert_called_once_with( certificate_chain=b"cert bytes", private_key=b"key bytes" ) grpc_create_channel.assert_called_once_with( "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, scopes=( 'https://www.googleapis.com/auth/adwords', ), ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], ) assert transport.grpc_channel == mock_grpc_channel assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize("transport_class", [transports.HotelPerformanceViewServiceGrpcTransport,]) def test_hotel_performance_view_service_transport_channel_mtls_with_adc( transport_class ): mock_ssl_cred = mock.Mock() with mock.patch.multiple( "google.auth.transport.grpc.SslCredentials", __init__=mock.Mock(return_value=None), ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object(transport_class, "create_channel", autospec=True) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel mock_cred = mock.Mock() with pytest.warns(DeprecationWarning): transport = transport_class( host="squid.clam.whelk", credentials=mock_cred, api_mtls_endpoint="mtls.squid.clam.whelk", client_cert_source=None, ) grpc_create_channel.assert_called_once_with( "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, scopes=( 'https://www.googleapis.com/auth/adwords', ), ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], ) assert transport.grpc_channel == mock_grpc_channel def test_hotel_performance_view_path(): customer = "squid" expected = "customers/{customer}/hotelPerformanceView".format(customer=customer, ) actual = HotelPerformanceViewServiceClient.hotel_performance_view_path(customer) assert expected == actual def test_parse_hotel_performance_view_path(): expected = { "customer": "clam", } path = HotelPerformanceViewServiceClient.hotel_performance_view_path(**expected) # Check that the path construction is reversible. actual = HotelPerformanceViewServiceClient.parse_hotel_performance_view_path(path) assert expected == actual def test_common_billing_account_path(): billing_account = "whelk" expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) actual = HotelPerformanceViewServiceClient.common_billing_account_path(billing_account) assert expected == actual def test_parse_common_billing_account_path(): expected = { "billing_account": "octopus", } path = HotelPerformanceViewServiceClient.common_billing_account_path(**expected) # Check that the path construction is reversible. actual = HotelPerformanceViewServiceClient.parse_common_billing_account_path(path) assert expected == actual def test_common_folder_path(): folder = "oyster" expected = "folders/{folder}".format(folder=folder, ) actual = HotelPerformanceViewServiceClient.common_folder_path(folder) assert expected == actual def test_parse_common_folder_path(): expected = { "folder": "nudibranch", } path = HotelPerformanceViewServiceClient.common_folder_path(**expected) # Check that the path construction is reversible. actual = HotelPerformanceViewServiceClient.parse_common_folder_path(path) assert expected == actual def test_common_organization_path(): organization = "cuttlefish" expected = "organizations/{organization}".format(organization=organization, ) actual = HotelPerformanceViewServiceClient.common_organization_path(organization) assert expected == actual def test_parse_common_organization_path(): expected = { "organization": "mussel", } path = HotelPerformanceViewServiceClient.common_organization_path(**expected) # Check that the path construction is reversible. actual = HotelPerformanceViewServiceClient.parse_common_organization_path(path) assert expected == actual def test_common_project_path(): project = "winkle" expected = "projects/{project}".format(project=project, ) actual = HotelPerformanceViewServiceClient.common_project_path(project) assert expected == actual def test_parse_common_project_path(): expected = { "project": "nautilus", } path = HotelPerformanceViewServiceClient.common_project_path(**expected) # Check that the path construction is reversible. actual = HotelPerformanceViewServiceClient.parse_common_project_path(path) assert expected == actual def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) actual = HotelPerformanceViewServiceClient.common_location_path(project, location) assert expected == actual def test_parse_common_location_path(): expected = { "project": "squid", "location": "clam", } path = HotelPerformanceViewServiceClient.common_location_path(**expected) # Check that the path construction is reversible. actual = HotelPerformanceViewServiceClient.parse_common_location_path(path) assert expected == actual def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object(transports.HotelPerformanceViewServiceTransport, '_prep_wrapped_messages') as prep: client = HotelPerformanceViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) with mock.patch.object(transports.HotelPerformanceViewServiceTransport, '_prep_wrapped_messages') as prep: transport_class = HotelPerformanceViewServiceClient.get_transport_class() transport = transport_class( credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)
[ "bazel-bot-development[bot]@users.noreply.github.com" ]
bazel-bot-development[bot]@users.noreply.github.com
f088c65f4fa33a034de7b94bd162a19cf66086a6
18bf8cc986763d381c35ae2a38560cce655020b1
/week10/01-Vehicle-Repair-Manager/example/database_layer/database.py
766313fd3c4a3e42afb3d74a228069ff65644fd0
[]
no_license
markomatke/Programming101-Python-2018
3d2e467bec283469a372a55d66a911e231ca780c
9e3181a98f8df2e2a0801faca04d4e41acb9b6f4
refs/heads/master
2020-04-08T11:50:36.277683
2018-06-13T13:50:21
2018-06-13T13:50:21
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,915
py
import sqlite3 class Column: def __init__(self, name, column_type, is_nullable=False, is_fk=False, ref_table=None): self.name = name self.column_type = column_type self.is_nullable = is_nullable self.is_fk = is_fk self.ref_table = ref_table @property def nullable(self): return 'NOT NULL' if not self.is_nullable else '' @property def foreign_key(self): if not self.is_fk: return '' return ",\n FOREIGN KEY ({name}) REFERENCES {ref_table}(ID)".format( name=self.name, ref_table=self.ref_table ) @property def to_sql_string(self): return "{name} {column_type} {nullable} {foreign_key}".format( name=self.name, column_type=self.column_type, nullable=self.nullable, foreign_key=self.foreign_key ) class Database: def __init__(self, db_name): self.db_name = db_name @classmethod def create_table(cls, db_name, table_name, columns): CREATE_TABLE_SQL = """ CREATE TABLE IF NOT EXISTS {table_name} ( ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, {columns} ) """.format(table_name=table_name, columns=",\n ".join([c.to_sql_string for c in columns])) db = sqlite3.connect(db_name) crs = db.cursor() crs.execute(CREATE_TABLE_SQL) db.commit() db.close() if __name__ == '__main__': DB_NAME = 'vehicle_system2.db' db = Database(DB_NAME) db.create_table(db_name=DB_NAME, table_name='base_user', columns=[ Column('user_name', 'text'), Column('email', 'text'), Column('phone_number', 'text'), Column('address', 'text', True) ])
9367da03a729c28a42db9948dbd97391e306a02b
6e6103826c37d26ffefdebee1fcd5b4a580c8b5e
/정리/20180206/urllib function 2.py
8c53e80aebcc13997a9975103941c1df75c26a22
[]
no_license
ljg95924/multicampus_bigdata
34023a1bb121aa0f96910805bd70d7206534c738
75178c65fd2000dd1181860f5f7166c7635a5715
refs/heads/master
2021-05-09T05:34:54.657655
2018-02-26T08:00:35
2018-02-26T08:00:35
119,315,338
0
0
null
null
null
null
UTF-8
Python
false
false
370
py
import os print(os.path.split("C:\\python36\\NEWS.txt")) #파일과 폴더의 경로를 구분해주는 함수 join_1=os.path.split("C:\\python36\\news.txt") print(join_1) print(os.path.join(join_1[0],join_1[1])) #파일 이름과 폴더 이름을 합쳐주는 함수 print(os.path.dirname("C:\\python36\\news.txt")) print(os.path.basename("C:\\python36\\news.txt"))
921e4f26abedf4bc46920425a197ff9ff3695829
e7e53dfb57f1ad027c70c82a6d5bfc2bff7fe381
/vis_imagine_static_voxels/lib/modules/kld.py
03919ed0593994178677af5314e509af48396f92
[ "Apache-2.0" ]
permissive
standardgalactic/EmbLang
555855dcfc858d856159997c5425bd5099a67761
169b0468ccda554896973bcc226afb3e762a70e7
refs/heads/master
2023-07-09T16:46:01.900556
2021-07-24T11:53:36
2021-07-24T11:53:36
null
0
0
null
null
null
null
UTF-8
Python
false
false
291
py
import tensorflow as tf import numpy as np from keras import backend as K class KLD(tf.keras.Model): def __init__(self): super(KLD, self).__init__() @tf.function def call(self, mu, var): kld = 0.5 * K.sum(K.exp(var) + K.square(mu) - 1. - var) return kld
a7d6092aab9b8be864eedc389fddfad246976898
b84ff2535544ffe11b81332a99fd6b1c73a9a04b
/01/taokecheng/work2.py
f07d5f956bd897ab03e554265c2a2c9a039eafca
[]
no_license
imsilence/actual_05_homework_mage
ea9170fbae181c524c606e87a86882735c6741a1
66c7b581c5f396083318d451c8e066b04569ba32
refs/heads/master
2021-05-11T09:24:17.095398
2018-01-19T04:05:46
2018-01-19T04:05:46
118,074,930
0
1
null
null
null
null
UTF-8
Python
false
false
925
py
#!/bin/evn python #encoding:utf-8 import random random_num = random.randint(0,100) sum = 0 print('游戏开始,有5次机会猜数字...') guest_num = input('请输入你猜测的数字(0-100): ') while True: if len(guest_num.strip()) == 0 or not guest_num.strip().isdigit(): print('-'*40) guest_num = input('错误! 只能输入数字,请重新输入,范围是(0-100):') continue else: sum += 1 guest_num = int(guest_num) if guest_num < random_num: print('\t猜小了!你还有 ',5-sum,' 次机会!') elif guest_num > random_num: print('\t猜大了!你还有 ',5-sum,' 次机会!') elif guest_num == random_num: print('\t猜对了,程序结束') break if sum == 5: print('-' * 40) print('5 次机会已经用完,游戏结束!') break else: guest_num = input('请输入你猜测的数字(0-100): ') ''' 功能ok, 继续加油 '''
20c6867b8db3f9a1eb5100ddb0bec47224a0c8fb
285e244795836b9ab725383f34bac5f1d1fd08e7
/Competitive Coding/DCL2015A.py
32747d852a762a10fc53358621496e38c1f2a394
[]
no_license
Swarajk7/Programs
2ef5d98d9d1fddefcde6147af7e9404f229f759f
9fb7224058c6d20963d3562a8bc16124dc2e7742
refs/heads/master
2020-05-16T08:41:50.251925
2017-05-19T11:29:41
2017-05-19T11:29:41
32,454,166
0
0
null
null
null
null
UTF-8
Python
false
false
583
py
val=10005 primes=[True]*val primes[0]=primes[1]=-1 for i in range(2,val): if not primes[i]: continue j=i+i while j<val: primes[j]=False j+=i def get(i): if i>='a': return ord(i)-ord('a') else: return ord(i)-ord('A')+26 t=int(input()) for i in range(t): #print i, a=raw_input() hsh=[0]*52 for i in a: hsh[get(i)]+=1 z=max(hsh) ans=0 for ii in hsh: #print ii,primes[ii],primes[z] if primes[z]!=-1 and primes[ii]==primes[z]: ans+=ii-(ii/2) else: ans+=ii print ans
daefeef00873041839c6900ac98b2dfb959857c0
779af350dd09ac5fa685d1d94e9576240d5c4fdf
/env_var.py
4b424fa10df92cc96d7fe8986a70e19ef1abe350
[]
no_license
RaenonX-DL/dragalia-site-back
543227245f37174eaff88adb46609cad7e34a00d
d15a4821c8249ec2ab80ca6f1ce91066e4f93b48
refs/heads/main
2023-04-30T04:02:18.447944
2021-05-11T21:52:04
2021-05-11T21:52:04
305,549,653
3
0
null
null
null
null
UTF-8
Python
false
false
372
py
"""Convenient functions to extract information from the environment variables.""" import os __all__ = ("is_testing",) def is_testing() -> bool: """ Check if the environment variable ``TEST`` has been set to ``1`` to indicate it's testing. :return: if the environment variables indicates it's testing """ return bool(int(os.environ.get("TEST", 0)))
b0436ffaab15913c99d36cd1257f032d228d8b8a
d8c1f119d1349dd8ad2e48619a8c258967cd9a31
/PS_vsCode/1080. 행렬.py
1d3b82b7881ffb630ce862db8db6ce0f3e3d3600
[]
no_license
Seonghyeony/DataStructure-Algorithm
c7c006ee705b68fc4d2d04dc6baaf0aeb80fc83e
4121289cafd0050bda408934fcb14d88052c956f
refs/heads/master
2023-04-12T16:30:17.039109
2021-05-08T10:31:05
2021-05-08T10:31:05
286,371,604
0
0
null
null
null
null
UTF-8
Python
false
false
407
py
N, M = map(int, input().split()) def input_str(): return [list(map(int, list(input()))) for _ in range(N)] A, B = input_str(), input_str() def flip(x, y, A): for i in range(3): for j in range(3): A[x+i][y+j] ^= 1 ans = 0 for i in range(N-2): for j in range(M-2): if A[i][j] != B[i][j]: flip(i, j, A) ans += 1 print(ans if A == B else -1)
f3e2c539d1e61d68557b3c7e88d64a39aeae697a
b3b066a566618f49ae83c81e963543a9b956a00a
/Introduction to Data Visualization with Matplotlib/04_Sharing visualizations with others/02_Switching between styles.py
bf6b64d0240f4478453438edd343b540448f1297
[]
no_license
ahmed-gharib89/DataCamp_Data_Scientist_with_Python_2020
666c4129c3f0b5d759b511529a365dfd36c12f1a
f3d20b788c8ef766e7c86c817e6c2ef7b69520b8
refs/heads/master
2022-12-22T21:09:13.955273
2020-09-30T01:16:05
2020-09-30T01:16:05
289,991,534
2
0
null
2020-08-24T17:15:43
2020-08-24T17:15:42
null
UTF-8
Python
false
false
1,231
py
"""Switching between styles Selecting a style to use affects all of the visualizations that are created after this style is selected. Here, you will practice plotting data in two different styles. The data you will use is the same weather data we used in the first lesson: you will have available to you the DataFrame seattle_weather and the DataFrame austin_weather, both with records of the average temperature in every month. Instructions 1/2 50 XP 1 Select the 'ggplot' style, create a new Figure called fig, and a new Axes object called ax with plt.subplots.""" # Use the "ggplot" style and create new Figure/Axes plt.style.use('ggplot') fig, ax = plt.subplots() ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"]) plt.show() """Select the 'Solarize_Light2' style, create a new Figure called fig, and a new Axes object called ax with plt.subplots.""" # Use the "Solarize_Light2" style and create new Figure/Axes plt.style.use('Solarize_Light2') fig, ax = plt.subplots() ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"]) plt.show() """DEVELOPER""" """BasitAminBhatti""" """Github""" """https://github.com/basitaminbhatti"""
[ "Your-Email" ]
Your-Email
6ac3c62e2a4226a5f65d4d9dfc0d061c2efcf72d
700bbd29624158c86402933b43f863e794e0ab7e
/register/migrations/0008_auto_20180218_2047.py
eb49eb56e7d02d34db8ffbabb2d1227a826e7dc1
[]
no_license
gitanjali1077/volunteer
ab0391ab3319c88b5ecd40e6ff480ae15d30fdf4
bd9dbd056624b6ebde3c46c8640b0b5786f0665f
refs/heads/master
2021-04-27T08:16:22.889332
2018-02-23T17:29:38
2018-02-23T17:29:38
122,651,909
2
1
null
null
null
null
UTF-8
Python
false
false
469
py
# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2018-02-18 15:17 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('register', '0007_auto_20180218_1221'), ] operations = [ migrations.AlterField( model_name='managers', name='username', field=models.CharField(max_length=60, unique=True), ), ]
183f84f9f7d40335c152e532c4984ba51ff94712
45fdc51cf264bbd50e59655440eefc91451c50ea
/data_compression/gzip_write.py
f3b6aff0f49da10c94b226d6b5f66cb97e318bb9
[]
no_license
blindij/python3_stl
2163043f3a9113eac21a48a35685a4a01987e926
ea138e25f8b5bbf7d8f78e4b1b7e2ae413de4735
refs/heads/master
2021-12-24T20:37:54.055116
2021-09-29T13:37:38
2021-09-29T13:37:38
191,508,648
0
0
null
2019-08-27T15:45:53
2019-06-12T06:10:30
Python
UTF-8
Python
false
false
349
py
import gzip import io import os outfilename = 'example.txt.gz' with gzip.open(outfilename,'wb') as output: with io.TextIOWrapper(output, encoding='utf-8') as enc: enc.write('Contents of the example file go here.\n') print(outfilename,'contains',os.stat(outfilename).st_size, 'bytes') os.system('file -b --mime {}'.format(outfilename))
3466cea2b26cd096e9d52e1486e519f5b67ff809
779be2cae4bcfa24d47c2f681dd77bd2419099e9
/atcoder_py/Archive/ABC204_B_20210606.py
34f664ca2463da63dc4c79e7c18f14cb75b8b3d2
[]
no_license
ynanigashi/til
f72d586427981c5b4543546193f8bfcb0d65a8c8
9de4453300ea5b084f4348a3e25ccedb0627d10c
refs/heads/master
2023-08-10T18:30:44.599474
2021-09-26T12:50:39
2021-09-26T12:50:39
274,137,816
0
0
null
null
null
null
UTF-8
Python
false
false
126
py
n = int(input()) a = list(map(int, input().split())) ans = 0 for i in a: if i > 10: ans += i - 10 print(ans)
6f10dd392a12325ac3735eafb29f3c589fdb6589
b106753e5abe4a72f669b4c25f1770fa2a2b2eb8
/students/views/demo.py
b974a5fd30e6a79fb223444d10a2ca6429d50e4c
[]
no_license
ofisser86/last_chance
1f614634b93ca2267c31679f052b0b32e9699738
a808cc7b632ea4545e8a5628fec02a5bb1bc6ac1
refs/heads/master
2021-03-27T20:28:03.970568
2017-11-18T16:31:10
2017-11-18T16:31:10
100,600,192
0
0
null
null
null
null
UTF-8
Python
false
false
219
py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.http import HttpResponse from django.shortcuts import render def demo(request): return render(request, 'students/demo.html', {})
e15f7ed60d6d2af4ab3f888cd3311c6379368064
9b79dc0b4b2f13dea85a1d29177e5eb266b6e7f7
/var/lib/python-support/python2.6/orca/speechdispatcherfactory.py
31e58bb001a0fb51493d502e586a90fdaae23fbf
[]
no_license
haniokasai/netwalker-rootfs
0bc87efc0ae478338b6326fd9118befcbcc5cd06
d08f7bf370a82b6970387bb9f165d374a9d9092b
refs/heads/master
2021-01-10T11:04:34.436513
2016-01-12T06:09:50
2016-01-12T06:09:50
36,504,146
2
1
null
null
null
null
UTF-8
Python
false
false
68
py
/usr/share/python-support/gnome-orca/orca/speechdispatcherfactory.py
f461f4dbc105464039c3e003fd8a2673ea8b1da6
9aabbb426a3382017e99f9199e23bd0dd0133734
/natlas-server/migrations/versions/997bbd9a505a_.py
77fe1fc4b5b945c73ed8c1d4e6a177f01f5ef31f
[ "Apache-2.0" ]
permissive
thesubtlety/natlas
71702da863a8086ce4a7b21a91d143dfab96b869
c7e6afc44244c5e0bb6dcadb3d11a45bd445540d
refs/heads/master
2020-07-24T12:16:42.352028
2019-10-08T21:37:38
2019-10-08T21:37:38
207,923,055
0
0
Apache-2.0
2019-09-11T23:16:54
2019-09-11T23:16:53
null
UTF-8
Python
false
false
869
py
"""empty message Revision ID: 997bbd9a505a Revises: aeb6c660a13a Create Date: 2018-07-17 13:21:47.150960 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '997bbd9a505a' down_revision = 'aeb6c660a13a' branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_index(op.f('ix_scope_item_blacklist'), 'scope_item', ['blacklist'], unique=False) op.create_index(op.f('ix_scope_item_target'), 'scope_item', ['target'], unique=True) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_scope_item_target'), table_name='scope_item') op.drop_index(op.f('ix_scope_item_blacklist'), table_name='scope_item') # ### end Alembic commands ###
849cac2c6ffc592edc45a4f17cc1627b144adc08
d21071464bef4f3fd51e554f280418d06975a77e
/leetcode/187 Repeated DNA Sequence.py
2b569f7f04327396e11419362f64688b1bd117ae
[]
no_license
DeshErBojhaa/sports_programming
ec106dcc24e96231d447cdcac494d76a94868b2d
96e086d4ee6169c0f83fff3819f38f32b8f17c98
refs/heads/master
2021-06-13T19:43:40.782021
2021-03-27T14:21:49
2021-03-27T14:21:49
164,201,394
1
0
null
2019-08-27T22:21:26
2019-01-05T09:39:41
C++
UTF-8
Python
false
false
814
py
from collections import defaultdict class Solution: def findRepeatedDnaSequences(self, s: str) -> List[str]: if len(s) < 11: return [] ss = s s = [ord(c)-64 for c in s] ans = set() alphabates = 4 mp = 4 ** 9 _hash = 0 for i in range(10): _hash = (alphabates * _hash + s[i]) all_hash = defaultdict(set) all_hash[_hash].add(ss[:10]) for i in range(10, len(s)): # Go from 11th char to the last char _hash = (alphabates * (_hash - s[i-10] * mp) + s[i] ) cur_str = ss[i-9:i+1] if _hash in all_hash: if cur_str in all_hash[_hash]: ans.add(cur_str) all_hash[_hash].add(cur_str) return list(ans)
7ccd59634356c252bf6755d8585b8d418f3c4fe8
4eeb40dcc265caf4a2b84bc90a28d481930d6a8a
/templatelistviewsproject/sampleproj/settings.py
844c3cb74d437a2b1c1d20edbd32f7641cccf8be
[]
no_license
mprasu/Sample-Projects
eb7fc46e81b09d7c97c238047e3c93b6fff3fb8d
7363baf630900ab2babb4af2afe77911d8a548b2
refs/heads/master
2020-04-16T06:43:16.345750
2019-01-12T07:07:34
2019-01-12T07:07:34
165,358,055
0
0
null
null
null
null
UTF-8
Python
false
false
3,245
py
import pymysql pymysql.install_as_MySQLdb() import MySQLdb """ Django settings for sampleproj project. Generated by 'django-admin startproject' using Django 2.1. For more information on this file, see https://docs.djangoproject.com/en/2.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.1/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '&wb@k6@sq#n^$*7ey2u@@&bz2!m^v4vzcais)66u1dve9(@pqb' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'sampleproj.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR,'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'sampleproj.wsgi.application' # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'hoteldb1', 'HOST': 'localhost', 'USER': 'root', 'PASSWORD': 'root', 'PORT': 3306, } } # Password validation # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/2.1/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/'
eabefdbf9bf558615032877bb94b86116d7e60e4
b39d9ef9175077ac6f03b66d97b073d85b6bc4d0
/Savene_WC500049102.py
1fca99424e88a51f6a725a26ec3e053abee89057
[]
no_license
urudaro/data-ue
2d840fdce8ba7e759b5551cb3ee277d046464fe0
176c57533b66754ee05a96a7429c3e610188e4aa
refs/heads/master
2021-01-22T12:02:16.931087
2013-07-16T14:05:41
2013-07-16T14:05:41
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,020
py
{'_data': [['Very common', [['Infections', u'Postoperativ infektion'], ['GI', u'Illam\xe5ende'], ['General', u'Sm\xe4rta vid injektionsst\xe4llet Pyrexi Flebit vid injektionsst\xe4llet Erytem vid injektionsst\xe4llet Utmattning Induration vid injektionsst\xe4llet']]], ['Common', [['Infections', u'Infektion Neutropen infektion'], ['Metabolism', u'Minskad aptit'], ['Nervous system', u'Yrsel Sensorisk f\xf6rlust'], ['Vascular', u'Flebit Ytlig tromboflebit Ven\xf6s trombos i extremiteter'], ['Respiratory', u'Dyspn\xe9 Pneumoni'], ['GI', u'Kr\xe4kningar Diarr\xe9 Stomatit Muntorrhet'], ['Skin', u'Alopeci Pruritus'], ['Musculoskeletal', u''], ['General', u'Svullnad vid injektionsst\xe4llet Perifert \xf6dem S\xf6mnighet'], ['Investigations', u'Viktminskning']]]], '_pages': [5, 7], u'_rank': 12, u'_type': u'TSFU'}
c8a18cb50e5375ab0e677a1fd6fe0d03669e9644
5c2e4266abf6d2be9102d5309bf94071a1eae1db
/cp 习题课练习/进阶练习/advance 15.3.py
7609871116204497122b379e87dc17030c11979a
[]
no_license
13834319675/python
8176d5da47136b9b3ec290eaa0b699c6b1e7a8ab
3e6f04670f6f01006f827794865488dd40bca380
refs/heads/master
2021-07-11T18:29:12.894401
2021-07-05T08:29:27
2021-07-05T08:29:27
171,112,613
0
0
null
null
null
null
UTF-8
Python
false
false
545
py
""" 假设,我们用一组tuple来表示学生的名字和成绩, L = [("Bob",75),("Adam",92),("Bart",66),("List",88)] 用sorted()对上述列表按照名字排序 """ l = [("Bob",75),("Adam",92),("Bart",66),("List",88)] sorted1 = sorted(l,key=lambda x:x[1]) print(sorted1) def By_name(n): t = sorted(n[0],key=str.lower) return t l2 = sorted(l,key=By_name) print(l2) def by_score(t): t = sorted(range(t[1]),key=abs) return t L2 = sorted(l,key=by_score) print(L2) l3 = sorted(l,key=lambda x:x[1],reverse=True) print(l3)
a3fa41af3d88f132cf6ccf311546fb57ae67bcfb
390380434c2daede4de30de73df939572de6957d
/project/urls.py
d4a0cf3d7f2b4f09b92e6077e5d26a44759063d6
[]
no_license
anykate/FullCRUD
984a6ca85ba9bb7b8f1ec3c7b1589e09c24e182b
c3a9f565198ece38ae6b70c746844a37e7dea3e2
refs/heads/master
2021-04-30T05:07:09.453906
2018-02-13T16:52:34
2018-02-13T16:52:34
121,408,868
0
0
null
null
null
null
UTF-8
Python
false
false
798
py
"""project URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.0/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('products.urls')), ]
74e05cab947be624208275e976fd92220ecc9323
f9d564f1aa83eca45872dab7fbaa26dd48210d08
/huaweicloud-sdk-ief/huaweicloudsdkief/v1/model/probe_detail.py
164248ef166385abad271c9e4dec0ea7902be286
[ "Apache-2.0" ]
permissive
huaweicloud/huaweicloud-sdk-python-v3
cde6d849ce5b1de05ac5ebfd6153f27803837d84
f69344c1dadb79067746ddf9bfde4bddc18d5ecf
refs/heads/master
2023-09-01T19:29:43.013318
2023-08-31T08:28:59
2023-08-31T08:28:59
262,207,814
103
44
NOASSERTION
2023-06-22T14:50:48
2020-05-08T02:28:43
Python
UTF-8
Python
false
false
6,416
py
# coding: utf-8 import six from huaweicloudsdkcore.utils.http_utils import sanitize_for_serialization class ProbeDetail: """ Attributes: openapi_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name and the value is json key in definition. """ sensitive_list = [] openapi_types = { 'exec_command': 'str', 'http_get': 'HttpGetDetail', 'initial_delay_seconds': 'int', 'timeout_seconds': 'int' } attribute_map = { 'exec_command': 'exec_command', 'http_get': 'http_get', 'initial_delay_seconds': 'initial_delay_seconds', 'timeout_seconds': 'timeout_seconds' } def __init__(self, exec_command=None, http_get=None, initial_delay_seconds=None, timeout_seconds=None): """ProbeDetail The model defined in huaweicloud sdk :param exec_command: 执行探测的命令行命令,长度1-10240内的字符串 :type exec_command: str :param http_get: :type http_get: :class:`huaweicloudsdkief.v1.HttpGetDetail` :param initial_delay_seconds: 表示从工作负载启动后从多久开始探测,大于0且不大于3600的整数,默认为10 :type initial_delay_seconds: int :param timeout_seconds: 表示探测超时时间,大于0且不大于3600的整数,默认为1 :type timeout_seconds: int """ self._exec_command = None self._http_get = None self._initial_delay_seconds = None self._timeout_seconds = None self.discriminator = None if exec_command is not None: self.exec_command = exec_command if http_get is not None: self.http_get = http_get if initial_delay_seconds is not None: self.initial_delay_seconds = initial_delay_seconds if timeout_seconds is not None: self.timeout_seconds = timeout_seconds @property def exec_command(self): """Gets the exec_command of this ProbeDetail. 执行探测的命令行命令,长度1-10240内的字符串 :return: The exec_command of this ProbeDetail. :rtype: str """ return self._exec_command @exec_command.setter def exec_command(self, exec_command): """Sets the exec_command of this ProbeDetail. 执行探测的命令行命令,长度1-10240内的字符串 :param exec_command: The exec_command of this ProbeDetail. :type exec_command: str """ self._exec_command = exec_command @property def http_get(self): """Gets the http_get of this ProbeDetail. :return: The http_get of this ProbeDetail. :rtype: :class:`huaweicloudsdkief.v1.HttpGetDetail` """ return self._http_get @http_get.setter def http_get(self, http_get): """Sets the http_get of this ProbeDetail. :param http_get: The http_get of this ProbeDetail. :type http_get: :class:`huaweicloudsdkief.v1.HttpGetDetail` """ self._http_get = http_get @property def initial_delay_seconds(self): """Gets the initial_delay_seconds of this ProbeDetail. 表示从工作负载启动后从多久开始探测,大于0且不大于3600的整数,默认为10 :return: The initial_delay_seconds of this ProbeDetail. :rtype: int """ return self._initial_delay_seconds @initial_delay_seconds.setter def initial_delay_seconds(self, initial_delay_seconds): """Sets the initial_delay_seconds of this ProbeDetail. 表示从工作负载启动后从多久开始探测,大于0且不大于3600的整数,默认为10 :param initial_delay_seconds: The initial_delay_seconds of this ProbeDetail. :type initial_delay_seconds: int """ self._initial_delay_seconds = initial_delay_seconds @property def timeout_seconds(self): """Gets the timeout_seconds of this ProbeDetail. 表示探测超时时间,大于0且不大于3600的整数,默认为1 :return: The timeout_seconds of this ProbeDetail. :rtype: int """ return self._timeout_seconds @timeout_seconds.setter def timeout_seconds(self, timeout_seconds): """Sets the timeout_seconds of this ProbeDetail. 表示探测超时时间,大于0且不大于3600的整数,默认为1 :param timeout_seconds: The timeout_seconds of this ProbeDetail. :type timeout_seconds: int """ self._timeout_seconds = timeout_seconds def to_dict(self): """Returns the model properties as a dict""" result = {} for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) else: if attr in self.sensitive_list: result[attr] = "****" else: result[attr] = value return result def to_str(self): """Returns the string representation of the model""" import simplejson as json if six.PY2: import sys reload(sys) sys.setdefaultencoding("utf-8") return json.dumps(sanitize_for_serialization(self), ensure_ascii=False) def __repr__(self): """For `print`""" return self.to_str() def __eq__(self, other): """Returns true if both objects are equal""" if not isinstance(other, ProbeDetail): return False return self.__dict__ == other.__dict__ def __ne__(self, other): """Returns true if both objects are not equal""" return not self == other
67a3294885373c7c6f4cffd3913b003c7454a49c
9e9ce86ef979a179a5b99a349452765f7f6e5f8d
/src/sentry_opsgenie/plugin.py
b2d975efc69b9dc11980741702c811bf3df39148
[ "Apache-2.0" ]
permissive
zsjohny/sentry-opsgenie
49b273544544ee852396b984793f9c5319e849b4
bc74d82a971da63d8faec4f03949d967851d7e7b
refs/heads/master
2021-01-15T21:02:44.629556
2015-05-11T21:45:13
2015-05-11T21:45:13
null
0
0
null
null
null
null
UTF-8
Python
false
false
3,474
py
""" sentry_opsgenie.plugin ~~~~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2015 by Sentry Team, see AUTHORS for more details. :license: Apache 2.0, see LICENSE for more details. """ from __future__ import absolute_import import logging import sentry_opsgenie from django import forms from django.utils.html import escape from sentry import http from sentry.plugins.bases import notify from sentry.utils import json class OpsGenieOptionsForm(notify.NotificationConfigurationForm): api_key = forms.CharField( max_length=255, help_text='OpsGenie API key used for authenticating API requests', required=True, ) recipients = forms.CharField( max_length=255, help_text='The user names of individual users or groups (comma seperated)', required=False, ) alert_url = forms.CharField( max_length=255, label='OpsGenie Alert URL', widget=forms.TextInput(attrs={'class': 'span6', 'placeholder': 'e.g. https://api.opsgenie.com/v1/json/alert'}), help_text='It must be visible to the Sentry server', required=True, ) class OpsGeniePlugin(notify.NotificationPlugin): author = 'Sentry Team' author_url = 'https://github.com/getsentry' resource_links = ( ('Bug Tracker', 'https://github.com/getsentry/sentry-opsgenie/issues'), ('Source', 'https://github.com/getsentry/sentry-opsgenie'), ) title = 'OpsGenie' slug = 'opsgenie' description = 'Create OpsGenie alerts out of notifications.' conf_key = 'opsgenie' version = sentry_opsgenie.VERSION project_conf_form = OpsGenieOptionsForm logger = logging.getLogger('sentry.plugins.opsgenie') def is_configured(self, project): return all(( self.get_option(k, project) for k in ('api_key', 'alert_url') )) def get_form_initial(self, project=None): return { 'alert_url': 'https://api.opsgenie.com/v1/json/alert', } # TODO(dcramer): this is duplicated from sentry-webhooks def get_group_data(self, group, event): data = { 'id': str(group.id), 'checksum': group.checksum, 'project': group.project.slug, 'project_name': group.project.name, 'logger': group.logger, 'level': group.get_level_display(), 'culprit': group.culprit, 'message': event.message, 'url': group.get_absolute_url(), } data['event'] = dict(event.data or {}) data['event']['tags'] = event.get_tags() return data def notify_users(self, group, event, fail_silently=False): if not self.is_configured(group.project): return api_key = self.get_option('api_key', group.project) recipients = self.get_option('recipients', group.project) alert_url = self.get_option('alert_url', group.project) message = getattr(group, 'message_short', group.message).encode('utf-8') payload = { 'apiKey': api_key, 'message': message, 'source': 'Sentry', 'details': self.get_group_data(group, event) } if recipients: payload['recipients'] = recipients req = http.safe_urlopen(alert_url, json=payload) resp = req.json() if resp.get('status') != 'successful': raise Exception('Unsuccessful response from OpsGenie: %s' % resp)
a7da8a97cddff33a27a682c204eedaf50d183a61
778633cb4adc0172015ad53452ff66d757a07fd8
/src/collective/documentgenerator/content/merge_templates.py
c494702ffecfae0ab655fedcf406700fe3d37c4c
[]
no_license
malikrohit16/collective.documentgenerator
0d2db10a6047ba208f2dadba9759eb50b22b76e6
1836b94f8eae17528d93f6cdee5bc245377ede96
refs/heads/master
2021-04-27T17:07:23.812486
2018-02-21T08:59:40
2018-02-21T08:59:40
null
0
0
null
null
null
null
UTF-8
Python
false
false
350
py
# -*- coding: utf-8 -*- from collective.documentgenerator.interfaces import ITemplatesToMerge from zope.interface import implements class TemplatesToMergeForPODTemplate(object): """ """ implements(ITemplatesToMerge) def __init__(self, pod_template): self.pod_template = pod_template def get(self): return {}
9b5ee6608d5f2fa48e239a47432b99fa77288040
d6f31bf476f4ea4a810cf67b668246303ca0d8e3
/python/data/price.py
10b73fccba1a4eab0e626b69ec0bbe5627522a0b
[ "MIT" ]
permissive
sslab-gatech/ACon2
b8201610a62ac71fefd92f876877dd169db783a6
17b5967b90bf43dae24ae52080b8df2fcbf7be49
refs/heads/main
2023-08-17T06:32:10.371013
2023-08-06T13:43:43
2023-08-06T13:43:43
607,729,188
1
0
null
null
null
null
UTF-8
Python
false
false
3,781
py
import os, sys import numpy as np import warnings import pickle import glob class NoObservation(Exception): pass class SinglePriceDataset: def __init__(self, path): file_name = glob.glob(path + '*.pk') if len(file_name) == 0: path_split = path.split('/') pair_name = path_split[-2] pair_name_split = pair_name.split('_') pair_name = '_'.join([pair_name_split[0], pair_name_split[2], pair_name_split[1]]) path_split[-2] = pair_name path = '/'.join(path_split) file_name = glob.glob(path + '*.pk') assert(len(file_name) == 1) self.inverse_price = True else: assert(len(file_name) == 1) self.inverse_price = False file_name = file_name[0] self.data = pickle.load(open(file_name, 'rb')) # check if data is sorted timestamps = [d['time'] for d in self.data] for t1, t2 in zip(timestamps[:-1], timestamps[1:]): assert t1 <= t2, f'data is not sorted: {t1} > {t2}' # time type conversion for i in range(len(self.data)): self.data[i]['time'] = self.data[i]['time'].astype('datetime64[s]') self.data[i]['price'] = float(self.data[i]['price']) if type(self.data[i]['price']) is not float else self.data[i]['price'] self.reset() def __getitem__(self, index): time, price = self.data[index]['time'], self.data[index]['price'] if self.inverse_price: price = 1 / price return {'timestamp': time.astype('int'), 'price': price} def __len__(self): return len(self.data) def reset(self): self.index = 0 def read(self, timestamp): if self.index + 1 == len(self): raise StopIteration index = None for i, d in enumerate(self.data[self.index:]): if d['time'].astype('int') > timestamp: break else: index = i + self.index if index is None: raise NoObservation else: self.index = index return self[index]['price'] class PriceDataset: def __init__( self, data_path, ): self.seq = {} for p in data_path: seq = SinglePriceDataset(p) print(f'[price data, data_path = {p}] sequence length = {len(seq)}') self.seq[p] = seq def reset(self): for k in self.seq.keys(): self.seq[k].reset() def read(self, time): out = {} for k in self.seq.keys(): try: out[k] = self.seq[k].read(time.astype('int')) except NoObservation: out[k] = None return out class RandomPriceDataset: def __init__(self, path, sig=5, seed=None): assert(len(path) == 1) self.path = path[0] #TODO: dummy self.sig = sig self.price = 0.0 np.random.seed(seed) def _read(self): self.price = np.random.normal(loc=self.price, scale=self.sig) #self.price += 2.0 return self.price def reset(self): self.price = 0.0 def read(self, time): return {self.path: self._read()} class ZeroPriceDataset: def __init__(self, path, sig=5, seed=None): self.path = path[0] #TODO: dummy self.reset() def _read(self): return self.price def reset(self): self.price = 0.0 def read(self, time): return {self.path: self._read()} if __name__ == '__main__': dsld = Price('price_ETH_USD/coinbase')
aea7154f5e4850a4eadaf03473dd5273450c16dc
4e353bf7035eec30e5ad861e119b03c5cafc762d
/QtGui/QSplashScreen.py
b4f657ddc37548ddd2e716cf42fa2f6ccf8ad729
[]
no_license
daym/PyQt4-Stubs
fb79f54d5c9a7fdb42e5f2506d11aa1181f3b7d5
57d880c0d453641e31e1e846be4087865fe793a9
refs/heads/master
2022-02-11T16:47:31.128023
2017-10-06T15:32:21
2017-10-06T15:32:21
null
0
0
null
null
null
null
UTF-8
Python
false
false
6,226
py
# encoding: utf-8 # module PyQt4.QtGui # from C:\Python27\lib\site-packages\PyQt4\QtGui.pyd # by generator 1.145 # no doc # imports import PyQt4.QtCore as __PyQt4_QtCore from QWidget import QWidget class QSplashScreen(QWidget): """ QSplashScreen(QPixmap pixmap=QPixmap(), Qt.WindowFlags flags=0) QSplashScreen(QWidget, QPixmap pixmap=QPixmap(), Qt.WindowFlags flags=0) """ def actionEvent(self, *args, **kwargs): # real signature unknown pass def changeEvent(self, *args, **kwargs): # real signature unknown pass def childEvent(self, *args, **kwargs): # real signature unknown pass def clearMessage(self): # real signature unknown; restored from __doc__ """ QSplashScreen.clearMessage() """ pass def closeEvent(self, *args, **kwargs): # real signature unknown pass def connectNotify(self, *args, **kwargs): # real signature unknown pass def contextMenuEvent(self, *args, **kwargs): # real signature unknown pass def create(self, *args, **kwargs): # real signature unknown pass def customEvent(self, *args, **kwargs): # real signature unknown pass def destroy(self, *args, **kwargs): # real signature unknown pass def disconnectNotify(self, *args, **kwargs): # real signature unknown pass def dragEnterEvent(self, *args, **kwargs): # real signature unknown pass def dragLeaveEvent(self, *args, **kwargs): # real signature unknown pass def dragMoveEvent(self, *args, **kwargs): # real signature unknown pass def drawContents(self, QPainter): # real signature unknown; restored from __doc__ """ QSplashScreen.drawContents(QPainter) """ pass def dropEvent(self, *args, **kwargs): # real signature unknown pass def enabledChange(self, *args, **kwargs): # real signature unknown pass def enterEvent(self, *args, **kwargs): # real signature unknown pass def event(self, QEvent): # real signature unknown; restored from __doc__ """ QSplashScreen.event(QEvent) -> bool """ return False def finish(self, QWidget): # real signature unknown; restored from __doc__ """ QSplashScreen.finish(QWidget) """ pass def focusInEvent(self, *args, **kwargs): # real signature unknown pass def focusNextChild(self, *args, **kwargs): # real signature unknown pass def focusNextPrevChild(self, *args, **kwargs): # real signature unknown pass def focusOutEvent(self, *args, **kwargs): # real signature unknown pass def focusPreviousChild(self, *args, **kwargs): # real signature unknown pass def fontChange(self, *args, **kwargs): # real signature unknown pass def hideEvent(self, *args, **kwargs): # real signature unknown pass def inputMethodEvent(self, *args, **kwargs): # real signature unknown pass def keyPressEvent(self, *args, **kwargs): # real signature unknown pass def keyReleaseEvent(self, *args, **kwargs): # real signature unknown pass def languageChange(self, *args, **kwargs): # real signature unknown pass def leaveEvent(self, *args, **kwargs): # real signature unknown pass def messageChanged(self, *args, **kwargs): # real signature unknown """ QSplashScreen.messageChanged[QString] [signal] """ pass def metric(self, *args, **kwargs): # real signature unknown pass def mouseDoubleClickEvent(self, *args, **kwargs): # real signature unknown pass def mouseMoveEvent(self, *args, **kwargs): # real signature unknown pass def mousePressEvent(self, QMouseEvent): # real signature unknown; restored from __doc__ """ QSplashScreen.mousePressEvent(QMouseEvent) """ pass def mouseReleaseEvent(self, *args, **kwargs): # real signature unknown pass def moveEvent(self, *args, **kwargs): # real signature unknown pass def paintEvent(self, *args, **kwargs): # real signature unknown pass def paletteChange(self, *args, **kwargs): # real signature unknown pass def pixmap(self): # real signature unknown; restored from __doc__ """ QSplashScreen.pixmap() -> QPixmap """ return QPixmap def receivers(self, *args, **kwargs): # real signature unknown pass def repaint(self): # real signature unknown; restored from __doc__ """ QSplashScreen.repaint() """ pass def resetInputContext(self, *args, **kwargs): # real signature unknown pass def resizeEvent(self, *args, **kwargs): # real signature unknown pass def sender(self, *args, **kwargs): # real signature unknown pass def senderSignalIndex(self, *args, **kwargs): # real signature unknown pass def setPixmap(self, QPixmap): # real signature unknown; restored from __doc__ """ QSplashScreen.setPixmap(QPixmap) """ pass def showEvent(self, *args, **kwargs): # real signature unknown pass def showMessage(self, QString, int_alignment=None, QColor_color=None): # real signature unknown; restored from __doc__ """ QSplashScreen.showMessage(QString, int alignment=Qt.AlignLeft, QColor color=Qt.black) """ pass def tabletEvent(self, *args, **kwargs): # real signature unknown pass def timerEvent(self, *args, **kwargs): # real signature unknown pass def updateMicroFocus(self, *args, **kwargs): # real signature unknown pass def wheelEvent(self, *args, **kwargs): # real signature unknown pass def windowActivationChange(self, *args, **kwargs): # real signature unknown pass def winEvent(self, *args, **kwargs): # real signature unknown pass def __init__(self, *__args): # real signature unknown; restored from __doc__ with multiple overloads pass
371ae445aebcea943259ea3701f151c082bf13cb
cfb2d39ab0ed8603750711698108328ba65152bf
/Products/Bitakora/XMLImporter.py
4201f2a26782b8bdde10c5157b6078771fbf02a8
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
codesyntax/Products.Bitakora
d4fc4ce48d7244d69d986de1c9e70ff7dfbd0ffb
555dee0070263d4296b409ae587cbf3693fc8adc
refs/heads/master
2021-01-10T21:24:17.062053
2016-10-13T09:38:32
2016-10-13T09:38:32
3,788,430
0
0
null
null
null
null
UTF-8
Python
false
false
5,125
py
# -*- coding: utf-8 -*- # (c) Copyright 2005, CodeSyntax <http://www.codesyntax.com> # Authors: Mikel Larreategi <[email protected]> # See also LICENSE.txt from xml.sax.handler import ContentHandler from xml.sax import make_parser class XMLImporter(ContentHandler): def __init__(self): self.posts = [] self.comments = [] self.reset() def reset(self): self.inpost = 0 self.incomment = 0 self.incomments = 0 self.intitle = 0 self.inauthor = 0 self.infmt = 0 self.inid = 0 self.inbody = 0 self.intags = 0 self.indate = 0 self.title = '' self.author = '' self.fmt = '' self.body = '' self.tags = '' self.date = '' self.id = '' self.resetComment() def startElement(self, tag, attrs): if self.inpost and not self.incomment: if tag == 'author': self.inauthor = 1 elif tag == 'body': self.inbody = 1 elif tag == 'date': self.indate = 1 elif tag == 'id': self.inid = 1 elif self.incomment: if tag == 'author': self.incommauthor = 1 elif tag == 'body': self.incommbody = 1 elif tag == 'date': self.incommdate = 1 if tag == 'post': self.inpost = 1 elif tag == 'url': self.inurl = 1 elif tag == 'email': self.inemail = 1 elif tag == 'tags': self.intags = 1 elif tag == 'fmt': self.infmt = 1 elif tag == 'title': self.intitle = 1 elif tag == 'comment': self.incomment = 1 elif tag == 'comments': self.incomments = 1 def endElement(self, tag): if self.inpost and not self.incomment: if tag == 'author': self.inauthor = 0 elif tag == 'body': self.inbody = 0 elif tag == 'date': self.indate = 0 elif tag == 'id': self.inid = 0 elif self.incomment: if tag == 'author': self.incommauthor = 0 elif tag == 'body': self.incommbody = 0 elif tag == 'date': self.incommdate = 0 if tag == 'post': self.inpost = 0 self.createPost() self.reset() elif tag == 'url': self.inurl = 0 elif tag == 'email': self.inemail = 0 elif tag == 'tags': self.intags = 0 elif tag == 'fmt': self.infmt = 0 elif tag == 'title': self.intitle = 0 elif tag == 'comment': self.incomment = 0 self.createComment() self.resetComment() elif tag == 'comments': self.incomments = 0 def characters(self, chars): if self.intitle: self.title += chars elif self.inauthor: self.author += chars elif self.infmt: self.fmt += chars elif self.inbody: self.body += chars elif self.intags: self.tags += chars elif self.indate: self.date += chars elif self.incommauthor: self.commauthor += chars elif self.incommdate: self.commdate += chars elif self.incommbody: self.commbody += chars elif self.inurl: self.url += chars elif self.inemail: self.email += chars elif self.inid: self.id += chars def createPost(self): post = {} post['id'] = self.id post['title'] = self.title post['author'] = self.author post['fmt'] = self.fmt post['body'] = self.body post['tags'] = self.tags.split(';') post['date'] = self.date post['comments'] = self.comments[:] self.comments = [] self.posts.append(post) def createComment(self): comment = {} comment['author'] = self.commauthor comment['date'] = self.commdate comment['body'] = self.commbody comment['url'] = self.url comment['email'] = self.email self.comments.append(comment) def resetComment(self): self.commauthor = '' self.commdate = '' self.commbody = '' self.url = '' self.email = '' self.incommauthor = 0 self.incommdate = 0 self.incommbody = 0 self.inurl = 0 self.inemail = 0 def returnData(self): return self.posts def importXML(xml): from cStringIO import StringIO xmlimporter = XMLImporter() parser = make_parser() parser.setContentHandler(xmlimporter) parser.parse(StringIO(xml)) return xmlimporter.returnData() if __name__ == '__main__': fp = open('/tmp/tolon.xml', 'r') print importXML(fp.read()) fp.close()
bdb3737c57abe52174c250ea7e721281ef182918
6444622ad4a150993955a0c8fe260bae1af7f8ce
/djangoenv/lib/python2.7/site-packages/django/contrib/contenttypes/views.py
fd09b8d32057cccdff25bb88a3b5dcf0e0a73b09
[]
no_license
jeremyrich/Lesson_RestAPI_jeremy
ca965ef017c53f919c0bf97a4a23841818e246f9
a44263e45b1cc1ba812059f6984c0f5be25cd234
refs/heads/master
2020-04-25T23:13:47.237188
2019-03-22T09:26:58
2019-03-22T09:26:58
173,138,073
0
0
null
2019-03-22T09:26:59
2019-02-28T15:34:19
Python
UTF-8
Python
false
false
3,699
py
from __future__ import unicode_literals from django import http from django.apps import apps from django.contrib.contenttypes.models import ContentType from django.contrib.sites.requests import RequestSite from django.core.exceptions import ObjectDoesNotExist from django.utils.translation import ugettext as _ def shortcut(request, content_type_id, object_id): """ Redirect to an object's page based on a content-type ID and an object ID. """ # Look up the object, making sure it's got a get_absolute_url() function. try: content_type = ContentType.objects.get(pk=content_type_id) if not content_type.model_class(): raise http.Http404( _("Content type %(ct_id)s object has no associated model") % {"ct_id": content_type_id} ) obj = content_type.get_object_for_this_type(pk=object_id) except (ObjectDoesNotExist, ValueError): raise http.Http404( _("Content type %(ct_id)s object %(obj_id)s doesn't exist") % {"ct_id": content_type_id, "obj_id": object_id} ) try: get_absolute_url = obj.get_absolute_url except AttributeError: raise http.Http404( _("%(ct_name)s objects don't have a get_absolute_url() method") % {"ct_name": content_type.name} ) absurl = get_absolute_url() # Try to figure out the object's domain, so we can do a cross-site redirect # if necessary. # If the object actually defines a domain, we're done. if absurl.startswith(("http://", "https://", "//")): return http.HttpResponseRedirect(absurl) # Otherwise, we need to introspect the object's relationships for a # relation to the Site object object_domain = None if apps.is_installed("django.contrib.sites"): Site = apps.get_model("sites.Site") opts = obj._meta # First, look for an many-to-many relationship to Site. for field in opts.many_to_many: if field.remote_field.model is Site: try: # Caveat: In the case of multiple related Sites, this just # selects the *first* one, which is arbitrary. object_domain = getattr(obj, field.name).all()[0].domain except IndexError: pass if object_domain is not None: break # Next, look for a many-to-one relationship to Site. if object_domain is None: for field in obj._meta.fields: if field.remote_field and field.remote_field.model is Site: try: site = getattr(obj, field.name) except Site.DoesNotExist: continue if site is not None: object_domain = site.domain if object_domain is not None: break # Fall back to the current site (if possible). if object_domain is None: try: object_domain = Site.objects.get_current(request).domain except Site.DoesNotExist: pass else: # Fall back to the current request's site. object_domain = RequestSite(request).domain # If all that malarkey found an object domain, use it. Otherwise, fall back # to whatever get_absolute_url() returned. if object_domain is not None: protocol = request.scheme return http.HttpResponseRedirect( "%s://%s%s" % (protocol, object_domain, absurl) ) else: return http.HttpResponseRedirect(absurl)
e581f50177c0f06cd565e1b66f82f6d51dbb486e
3fe272eea1c91cc5719704265eab49534176ff0d
/scripts/field/enter_402000600.py
88f1149115492abf3117fdc9ac30cf77dc6fb2e6
[ "MIT" ]
permissive
Bratah123/v203.4
e72be4843828def05592298df44b081515b7ca68
9cd3f31fb2ef251de2c5968c75aeebae9c66d37a
refs/heads/master
2023-02-15T06:15:51.770849
2021-01-06T05:45:59
2021-01-06T05:45:59
316,366,462
1
0
MIT
2020-12-18T17:01:25
2020-11-27T00:50:26
Java
UTF-8
Python
false
false
312
py
# Created by MechAviv # Map ID :: 402000600 # Refuge Outskirts : Caravan Refuge # Unhandled Message [47] Packet: 2F 02 00 00 00 B0 83 08 00 00 00 00 00 2E 02 00 00 00 00 00 80 05 BB 46 E6 17 02 00 00 B8 22 11 00 00 00 00 00 63 04 00 00 00 02 C0 6A 2A F2 79 D6 D4 01 0D 00 66 69 65 6C 64 5F 65 6E 74 65 72 3D 31
9cfdb317eb64642a51f6b25f90e07311be3c5efd
5785d7ed431b024dd910b642f10a6781df50e4aa
/revise-daily/june_2021/epi/36_phone_mnemonics.py
63ad8507a981dc8f93667cd57cd578a5835d1fea
[]
no_license
kashyapa/interview-prep
45d77324446da34d99bf8efedb3544b367b5523e
7060c090c40602fb9c4778eace2078e1b51e235b
refs/heads/master
2023-07-28T13:12:49.515299
2021-09-06T14:33:25
2021-09-06T14:33:25
403,706,510
0
0
null
null
null
null
UTF-8
Python
false
false
476
py
def phone_mnemonics(nums): def rec(idx, mnemonic): if idx == len(nums): res.append(''.join(mnemonic.copy())) return str = mapping[int(nums[idx])] for c in str: mnemonic.append(c) rec(idx+1, mnemonic) mnemonic.pop() return res = [] mapping = ['0', 'ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQRS', 'TUV', 'WXYZ'] rec(0, []) return res print(phone_mnemonics("2345"))
763c6f160fd22c8c58e34381dbfbaa07c2188275
397c28c703bd3c3a015f87ccf55b75fa18304b8b
/test/testRssEditor.py
1cadc3c4426b8531282fb368439990880c84e0b8
[]
no_license
jbarciauskas/rsseditor
7f3f958d50e1c40ae433a0227cbd3eed9287c50e
0e028d2de8eef7fbeb56727bbd47f8b68bd38b4e
refs/heads/master
2021-01-20T04:32:23.294303
2011-04-19T04:59:13
2011-04-19T04:59:13
1,628,110
2
1
null
null
null
null
UTF-8
Python
false
false
507
py
import unittest from rsseditor import RssEditor from rsseditor import FeedLoader class RssEditorTest(unittest.TestCase): def setUp(self): self.feedLoader = FeedLoader('http://news.ycombinator.com/rss') self.classUnderTest = RssEditor(self.feedLoader) def testEditTitle(self): self.assertEqual(self.feedLoader.retrieve().find("asdf"), -1) self.classUnderTest.edit("[1].title.string", "asdf") self.assertNotEqual(self.feedLoader.retrieve().find("asdf"), -1)
e285754d1e6e6d0301acfcce6701a5d3b6ce7c50
87b006149b16a3028385fc58cf781f5a12c94ad9
/tests/checker/syntax/test_ip.py
5e85f4f92990830a381af3f5fcb90f2d33b47638
[ "Apache-2.0" ]
permissive
spirillen/PyFunceble
04d03b2678ad46ec81c520a32df5397832414451
3c8f62062bffa0e16d465c150a853af8bf2f2205
refs/heads/master
2023-05-12T04:32:04.587521
2022-11-20T11:19:06
2022-11-20T11:19:06
237,827,167
2
0
Apache-2.0
2021-01-27T10:09:59
2020-02-02T19:50:47
Python
UTF-8
Python
false
false
9,105
py
""" The tool to check the availability or syntax of domain, IP or URL. :: ██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗ ██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝ ██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗ ██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝ ██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝ Tests of our IP (v4 and v6) syntax checker. Author: Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom Special thanks: https://pyfunceble.github.io/special-thanks.html Contributors: https://pyfunceble.github.io/contributors.html Project link: https://github.com/funilrys/PyFunceble Project documentation: https://pyfunceble.readthedocs.io/en/latest/ Project homepage: https://pyfunceble.github.io/ License: :: Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import unittest from PyFunceble.checker.syntax.ip import IPSyntaxChecker try: import pyf_test_dataset except ModuleNotFoundError: # pragma: no cover from .. import pyf_test_dataset class TestIPSyntaxChecker(unittest.TestCase): """ Tests of our IP (v4 and v6) syntax checker. """ def test_is_valid_v4(self) -> None: """ Tests the method which let us check if the given subject is valid. """ ip_checker = IPSyntaxChecker() expected = True for subject in pyf_test_dataset.VALID_IPV4: actual = ip_checker.set_subject(subject).is_valid() self.assertEqual(expected, actual, subject) def test_is_valid_v6(self) -> None: """ Tests the method which let us check if the given subject is valid. """ ip_checker = IPSyntaxChecker() expected = True for subject in pyf_test_dataset.VALID_IPV6: ip_checker.subject = subject actual = ip_checker.is_valid() self.assertEqual(expected, actual, subject) def test_is_not_valid_v4(self) -> None: """ Tests the method which let us check if the given subject is valid for the case that the given subject is not valid. """ ip_checker = IPSyntaxChecker() expected = False for subject in pyf_test_dataset.NOT_VALID_IPV4: ip_checker.subject = subject actual = ip_checker.is_valid() self.assertEqual(expected, actual, subject) def test_is_not_valid_v6(self) -> None: """ Tests the method which let us check if the given subject is valid for the case that the given subject is not valid. """ ip_checker = IPSyntaxChecker() expected = False for subject in pyf_test_dataset.NOT_VALID_IPV6: ip_checker.subject = subject actual = ip_checker.is_valid() self.assertEqual(expected, actual, subject) def test_is_valid_range_v4(self) -> None: """ Tests the method which let us check if the given subject is valid range. """ ip_checker = IPSyntaxChecker() expected = True for subject in pyf_test_dataset.VALID_IPV4_RANGES: ip_checker.subject = subject actual = ip_checker.is_valid_range() self.assertEqual(expected, actual, subject) def test_is_valid_range_v6(self) -> None: """ Tests the method which let us check if the given subject is valid range. """ ip_checker = IPSyntaxChecker() expected = True for subject in pyf_test_dataset.VALID_IPV6_RANGES: ip_checker.subject = subject actual = ip_checker.is_valid_range() self.assertEqual(expected, actual, subject) def test_is_not_valid_range_v4(self) -> None: """ Tests the method which let us check if the given subject is valid for the case that the given subject is not a valid range. """ ip_checker = IPSyntaxChecker() expected = False for subject in pyf_test_dataset.NOT_VALID_IPV4_RANGES: ip_checker.subject = subject actual = ip_checker.is_valid_range() self.assertEqual(expected, actual, subject) def test_is_not_valid_range(self) -> None: """ Tests the method which let us check if the given subject is valid for the case that the given subject is not a valid range. """ ip_checker = IPSyntaxChecker() expected = False for subject in pyf_test_dataset.NOT_VALID_IPV6_RANGES: ip_checker.subject = subject actual = ip_checker.is_valid_range() self.assertEqual(expected, actual, subject) def test_is_reserved_v4(self) -> None: """ Tests the method which let us check if the given subject is reserved. """ ip_checker = IPSyntaxChecker() expected = True for subject in pyf_test_dataset.RESERVED_IPV4: ip_checker.subject = subject actual = ip_checker.is_reserved() self.assertEqual(expected, actual, subject) def test_is_reserved_v6(self) -> None: """ Tests the method which let us check if the given subject is reserved. """ ip_checker = IPSyntaxChecker() expected = True for subject in pyf_test_dataset.RESERVED_IPV6: ip_checker.subject = subject actual = ip_checker.is_reserved() self.assertEqual(expected, actual, subject) def test_is_not_reserved_v4(self) -> None: """ Tests the method which let us check if the given subject is valid for the case that the given subject is not reserved. """ ip_checker = IPSyntaxChecker() expected = False for subject in pyf_test_dataset.NOT_RESERVED_IPV4: ip_checker.subject = subject actual = ip_checker.is_reserved() self.assertEqual(expected, actual, subject) def test_is_not_reserved_v6(self) -> None: """ Tests the method which let us check if the given subject is valid for the case that the given subject is not reserved. """ ip_checker = IPSyntaxChecker() expected = False for subject in pyf_test_dataset.NOT_RESERVED_IPV6: ip_checker.subject = subject actual = ip_checker.is_reserved() self.assertEqual(expected, actual, subject) def test_is_valid(self) -> None: """ Tests the method which let us check if the given subject is valid IPv4 or IPv6. """ ip_checker = IPSyntaxChecker() expected = True for subject in pyf_test_dataset.VALID_IPV4 + pyf_test_dataset.VALID_IPV6: ip_checker.subject = subject actual = ip_checker.is_valid() self.assertEqual(expected, actual, subject) def test_is_not_valid(self) -> None: """ Tests the method which let us check if the given subject is valid IPv4 or IPv6 for the case that is not a valid IPv4 or IPv6. """ ip_checker = IPSyntaxChecker() expected = False for subject in ( pyf_test_dataset.NOT_VALID_IPV4 + pyf_test_dataset.NOT_VALID_IPV6 ): ip_checker.subject = subject actual = ip_checker.is_valid() self.assertEqual(expected, actual, subject) if __name__ == "__main__": unittest.main()
b5e0858061319961de905ea6f567ecfdadd1c942
163bbb4e0920dedd5941e3edfb2d8706ba75627d
/Code/CodeRecords/2410/47937/267383.py
6a19290da4da1af5ceca5da1b99f25f26281d7c3
[]
no_license
AdamZhouSE/pythonHomework
a25c120b03a158d60aaa9fdc5fb203b1bb377a19
ffc5606817a666aa6241cfab27364326f5c066ff
refs/heads/master
2022-11-24T08:05:22.122011
2020-07-28T16:21:24
2020-07-28T16:21:24
259,576,640
2
1
null
null
null
null
UTF-8
Python
false
false
664
py
a=input().split(",") b=input() #print(len(a)) c=[] i=0 while i<len(a): c.append(int(a[i])) i=i+1 #print(c) d=int(b) i=0 end=1 while i<len(a): length=1 i2=i+1 i3=i while i2<len(a): if(c[i2]-c[i3]==d): i3=i2 i2=i2+1 length=length+1 continue i2=i2+1 if(length>end): end=length i=i+1 print(end) #if(a=="1,2,3,4" and b=="1"): #print(4) #elif(a=="1,5,7,8,5,3,4,2,1" and b=="2"): #print(2) #elif(a=="1,3,5,7,9" and b=="2"): #print(5) #elif(a=="1,2,3,4,5,6,7" and b=="2"): #print(4) #elif(a=="1,3,5,6,9" and b=="2"): #print(3)
d2317d8ad686eebde79a7ade73a22b350beaadbe
4cf3f8845d64ed31737bd7795581753c6e682922
/.history/main_20200118154006.py
c21def57393197b390a3f4cce01282d5f58a3dce
[]
no_license
rtshkmr/hack-roll
9bc75175eb9746b79ff0dfa9307b32cfd1417029
3ea480a8bf6d0067155b279740b4edc1673f406d
refs/heads/master
2021-12-23T12:26:56.642705
2020-01-19T04:26:39
2020-01-19T04:26:39
234,702,684
1
0
null
2021-12-13T20:30:54
2020-01-18T08:12:52
Python
UTF-8
Python
false
false
632,235
py
from telegram.ext import Updater, CommandHandler import requests import re # API call to source, get json (url is obtained): contents = requests.get('https://random.dog/woof.json').json() image_url = contents['url'] def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main() def get_url(): contents = requests.get('https://random.dog/woof.json').json() url = contents['url'] return url def get_tasks(): response = requests.get('https://nowwat.herokuapp.com/api/tasks.json').json() def extract_list(obj): return obj.map(lambda item: item.title) tasks = extract_list(response) return tasks # sending the image: # we require: # - the image URL # - the recipient's ID: group/user id def bop(bot, update): # image url: url = get_url() # recipient's ID: chat_id = update.message.chat_id bot.send_photo(chat_id=chat_id, photo=url) def getTaskList(bot, update): taskList = get_tasks() chat_id = update.message.chat_id for task in taskList: bot.sendMessage(chat_id, task, Markdown); def main(): updater = Updater('982938821:AAHiN0-7hIPahKJm6lWPyQ0UupOsuhP1GsQ') dp = updater.dispatcher dp.add_handler(CommandHandler('bop',bop)) updater.start_polling() updater.idle() if __name__ == '__main__': main()
76968d454afd94bdffc453550ea7bb5da3329979
555eb9c234f86911df70188914d45c358c67bb62
/tensorflow/python/autograph/pyct/static_analysis/liveness_test.py
8a23abef6bc5c2df50fc8393342c2f8a9c23a5d6
[ "Apache-2.0" ]
permissive
obeshor/tensorflow
64b99bfec161e8680535104e7e90834b1060c5c3
0fd570848f7cd08904907640111d435dcb7fba8a
refs/heads/master
2020-05-18T09:44:13.516187
2019-04-30T20:33:02
2019-04-30T21:32:19
184,335,557
2
1
Apache-2.0
2019-04-30T21:43:01
2019-04-30T21:43:00
null
UTF-8
Python
false
false
10,514
py
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for liveness module.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import six from tensorflow.python.autograph.pyct import anno from tensorflow.python.autograph.pyct import cfg from tensorflow.python.autograph.pyct import parser from tensorflow.python.autograph.pyct import qual_names from tensorflow.python.autograph.pyct import transformer from tensorflow.python.autograph.pyct.static_analysis import activity from tensorflow.python.autograph.pyct.static_analysis import liveness from tensorflow.python.platform import test class LivenessTest(test.TestCase): def _parse_and_analyze(self, test_fn): node, source = parser.parse_entity(test_fn, future_features=()) entity_info = transformer.EntityInfo( source_code=source, source_file=None, future_features=(), namespace={}) node = qual_names.resolve(node) ctx = transformer.Context(entity_info) node = activity.resolve(node, ctx) graphs = cfg.build(node) liveness.resolve(node, ctx, graphs) return node def assertHasLiveOut(self, node, expected): live_out = anno.getanno(node, anno.Static.LIVE_VARS_OUT) live_out_strs = set(str(v) for v in live_out) if not expected: expected = () if not isinstance(expected, tuple): expected = (expected,) self.assertSetEqual(live_out_strs, set(expected)) def assertHasLiveIn(self, node, expected): live_in = anno.getanno(node, anno.Static.LIVE_VARS_IN) live_in_strs = set(str(v) for v in live_in) if not expected: expected = () if not isinstance(expected, tuple): expected = (expected,) self.assertSetEqual(live_in_strs, set(expected)) def test_live_out_try_block(self): def test_fn(x, a, b, c): # pylint:disable=unused-argument if a > 0: try: pass except: # pylint:disable=bare-except pass return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], 'x') self.assertHasLiveOut(fn_body[0].body[0], 'x') def test_live_out_if_inside_except(self): def test_fn(x, a, b, c): # pylint:disable=unused-argument if a > 0: try: pass except: # pylint:disable=bare-except if b > 0: x = b return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], 'x') self.assertHasLiveOut(fn_body[0].body[0], 'x') self.assertHasLiveOut(fn_body[0].body[0].handlers[0].body[0], 'x') def test_live_out_stacked_if(self): def test_fn(x, a): if a > 0: x = 0 if a > 1: x = 1 return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], ('a', 'x')) self.assertHasLiveOut(fn_body[1], 'x') def test_live_out_stacked_if_else(self): def test_fn(x, a): if a > 0: x = 0 if a > 1: x = 1 else: x = 2 return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], 'a') self.assertHasLiveOut(fn_body[1], 'x') def test_live_out_for_basic(self): def test_fn(x, a): for i in range(a): x += i return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], 'x') def test_live_out_for_iterate(self): def test_fn(x, a): for i in range(a): x += i return x, i # pylint:disable=undefined-loop-variable node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], ('x', 'i')) def test_live_out_attributes(self): def test_fn(x, a): if a > 0: x.y = 0 return x.y node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], ('x.y', 'x')) def test_live_out_nested_functions(self): def test_fn(a, b): if b: a = [] def foo(): return a foo() node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], 'a') def test_live_out_nested_functions_isolation(self): def test_fn(b): if b: a = 0 # pylint:disable=unused-variable def child(): max(a) # pylint:disable=used-before-assignment a = 1 return a child() node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], 'max') def test_live_out_deletion(self): def test_fn(x, y, a): for _ in a: if x: del y else: y = 0 node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveOut(fn_body[0], ()) def test_live_in_pass(self): def test_fn(x, a, b, c): # pylint:disable=unused-argument if a > 0: pass return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'x')) self.assertHasLiveIn(fn_body[0].body[0], ('x',)) self.assertHasLiveIn(fn_body[1], ('x',)) def test_live_in_return_statement(self): def test_fn(x, a, b, c): # pylint:disable=unused-argument if a > 0: return x return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'x')) self.assertHasLiveIn(fn_body[0].body[0], ('x',)) self.assertHasLiveIn(fn_body[1], ('x',)) def test_live_in_try_block(self): def test_fn(x, a, b, c): # pylint:disable=unused-argument if a > 0: try: pass except: # pylint:disable=bare-except pass return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'x')) self.assertHasLiveIn(fn_body[0].body[0], ('x',)) self.assertHasLiveIn(fn_body[1], ('x',)) def test_live_in_try_orelse(self): def test_fn(x, a, b, c): # pylint:disable=unused-argument if a > 0: try: pass except: # pylint:disable=bare-except pass else: x = b return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'b', 'x')) self.assertHasLiveIn(fn_body[0].body[0], ('b', 'x')) self.assertHasLiveIn(fn_body[1], ('x',)) def test_live_in_if_inside_except(self): def test_fn(x, a, b, c): # pylint:disable=unused-argument if a > 0: try: pass except: # pylint:disable=bare-except if b > 0: x = b return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'b', 'x')) self.assertHasLiveIn(fn_body[0].body[0], ('b', 'x')) self.assertHasLiveIn(fn_body[0].body[0].handlers[0].body[0], ('b', 'x')) self.assertHasLiveIn(fn_body[1], ('x',)) def test_live_in_stacked_if(self): def test_fn(x, a, b, c): if a > 0: x = b if c > 1: x = 0 return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'b', 'c', 'x')) self.assertHasLiveIn(fn_body[1], ('c', 'x')) def test_live_in_stacked_if_else(self): def test_fn(x, a, b, c, d): if a > 1: x = b else: x = c if d > 0: x = 0 return x node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'b', 'c', 'd')) self.assertHasLiveIn(fn_body[1], ('d', 'x')) def test_live_in_for_basic(self): def test_fn(x, y, a): for i in a: x = i y += x z = 0 return y, z node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'y', 'z')) def test_live_in_for_nested(self): def test_fn(x, y, a): for i in a: for j in i: x = i y += x z = j return y, z node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'y', 'z')) def test_live_in_deletion(self): def test_fn(x, y, a): for _ in a: if x: del y else: y = 0 node = self._parse_and_analyze(test_fn) fn_body = node.body self.assertHasLiveIn(fn_body[0], ('a', 'x', 'y')) def test_live_in_generator_comprehension(self): def test_fn(y): if all(x for x in y): return node = self._parse_and_analyze(test_fn) fn_body = node.body if six.PY2: self.assertHasLiveIn(fn_body[0], ('all', 'x', 'y')) else: self.assertHasLiveIn(fn_body[0], ('all', 'y')) def test_live_in_list_comprehension(self): def test_fn(y): if [x for x in y]: return node = self._parse_and_analyze(test_fn) fn_body = node.body if six.PY2: self.assertHasLiveIn(fn_body[0], ('x', 'y')) else: self.assertHasLiveIn(fn_body[0], ('y',)) def test_live_in_set_comprehension(self): def test_fn(y): if {x for x in y}: return node = self._parse_and_analyze(test_fn) fn_body = node.body if six.PY2: self.assertHasLiveIn(fn_body[0], ('x', 'y')) else: self.assertHasLiveIn(fn_body[0], ('y',)) def test_live_in_dict_comprehension(self): def test_fn(y): if {k: v for k, v in y}: return node = self._parse_and_analyze(test_fn) fn_body = node.body if six.PY2: self.assertHasLiveIn(fn_body[0], ('k', 'v', 'y')) else: self.assertHasLiveIn(fn_body[0], ('y',)) if __name__ == '__main__': test.main()
d74f9bc9792a616e6c0933d06f78cde2201693ba
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/agc008/B/3719594.py
b69ea63898a0d7baadd01fe4aaeb65de1040ec21
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
Python
false
false
457
py
N, K = map(int, input().split()) A = [int(a) for a in input().split()] Plus, Whole = [0], [0] for i in range(N): Plus.append(Plus[-1] + max(A[i], 0)) Whole.append(Whole[-1] + A[i]) Score = max(max(0, Whole[K] - Whole[0]) + Plus[N] - Plus[K], Plus[N-K] - Plus[0] + max(0, Whole[N] - Whole[N-K])) for i in range(1, N-K): temp = Plus[i] + max(0, Whole[i+K] - Whole[i]) + Plus[N] - Plus[i+K] Score = max(Score, temp) print(Score)
e3b1ca32371f220e5494e925dba257fd3aaf7afc
f11600b9a256bf6a2b584d127faddc27a0f0b474
/normal/826.py
291cb5bbbf8d6b2a6f742b0274197291c8258dd9
[]
no_license
longhao54/leetcode
9c1f0ce4ca505ec33640dd9b334bae906acd2db5
d156c6a13c89727f80ed6244cae40574395ecf34
refs/heads/master
2022-10-24T07:40:47.242861
2022-10-20T08:50:52
2022-10-20T08:50:52
196,952,603
0
0
null
null
null
null
UTF-8
Python
false
false
1,245
py
# 弱智方法 class Solution: def maxProfitAssignment(self, difficulty: List[int], profit: List[int], worker: List[int]) -> int: w, p = {}, {} for d,pri in zip (difficulty, profit): w[d] = 1 if d in p: p[d] = max(pri, p[d]) else: p[d] = pri difficulty.sort() m = p[difficulty[0]] d1 = difficulty[0] while d1-1 >= 1: p[d1-1] = 0 d1 -= 1 m1 = max(worker) for v in difficulty[1:]: t = v while t-1 not in p: p[t-1] = m t -= 1 m = max(p[v], m) p[v] = m for i in range(difficulty[-1]+1, m1+1): p[i] = m ans = 0 for i in worker: ans += p[i] return ans #官方方法 class Solution(object): def maxProfitAssignment(self, difficulty, profit, worker): jobs = zip(difficulty, profit) jobs.sort() ans = i = best = 0 for skill in sorted(worker): while i < len(jobs) and skill >= jobs[i][0]: best = max(best, jobs[i][1]) i += 1 ans += best return ans
2909cf54ad06e7340aeb3128d7794c1718acc4d6
76a6890c01006fff69a920719df0065e6109a5e9
/full_django_blog/myblog/views.py
bba2acc11ab84388f7f433b809dac48a52bc09c4
[]
no_license
prathmesh2048/full-django-blog
0c94ce08c1a17b74c21420d4e658f1b5b5fe12d6
b25c9af1d25b1677cf82b929d133f1067109b26b
refs/heads/master
2022-11-21T21:50:39.990007
2020-07-23T15:59:39
2020-07-23T15:59:39
281,994,887
1
0
null
null
null
null
UTF-8
Python
false
false
2,964
py
from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.http import Http404 from django.shortcuts import render, redirect from django.urls import reverse_lazy, reverse from .models import Post from django.utils.decorators import method_decorator from django.views.generic import ListView, DetailView, TemplateView, CreateView, UpdateView, DeleteView from .forms import UserProfileForm, UserUpdateForm from .models import Profile from django.contrib.auth.decorators import login_required class PostListView(ListView): model = Post template_name = 'myblog/home.html' context_object_name = 'posts' ordering = ['-date_posted'] # @method_decorator(login_required, name='dispatch') class PostDetailView(LoginRequiredMixin, DetailView): model = Post # context is automatically called 'object' class PostCreateView(LoginRequiredMixin, CreateView): # context rendered is 'form' model = Post fields = ['title', 'content'] # success_url = reverse_lazy('detail') def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) # This view does'nt requires a template class PostUpdateView(LoginRequiredMixin, UserPassesTestMixin, UpdateView, ): # context rendered is 'form' , this order is toooo important model = Post fields = ['title', 'content'] # success_url = reverse_lazy('detail') def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) success_url = '/' def test_func(self): obj = self.get_object() if obj.author == self.request.user: return True else: raise Http404("You are not allowed to edit this Post") class PostDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView): model = Post success_url = '/' def test_func(self): obj = self.get_object() if obj.author == self.request.user: return True else: raise Http404("You are not allowed to delete this Post") @login_required def profile(request): template = 'account/profile.html' details = Profile.objects.get(user=request.user) if request.method == "POST": p_form = UserProfileForm(request.POST, request.FILES, instance=request.user.profile) u_form = UserUpdateForm(request.POST, instance=request.user) if u_form.is_valid() and p_form.is_valid(): u_form.save() p_form.save() messages.success(request, f'your profile has been updated !') return redirect('/profile') else: p_form = UserProfileForm(instance=request.user.profile) u_form = UserUpdateForm(instance=request.user) context = {'details': details, 'u_form': u_form, 'p_form': p_form} return render(request, template, context)
32af5f9daa05db8a9394c42989ce82fece01f08d
180a3795a115c0da71078f81efbde45ab2025ca0
/machine_learning_book/CH02/plot.py
614ec79097c9a7d30eb96456cd9a02dddfa28638
[]
no_license
lizhe960118/Machine-Learning
a7593e6788433408bcf072e5e25672debd931ee4
2d6fe2373839964645d632895ed2a7dcb9de48b0
refs/heads/master
2020-03-31T15:53:57.408037
2019-08-18T12:29:11
2019-08-18T12:29:11
152,355,543
0
0
null
null
null
null
UTF-8
Python
false
false
666
py
# import matplotlib import matplotlib.pyplot as plt import KNN from numpy import * datingDataMat, datingLabels = KNN.file2matrix('datingTestSet2.txt') # print(datingDataMat[0:100]) # print(datingLabels[0:20]) fig = plt.figure() ax = fig.add_subplot(111) ''' 这些是编码为单个整数的子图网格参数。 例如,“111”表示“1×1 grid,first subplot”,“234”表示“2×3 grid,4th subplot”。 add_subplot(111)的替代形式是add_subplot(1, 1, 1) ''' ax.scatter(datingDataMat[:, 1], datingDataMat[:, 2], 15.0 * array(datingLabels), 15.0 * array(datingLabels)) # 使用标签来决定所画图像的颜色和大小 plt.show()
902bc632e7a592419bfbdd250fd9fe501cfafc04
bbf1ae079309eca11270422d3f0d259d1515d430
/numerical-tours/python/todo/solutions/multidim_2_volumetric.py
dc13ecfee2d90c85abdd280d18d22bef9a5a7d1f
[ "BSD-2-Clause" ]
permissive
ZichaoDi/Di_MATLABTool
5e6a67b613c4bcf4d904ddc47c2744b4bcea4885
c071291c63685c236f507b2cb893c0316ab6415c
refs/heads/master
2021-08-11T07:28:34.286526
2021-08-04T18:26:46
2021-08-04T18:26:46
149,222,333
9
5
null
null
null
null
UTF-8
Python
false
false
5,481
py
def exo1(): """ Implement the forward wavelet transform by iteratively applying these transform steps to the low pass residual. nitialize the transform """ MW = M for j in 1: log2(n): p = n/ 2^(j-1) sel = 1: p % average/ difference along X MW(sel, sel, sel) = cat3(1, (MW(1: 2: p, sel, sel) + MW(2: 2: p, sel, sel))/ sqrt(2), (MW(1: 2: p, sel, sel)-MW(2: 2: p, sel, sel))/ sqrt(2)) % average/ difference along Y MW(sel, sel, sel) = cat3(2, (MW(sel, 1: 2: p, sel) + MW(sel, 2: 2: p, sel))/ sqrt(2), (MW(sel, 1: 2: p, sel)-MW(sel, 2: 2: p, sel))/ sqrt(2)) % average/ difference along Z MW(sel, sel, sel) = cat3(3, (MW(sel, sel, 1: 2: p) + MW(sel, sel, 2: 2: p))/ sqrt(2), (MW(sel, sel, 1: 2: p)-MW(sel, sel, 2: 2: p))/ sqrt(2)) def exo2(): """ Implement the backward transform to compute an approximation |M1| from the coefficients |MWT|. """ M1 = MWT for j in log2(n): -1: 1: p = n/ 2^(j) sel = 1: p sel1 = 1: 2*p selw = p + 1: 2*p % average/ difference along X A = M1(sel, sel1, sel1) D = M1(selw, sel1, sel1) M1(1: 2: 2*p, sel1, sel1) = (A + D)/ sqrt(2) M1(2: 2: 2*p, sel1, sel1) = (A-D)/ sqrt(2) % average/ difference along Y A = M1(sel1, sel, sel1) D = M1(sel1, selw, sel1) M1(sel1, 1: 2: 2*p, sel1) = (A + D)/ sqrt(2) M1(sel1, 2: 2: 2*p, sel1) = (A-D)/ sqrt(2) % average/ difference along Z A = M1(sel1, sel1, sel) D = M1(sel1, sel1, selw) M1(sel1, sel1, 1: 2: 2*p) = (A + D)/ sqrt(2) M1(sel1, sel1, 2: 2: 2*p) = (A-D)/ sqrt(2) def exo3(): """ Select the optimal blurring width |s| to reach the smallest possible SNR. Keep the optimal denoising |Mblur| """ ntests = 20 slist = linspace(.01, 1.5, ntests) err = [] for i in 1: ntests: h = exp(-(X.^2 + Y.^2 + Z.^2)/ (2*slist(i)^2)) h = h/ sum(h(: )) Mh = real(ifftn(fftn(Mnoisy) .* fftn(fftshift(h)))) err(i) = snr(M, Mh) if i >1 && err(i) >max(err(1: i-1)) Mblur = Mh plot(slist, err, '.-') axis('tight') set_label('s', 'SNR') def exo4(): """ Perforn Wavelet denoising by thresholding the wavelet coefficients of Mnoisy. Test both hard thresholding and soft thresholding to determine the optimal threshold and the corresponding SNR. Record the optimal result |Mwav|. """ MW = perform_haar_transf(Mnoisy, 1, + 1) Tlist = linspace(1, 4, 20)*sigma err_hard = []; err_soft = [] for i in 1: length(Tlist): MWT = perform_thresholding(MW, Tlist(i), 'hard') M1 = perform_haar_transf(MWT, 1, -1) err_hard(i) = snr(M, M1) MWT = perform_thresholding(MW, Tlist(i), 'soft') M1 = perform_haar_transf(MWT, 1, -1) err_soft(i) = snr(M, M1) if i >1 & err_soft(i) >max(err_soft(1: i-1)) Mwav = M1 plot(Tlist/ sigma, [err_hard; err_soft]', '.-') axis('tight') set_label('T/ sigma', 'SNR') legend('hard', 'soft') def exo5(): """ Implement cycle spinning hard thresholding with |T=3*sigma|. """ T = 3*sigma w = 4 [dX, dY, dZ] = ndgrid(0: w-1, 0: w-1, 0: w-1) Mspin = zeros(n, n, n) for i in 1: w^3: MnoisyC = circshift(Mnoisy, [dX(i) dY(i) dZ(i)]) % denoise MW = perform_haar_transf(MnoisyC, 1, + 1) MWT = perform_thresholding(MW, T, 'hard') M1 = perform_haar_transf(MWT, 1, -1) % back M1 = circshift(M1, -[dX(i) dY(i) dZ(i)]) Mspin = Mspin*(i-1)/ i + M1/ i def exo6(): """ Implement the full 3D forward wavelet transform by applying these steps for decaying scales |j| toward 0. """ Jmin = 0 options.h = h MW = perform_wavortho_transf(M, Jmin, + 1, options) def exo7(): """ Implement the full 3D backward wavelet transform by applying these steps for increasing scales |j|. """ M1 = perform_wavortho_transf(MWT, Jmin, -1, options) def exo8(): """ Implement denoising by soft and hard thresholding Daubechies wavelet coefficients. """ MW = perform_wavortho_transf(Mnoisy, 1, + 1, options) Tlist = linspace(1, 4, 10)*sigma err_hard = []; err_soft = [] for i in 1: length(Tlist): MWT = perform_thresholding(MW, Tlist(i), 'hard') M1 = perform_wavortho_transf(MWT, 1, -1, options) err_hard(i) = snr(M, M1) MWT = perform_thresholding(MW, Tlist(i), 'soft') M1 = perform_haar_transf(MWT, 1, -1, options) err_soft(i) = snr(M, M1) if i >1 & err_soft(i) >max(err_soft(1: i-1)) Mwav = M1 plot(Tlist/ sigma, [err_hard; err_soft]', '.-') axis('tight') set_label('T/ sigma', 'SNR') legend('hard', 'soft') def exo9(): """ Implement cycle spinning hard thresholding with Daubechies wavelets with |T=3*sigma|. """ T = 3*sigma w = 4 [dX, dY, dZ] = ndgrid(0: w-1, 0: w-1, 0: w-1) Mspin = zeros(n, n, n) for i in 1: w^3: MnoisyC = circshift(Mnoisy, [dX(i) dY(i) dZ(i)]) % denoise MW = perform_wavortho_transf(MnoisyC, 1, + 1, options) MWT = perform_thresholding(MW, T, 'hard') M1 = perform_wavortho_transf(MWT, 1, -1, options) % back M1 = circshift(M1, -[dX(i) dY(i) dZ(i)]) Mspin = Mspin*(i-1)/ i + M1/ i
cb4bacfba02f35a4b06e50b9536f97f7af866298
7bd9be7f25be80791f9220b62025f06170273293
/front-plugins/zstatuses/py_cerebro/__init__.py
aa488f1dd5c398d45e43845090805cd67b2b34de
[]
no_license
cerebrohq/cerebro-plugins
ab46b4844adcb12c51d14e21f2c0d8b758b0bb57
e2e0f97b548ef22957e13d614200027ba89215e0
refs/heads/master
2021-11-12T16:25:48.228521
2021-10-22T11:25:58
2021-10-22T11:25:58
143,178,631
5
3
null
null
null
null
UTF-8
Python
false
false
663
py
# -*- coding: utf-8 -*- """ py_cerebro package contains modules that provide program interface for file storage (Cargador) and database. The package includes the following modules: * :py:mod:`py_cerebro.database` -- access to the database to execute :ref:`SQL-queries <sapi-sql>`. * :py:mod:`py_cerebro.dbtypes` -- describes the data tuples of the bit flags used when working with the database. * :py:mod:`py_cerebro.cargador` -- Access to the Cargador file storage. * :py:mod:`py_cerebro.cclib` -- Contains auxiliary functions for handling hashes and bit flags. """ __all__ = ["database", "cargador", "dbtypes", "cclib"] from zstatuses.py_cerebro import *
a519345197a1a925a18bcdcaa5c384edde2d15d1
c8335705ff06641622668c9b0a3020df9213bc77
/core/migrations/0013_productpage.py
aae0848edcfab0b1936b19b0cfb191c9132025ec
[]
no_license
Richardh36/ANS
0adedcc760a6acbf539c8cbedde8edc28186218a
2c46d36cf349f3ab8556bf713d2a0125c415029a
refs/heads/master
2016-09-11T02:42:21.952145
2015-05-03T14:03:10
2015-05-03T14:03:10
34,852,005
0
0
null
null
null
null
UTF-8
Python
false
false
680
py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('wagtailcore', '0013_update_golive_expire_help_text'), ('core', '0012_contactpage_intro'), ] operations = [ migrations.CreateModel( name='ProductPage', fields=[ ('page_ptr', models.OneToOneField(serialize=False, auto_created=True, parent_link=True, to='wagtailcore.Page', primary_key=True)), ], options={ 'abstract': False, }, bases=('wagtailcore.page',), ), ]
f28bd4048ae55c0248d5c639b87f134d62a85807
37e87b3d5e1ee9009f0ea0671bc0c6edf0e233b7
/088_3.py
4cfa9bc9edcedf2f4efdb6f13e6e3b3d9d40b18f
[]
no_license
Jane11111/Leetcode2021
d9f4987792938597bf89ff72ba6bbcb4a3f9d081
a95b871578aae0103066962c33b8c0f4ec22d0f2
refs/heads/master
2023-07-14T21:29:41.196752
2021-08-23T03:28:02
2021-08-23T03:28:02
344,804,297
2
0
null
null
null
null
UTF-8
Python
false
false
736
py
# -*- coding: utf-8 -*- # @Time : 2021-05-13 13:12 # @Author : zxl # @FileName: 088_3.py class Solution: def merge(self, nums1 , m: int, nums2 , n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ if n==0: return p = m+n-1 i = m-1 j = n-1 while p>=0: if i>=0: n1 = nums1[i] else: n1 = float('-inf') if j>=0: n2 = nums2[j] else: n2 = float('-inf') if n1>=n2: nums1[p] = n1 i-=1 else: nums1[p] = n2 j-=1 p-=1
40bef4374a23d5005e5255ead7feb9767a4d762d
d33352f90d3d046e2e2fa55a123b4b2828260fc3
/LeetcodePython/Sqrt(x)69.py
9a627c1f67d9355bb70af15dd91c73dbdcb574e3
[]
no_license
DianaLuca/Algorithms
272c27d7d5fa4b7aa03e7500af01a4d67f15d0bf
b3a2013d1c3c7a5a16727dbc2ecbc934a01a3979
refs/heads/master
2021-09-11T12:37:00.334011
2018-04-07T00:17:57
2018-04-07T00:17:57
68,707,603
1
0
null
null
null
null
UTF-8
Python
false
false
442
py
# Implement int sqrt(int x). # Compute and return the square root of x. class Solution(object): def mySqrt(self, x): """ :type x: float :rtype: float """ l, r = 0, x while l + 1e-6 <= r: print(l, r) m = l + (r - l)/2 if m**2 <= x: l = m else: r = m return l s = Solution() r = s.mySqrt(81) print(r)
dc039f93edf88b962ac46de478b4828a0973415a
15a676a82a1344726172e5f422cf0ae56505be69
/src/web/controller/spiderController.py
e555bdcf6a620c0e3da10c75e74f0176912cfc97
[ "MIT" ]
permissive
343695222/QQZoneMood
35c12291ddf58c2571646723b7b8167da3912195
1c406d26bb63681e26d986bce57ab402808bf48a
refs/heads/master
2020-08-20T19:45:35.602392
2019-10-14T06:26:29
2019-10-14T06:26:29
216,059,716
1
0
MIT
2019-10-18T15:57:34
2019-10-18T15:57:33
null
UTF-8
Python
false
false
8,208
py
from flask import Blueprint, session import json from src.util.constant import * from flask import request from src.spider.main import web_interface import threading from time import sleep from src.web.controller.dataController import do_clear_data_by_user from src.web.web_util.web_constant import INVALID_LOGIN, SUCCESS_STATE, FAILED_STATE, FINISH_FRIEND, WAITING_USER_STATE, \ ALREADY_IN, CHECK_COOKIE, LOGGING_STATE, NOT_MATCH_STATE from src.web.web_util.web_util import check_password, md5_password, init_redis_key, get_redis_conn, judge_pool spider = Blueprint('spider', __name__) @spider.route('/query_spider_info/<QQ>/<password>') def query_spider_info(QQ, password): pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) info = conn.lpop(WEB_SPIDER_INFO + QQ) if not check_password(conn, QQ, password): if info is not None and info.find("登陆失败") != -1: return json.dumps(dict(finish=FAILED_STATE, info=info)) else: return json.dumps(dict(finish=INVALID_LOGIN, info=0)) finish = 0 mood_num = -1 friend_num = 0 if info is not None: if info.find(".jpg") != -1: finish = LOGGING_STATE elif info.find(LOGIN_NOT_MATCH) != -1: conn.lrem(WAITING_USER_LIST, QQ) conn.hdel(USER_MAP_KEY, QQ) finish = NOT_MATCH_STATE elif info.find(FRIEND_INFO_PRE) != -1: finish = FINISH_FRIEND friend_num = int(info.split(':')[1]) elif info.find(MOOD_NUM_PRE) != -1: finish = SUCCESS_STATE mood_num = int(info.split(':')[1]) elif info.find("失败") != -1: conn.lrem(WAITING_USER_LIST, QQ) conn.hdel(USER_MAP_KEY, QQ) finish = FAILED_STATE mood_num = FAILED_STATE result = dict(info=info, finish=finish, mood_num=mood_num, friend_num=friend_num) return json.dumps(result, ensure_ascii=False) else: info = '' result = dict(info=info, finish=finish, mood_num=mood_num, friend_num=friend_num) return json.dumps(result, ensure_ascii=False) @spider.route('/query_spider_num/<QQ>/<mood_num>/<password>') def query_spider_num(QQ, mood_num, password): pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) if not check_password(conn, QQ, password): return json.dumps(dict(finish=INVALID_LOGIN)) info = conn.get(MOOD_COUNT_KEY + str(QQ)) # 强制停止,保证在由于网络等原因导致爬取的说说数量有缺失时也能正常停止程序 finish_key = conn.get(MOOD_FINISH_KEY + str(QQ)) finish = 0 if mood_num == "null": mood_num = 0 if finish_key == "1" or int(info) >= int(mood_num): finish = SUCCESS_STATE return json.dumps(dict(num=info, finish=finish, finish_key=finish_key)) @spider.route('/start_spider', methods=['GET', 'POST']) def start_spider(): if request.method == 'POST': nick_name = request.form['nick_name'] qq = request.form['qq'] stop_time = str(request.form['stop_time']) mood_num = int(request.form['mood_num']) no_delete = False if request.form['no_delete'] == 'false' else True password = request.form['password'] password = md5_password(password) print("begin spider:", qq) pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) if conn is None: try: session[POOL_FLAG] = judge_pool() pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) except BaseException: result = dict(result="连接数据库失败,请稍后再尝试") return json.dumps(result, ensure_ascii=False) init_redis_key(conn, qq) waiting_list = check_waiting_list(conn) # 如果排队用户大于阈值,就返回 waiting_num = len(waiting_list) login_success = conn.get(USER_LOGIN_STATE + qq) if qq in waiting_list and login_success == "1": friend_num = conn.get(FRIEND_NUM_KEY + qq) mood_num = conn.get(MOOD_NUM_KEY + qq) result = dict(result=ALREADY_IN, waiting_num=waiting_num, friend_num=friend_num, mood_num=mood_num) return json.dumps(result, ensure_ascii=False) elif qq in waiting_list and login_success == "0": conn.lrem(WAITING_USER_LIST, qq) if waiting_num >= SPIDER_USER_NUM_LIMIT: result = dict(result=WAITING_USER_STATE, waiting_num=waiting_num) return json.dumps(result, ensure_ascii=False) else: # 放进数组,开始爬虫 conn.rpush(WAITING_USER_LIST, qq) try: t = threading.Thread(target=web_interface, args=(qq, nick_name, stop_time, mood_num, "xxx", no_delete, password, pool_flag)) t.start() result = dict(result=SUCCESS_STATE) return json.dumps(result, ensure_ascii=False) except BaseException as e: result = dict(result=e) return json.dumps(result, ensure_ascii=False) else: return "老哥你干嘛?" @spider.route('/stop_spider/<QQ>/<password>') def stop_spider(QQ, password): pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) if not check_password(conn, QQ, password): return json.dumps(dict(finish=INVALID_LOGIN)) # 更新标记位,停止爬虫 conn.set(STOP_SPIDER_KEY + QQ, STOP_SPIDER_FLAG) stop = 0 # 等待数据保存 while True: finish_info = conn.get(STOP_SPIDER_KEY + QQ) if finish_info == FINISH_ALL_INFO: stop = 1 break else: sleep(0.1) num = conn.get(MOOD_COUNT_KEY + str(QQ)) friend_num = conn.get(FRIEND_INFO_COUNT_KEY + str(QQ)) return json.dumps(dict(num=num, finish=stop, friend_num=friend_num)) # 强制停止spider @spider.route('/stop_spider_force/<QQ>/<password>') def stop_spider_force(QQ, password): pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) if not check_password(conn, QQ, password): return json.dumps(dict(finish=INVALID_LOGIN)) # 删除与该用户有关的数据 finish = do_clear_data_by_user(QQ, conn) # 重新设置标记位 conn.set(STOP_SPIDER_KEY + QQ, STOP_SPIDER_FLAG) conn.set(FORCE_STOP_SPIDER_FLAG + QQ, FORCE_STOP_SPIDER_FLAG) return json.dumps(dict(finish=finish)) @spider.route('/query_friend_info_num/<QQ>/<friend_num>/<password>') def query_friend_info_num(QQ, friend_num, password): pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) if not check_password(conn, QQ, password): return json.dumps(dict(finish=INVALID_LOGIN)) info = conn.get(FRIEND_INFO_COUNT_KEY + str(QQ)) finish = 0 if friend_num == "null": friend_num = 0 if int(info) >= int(friend_num): finish = 1 return json.dumps(dict(num=info, finish=finish)) @spider.route('/query_clean_data/<QQ>/<password>') def query_clean_data(QQ, password): pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) if not check_password(conn, QQ, password): return json.dumps(dict(finish=INVALID_LOGIN), ensure_ascii=False) while True: key = conn.get(CLEAN_DATA_KEY + QQ) if key == '1': break else: sleep(0.1) return json.dumps(dict(finish=key), ensure_ascii=False) def check_waiting_list(conn): waiting_list = conn.lrange(WAITING_USER_LIST, 0, -1) return waiting_list @spider.route('/query_finish_user_num') def query_finish_user_num(): pool_flag = session.get(POOL_FLAG) conn = get_redis_conn(pool_flag) if conn is None: host = judge_pool() conn = get_redis_conn(host) finish_user_num = conn.get(FINISH_USER_NUM_KEY) if finish_user_num is None: finish_user_num = 0 waiting_list = check_waiting_list(conn) waiting_num = len(waiting_list) return json.dumps(dict(finish_user_num=finish_user_num, waiting_user_num=waiting_num))
0cac1a24f83e80e5ba1a814ae54c5fd731b17ba7
eb38517d24bb32cd8a33206d4588c3e80f51132d
/grayscale.py
5a20f7197e61735bd1df50f7d333c75f69b6fa50
[]
no_license
Fernando23296/l_proy
2c6e209892112ceafa00c3584883880c856b6983
b7fdf99b9bd833ca1c957d106b2429cbd378abd3
refs/heads/master
2020-04-01T18:01:41.333302
2018-12-04T23:45:53
2018-12-04T23:45:53
153,466,681
2
0
null
null
null
null
UTF-8
Python
false
false
197
py
import cv2 image = cv2.imread('ex6.png') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow('Original image', image) cv2.imshow('Gray image', gray) cv2.waitKey(0) cv2.destroyAllWindows()
4bc12c51c6a8d4ba96daf796d0e2e6a2bb932602
787344a140b1f1ca05277b44dbf72fda3fa25cda
/bin/send_reports.py
504319ea16ef9ba6c2a8c41f9fcdcd965bba3976
[ "MIT" ]
permissive
poldrack/r-autograder
6785b40dbd3011dfe5fb47c134c66a8d18985d21
58ab96bed7456aef2cec9e01ff6eff23daec0425
refs/heads/master
2020-12-29T22:57:53.816305
2020-03-05T22:33:24
2020-03-05T22:33:24
238,765,808
3
0
null
2020-02-06T19:25:53
2020-02-06T19:20:10
Python
UTF-8
Python
false
false
976
py
#!/usr/bin/env python """ send reports to students automatically set up postfix gmail relay ala: https://www.justinsilver.com/technology/osx/send-emails-mac-os-x-postfix-gmail-relay/ http://postfix.1071664.n5.nabble.com/MacOS-High-Sierra-10-13-and-Postfix-relaying-td93421.html date | mail -s "Test Email" [email protected] """ import os,glob import numpy import json with open('config.json','r') as f: config = json.load(f) infiles=glob.glob('reports/*.txt') sunetDict={} for i in infiles: sunetID=os.path.basename(i).split('_')[0] if sunetID.find('unknown') > -1: print('skipping', sunetID) continue sunetDict[sunetID]=i with open('send_report.sh','w') as f: for sunetID in sunetDict: cmd='mail -s "Results from Week %d PSet automated tests for %s" %[email protected] < %s'%( config['week'], sunetID,sunetID,sunetDict[sunetID]) f.write(cmd+'\n') f.write('sleep %d\n'%(1+numpy.random.randint(18)))
1b64159778f2c89847c2b168143a6810ad3f4711
5178f5aa20a857f8744fb959e8b246079c800c65
/01_basic/text/src/03/if_ex3.py
fca268651ddcee0a837d8890fbf57c1392c708e2
[]
no_license
murayama333/python2020
4c3f35a0d78426c96f0fbaed335f9a63227205da
8afe367b8b42fcf9489fff1da1866e88f3af3b33
refs/heads/master
2021-05-19T04:03:46.295906
2021-03-09T22:23:58
2021-03-09T22:23:58
251,520,131
0
3
null
2020-10-26T01:20:09
2020-03-31T06:35:18
Python
UTF-8
Python
false
false
153
py
user_id = input("USER ID: ") password = input("PASSWORD: ") if user_id == "Alice" and password == "pass": print("Success") else: print("Error")
9a22d4a6c8d7830da5918262acf228ed3eb581c7
6612bdba8a08219b36d73739585836fa979b1dc5
/language/mentionmemory/tasks/eae_task.py
14731798856a87eb03c93feff95ea20fb5fe0cae
[ "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
insomnia1996/language
5582cfacebe27607b051b11e928dd0e46e4e4b7b
240cd2a1fd0307c6822b6f1f6c2abf1349a5a4da
refs/heads/master
2023-08-29T20:40:36.960181
2021-10-08T05:19:32
2021-10-08T17:14:00
null
0
0
null
null
null
null
UTF-8
Python
false
false
12,422
py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Contains Entities as Experts pre-training task.""" import flax.linen as nn import jax.numpy as jnp from language.mentionmemory.encoders import eae_encoder from language.mentionmemory.modules import mention_losses from language.mentionmemory.modules import mlm_layer from language.mentionmemory.tasks import mention_encoder_task from language.mentionmemory.tasks import task_registry from language.mentionmemory.utils import jax_utils as jut from language.mentionmemory.utils import metric_utils from language.mentionmemory.utils.custom_types import Array, MetricGroups # pylint: disable=g-multiple-import import ml_collections class EaEModel(nn.Module): """Entities as Experts (EaE) pre-training model. Attributes: encoder_config: EaE encoder hyperparameters. """ encoder_config: ml_collections.FrozenConfigDict def setup(self): self.encoder = eae_encoder.EaEEncoder(**self.encoder_config) self.mlm_layer = mlm_layer.MLMLayer( vocab_size=self.encoder.vocab_size, hidden_size=self.encoder.hidden_size, dtype=self.encoder.dtype, layer_norm_epsilon=self.encoder.layer_norm_epsilon, embedding_init=self.encoder.kernel_init, bias_init=self.encoder.bias_init, ) def __call__( self, batch, deterministic): encoded_input, loss_helpers, logging_helpers = self.encoder.forward( batch, deterministic) loss_helpers['mlm_logits'] = self.mlm_layer( encoded_input=encoded_input, mlm_target_positions=batch['mlm_target_positions'], shared_embedding=loss_helpers['word_embeddings']) return loss_helpers, logging_helpers @task_registry.register_task('eae') class EaETask(mention_encoder_task.MentionEncoderTask): """Task for pre-training Entities as Experts (EaE) encoder.""" model_class = EaEModel encoder_name = 'eae' @classmethod def make_loss_fn( cls, config ): """Creates task loss function. See BaseTask. EaE is pre-trained with a combination of 1) MLM loss, 2) entity-linking loss comparing mention encodings to entity embeddings at the retrieval and final layers, and 3) Matching the Blanks-style loss encouraging mentions of the same entity which co-occur with mentions of the same second entity to have similar representations. Args: config: contains experiment hyperparameters. Returns: Loss function. """ mlm_weight = config.mlm_weight el_im_weight = config.el_im_weight el_final_weight = config.el_final_weight el_score_mode = config.get('el_score_mode', 'dot') mtb_im_weight = config.get('mtb_im_weight', 0) mtb_final_weight = config.get('mtb_final_weight', 0) mtb_score_mode = config.get('mtb_score_mode', 'dot') def loss_fn( model_config, model_params, model_vars, # pylint: disable=unused-argument batch, deterministic, dropout_rng = None, ): """Task-specific loss function. See BaseTask.""" batch_size = batch['text_ids'].shape[0] loss_helpers, logging_helpers = cls.build_model(model_config).apply( # pylint: disable=unused-variable {'params': model_params}, batch, deterministic=deterministic, rngs=dropout_rng) mention_target_is_masked = batch['mention_target_is_masked'] mention_target_is_not_masked = 1 - batch['mention_target_is_masked'] mention_target_ids = batch['mention_target_ids'] mention_target_ids = mention_target_ids * batch['mention_target_weights'] mlm_logits = loss_helpers['mlm_logits'] mlm_loss, mlm_denom = metric_utils.compute_weighted_cross_entropy( mlm_logits, batch['mlm_target_ids'], batch['mlm_target_weights']) mlm_correct_mask = jnp.equal( jnp.argmax(mlm_logits, axis=-1), batch['mlm_target_ids']) * batch['mlm_target_weights'] mlm_acc = mlm_correct_mask.sum() mlm_mention_acc = (mlm_correct_mask * batch['mlm_target_is_mention']).sum() mlm_mention_denom = (batch['mlm_target_weights'] * batch['mlm_target_is_mention']).sum() mlm_non_mention_acc = (mlm_correct_mask * (1 - batch['mlm_target_is_mention'])).sum() mlm_non_mention_denom = (batch['mlm_target_weights'] * (1 - batch['mlm_target_is_mention'])).sum() metrics = { 'mlm': { 'loss': mlm_loss, 'acc': mlm_acc, 'denominator': mlm_denom, }, 'mlm_mention': { 'acc': mlm_mention_acc, 'denominator': mlm_mention_denom, }, 'mlm_non_mention': { 'acc': mlm_non_mention_acc, 'denominator': mlm_non_mention_denom, }, } if 'intermediate_mention_encodings' in loss_helpers: intermediate_target_mention_encodings = jut.matmul_slice( loss_helpers['intermediate_mention_encodings'], batch['mention_target_indices']) else: intermediate_target_mention_encodings = loss_helpers[ 'im_target_mention_encodings'] if model_config.encoder_config.get('no_entity_attention', False): (el_im_loss, el_im_metrics, (el_im_acc_per_mention, el_im_weight_per_mention)) = mention_losses.entity_linking_loss( intermediate_target_mention_encodings, loss_helpers['entity_embeddings'], mention_target_ids, batch['mention_target_weights'], el_score_mode) el_im_denom = el_im_metrics['denominator'] metrics['el_intermediate'] = el_im_metrics metrics['el_intermediate_masked'] = { 'acc': jnp.dot(el_im_acc_per_mention, el_im_weight_per_mention * mention_target_is_masked), 'denominator': jnp.dot(el_im_weight_per_mention, mention_target_is_not_masked), } metrics['el_intermediate_non_masked'] = { 'acc': jnp.dot(el_im_acc_per_mention, el_im_weight_per_mention * mention_target_is_masked), 'denominator': jnp.dot(el_im_weight_per_mention, mention_target_is_not_masked), } else: intermediate_entity_attention = loss_helpers[ 'intermediate_entity_attention'] # Construct targets and ids for intermediate entity linking loss intermediate_target_ids = jnp.zeros_like(batch['mention_mask']) intermediate_target_ids = intermediate_target_ids.at[ batch['mention_target_indices']].add( mention_target_ids * batch['mention_target_weights']) intermediate_target_weights = jnp.zeros_like( batch['mention_mask'], dtype=intermediate_entity_attention.dtype) intermediate_target_weights = intermediate_target_weights.at[ batch['mention_target_indices']].add( batch['mention_target_weights']) mention_is_masked = jnp.zeros_like(batch['mention_mask']) mention_is_masked = mention_is_masked.at[ batch['mention_target_indices']].add( mention_target_is_masked * batch['mention_target_weights']) el_im_loss, el_im_denom = metric_utils.compute_weighted_cross_entropy( intermediate_entity_attention, intermediate_target_ids, intermediate_target_weights, inputs_are_prob=True) el_im_correct_mask = jnp.equal( jnp.argmax(intermediate_entity_attention, axis=-1), intermediate_target_ids) * intermediate_target_weights el_im_acc = el_im_correct_mask.sum() el_im_acc, _ = metric_utils.compute_weighted_accuracy( intermediate_entity_attention, intermediate_target_ids, intermediate_target_weights) intermediate_entity_cos_sim = loss_helpers[ 'intermediate_entity_cos_sim'][batch['mention_target_indices'], mention_target_ids] metrics['el_intermediate'] = { 'loss': el_im_loss, 'acc': el_im_acc, 'cos_sim': jnp.dot(intermediate_entity_cos_sim, batch['mention_target_weights']), 'denominator': el_im_denom, } metrics['el_intermediate_masked'] = { 'acc': jnp.dot(el_im_correct_mask, mention_is_masked), 'denominator': jnp.dot(batch['mention_target_weights'], batch['mention_target_is_masked']), } metrics['el_intermediate_non_masked'] = { 'acc': jnp.dot(el_im_correct_mask, (1 - mention_is_masked)), 'denominator': jnp.dot(batch['mention_target_weights'], (1 - batch['mention_target_is_masked'])), } im_final_mention_encodings_cos_sim = jut.cosine_similarity( intermediate_target_mention_encodings, loss_helpers['target_mention_encodings']) metrics['im_final_mention_encodings'] = { 'cos_sim': jnp.dot(im_final_mention_encodings_cos_sim, batch['mention_target_weights']), 'denominator': batch['mention_target_weights'].sum(), } (el_final_loss, el_final_metrics, (el_final_acc_per_mention, el_final_weight_per_mention)) = mention_losses.entity_linking_loss( loss_helpers['target_mention_encodings'], loss_helpers['entity_embeddings'], mention_target_ids, batch['mention_target_weights'], el_score_mode) el_final_denom = el_final_metrics['denominator'] metrics['el_final'] = el_final_metrics metrics['el_final_masked'] = { 'acc': jnp.dot(el_final_acc_per_mention, el_final_weight_per_mention * mention_target_is_masked), 'denominator': jnp.dot(el_final_weight_per_mention, mention_target_is_masked), } metrics['el_final_non_masked'] = { 'acc': jnp.dot( el_final_acc_per_mention, el_final_weight_per_mention * mention_target_is_not_masked), 'denominator': jnp.dot(el_final_weight_per_mention, mention_target_is_not_masked), } loss = mlm_weight * mlm_loss / mlm_denom loss += el_im_weight * el_im_loss / el_im_denom loss += el_final_weight * el_final_loss / el_final_denom if mtb_im_weight > 0: (mtb_im_loss, mtb_im_metrics) = mention_losses.mtb_loss( intermediate_target_mention_encodings, batch['mention_target_batch_positions'], mention_target_ids, batch_size, mtb_score_mode, mention_target_is_masked, 'im_') mtb_im_denom = mtb_im_metrics['im_mtb']['denominator'] loss += mtb_im_weight * mtb_im_loss / mtb_im_denom metrics.update(mtb_im_metrics) if mtb_final_weight > 0: (mtb_final_loss, mtb_final_metrics) = mention_losses.mtb_loss( loss_helpers['target_mention_encodings'], batch['mention_target_batch_positions'], mention_target_ids, batch_size, mtb_score_mode, mention_target_is_masked, 'final_') mtb_final_denom = mtb_final_metrics['final_mtb']['denominator'] loss += mtb_final_weight * mtb_final_loss / mtb_final_denom metrics.update(mtb_final_metrics) metrics['agg'] = { 'loss': loss, 'denominator': 1.0, } return loss, metrics, {} return loss_fn
2bd783713fc5e7f9ca1abcb919e06d59ee812dd5
05d3b4d5e0a2b531429434f4500a0f60ec63785d
/Method_Using range in a function.py
f264dfbe02f502becf77e7fae829ed8d8c234943
[]
no_license
golfnut1400/Python201
8fcce72bfee78aafef230b5fdb1bc47bad51b829
311a6d7d55b5e2f76623809102c58ef70464a722
refs/heads/master
2021-09-03T06:33:49.792487
2018-01-06T13:38:58
2018-01-06T13:38:58
110,043,016
0
0
null
null
null
null
UTF-8
Python
false
false
242
py
import random def request_range(start, end): x = random.randrange(start,end) # creates a random number from the 2 arguments print(x) request_range(1,1000) # calls the request_range function and passes the 2 arguments
e4bc1036fc2022301460be8634e270c0ff35dfdc
8ca045c0b94729222e8f3ffe184c0d4f564418c4
/Image/composite_bands.py
5969cc2f6e8204679acd4bee99030483ca72b467
[ "MIT" ]
permissive
levi-manley/earthengine-py-notebooks
bc77632ca22ca85c0092c18f1eb8321abfbe874a
f5a888ddb6834f164e7399b20c683fb9cf604465
refs/heads/master
2021-01-02T12:17:27.974005
2020-02-09T02:59:20
2020-02-09T02:59:20
null
0
0
null
null
null
null
UTF-8
Python
false
false
3,656
py
''' <table class="ee-notebook-buttons" align="left"> <td><a target="_blank" href="https://github.com/giswqs/earthengine-py-notebooks/tree/master/Image/composite_bands.ipynb"><img width=32px src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" /> View source on GitHub</a></td> <td><a target="_blank" href="https://nbviewer.jupyter.org/github/giswqs/earthengine-py-notebooks/blob/master/Image/composite_bands.ipynb"><img width=26px src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/883px-Jupyter_logo.svg.png" />Notebook Viewer</a></td> <td><a target="_blank" href="https://mybinder.org/v2/gh/giswqs/earthengine-py-notebooks/master?filepath=Image/composite_bands.ipynb"><img width=58px src="https://mybinder.org/static/images/logo_social.png" />Run in binder</a></td> <td><a target="_blank" href="https://colab.research.google.com/github/giswqs/earthengine-py-notebooks/blob/master/Image/composite_bands.ipynb"><img src="https://www.tensorflow.org/images/colab_logo_32px.png" /> Run in Google Colab</a></td> </table> ''' # %% ''' ## Install Earth Engine API Install the [Earth Engine Python API](https://developers.google.com/earth-engine/python_install) and [geehydro](https://github.com/giswqs/geehydro). The **geehydro** Python package builds on the [folium](https://github.com/python-visualization/folium) package and implements several methods for displaying Earth Engine data layers, such as `Map.addLayer()`, `Map.setCenter()`, `Map.centerObject()`, and `Map.setOptions()`. The magic command `%%capture` can be used to hide output from a specific cell. Uncomment these lines if you are running this notebook for the first time. ''' # %% # %%capture # !pip install earthengine-api # !pip install geehydro # %% ''' Import libraries ''' # %% import ee import folium import geehydro # %% ''' Authenticate and initialize Earth Engine API. You only need to authenticate the Earth Engine API once. Uncomment the line `ee.Authenticate()` if you are running this notebook for the first time or if you are getting an authentication error. ''' # %% # ee.Authenticate() ee.Initialize() # %% ''' ## Create an interactive map This step creates an interactive map using [folium](https://github.com/python-visualization/folium). The default basemap is the OpenStreetMap. Additional basemaps can be added using the `Map.setOptions()` function. The optional basemaps can be `ROADMAP`, `SATELLITE`, `HYBRID`, `TERRAIN`, or `ESRI`. ''' # %% Map = folium.Map(location=[40, -100], zoom_start=4) Map.setOptions('HYBRID') # %% ''' ## Add Earth Engine Python script ''' # %% # There are many fine places to look here is one. Comment # this out if you want to twiddle knobs while panning around. Map.setCenter(-61.61625, -11.64273, 14) # Grab a sample L7 image and pull out the RGB and pan bands # in the range (0, 1). (The range of the pan band values was # chosen to roughly match the other bands.) image1 = ee.Image('LANDSAT/LE7/LE72300681999227EDC00') rgb = image1.select('B3', 'B2', 'B1').unitScale(0, 255) gray = image1.select('B8').unitScale(0, 155) # Convert to HSV, swap in the pan band, and convert back to RGB. huesat = rgb.rgbToHsv().select('hue', 'saturation') upres = ee.Image.cat(huesat, gray).hsvToRgb() # Display before and after layers using the same vis parameters. visparams = {'min': [.15, .15, .25], 'max': [1, .9, .9], 'gamma': 1.6} Map.addLayer(rgb, visparams, 'Orignal') Map.addLayer(upres, visparams, 'Pansharpened') # %% ''' ## Display Earth Engine data layers ''' # %% Map.setControlVisibility(layerControl=True, fullscreenControl=True, latLngPopup=True) Map
07d00c1fdef3a45ed0f84ae4231f2daf5452a390
58ca273d2a9ee7f75b4bde3990513f74441143f0
/Python/Cryptography/Data diffusion calculator.py
3db11d81443b4ff139c508f9c7c69195597faaec
[]
no_license
Al153/Programming
6db4b3c9d34747e1248aed2b0ee7fb7a35cef8d2
26de0b5607c6329bed2d6454090f00b098bc837f
refs/heads/master
2021-04-12T04:13:00.945021
2019-07-12T17:47:08
2019-07-12T17:47:08
12,439,227
2
2
null
2014-08-13T19:21:46
2013-08-28T16:47:08
Game Maker Language
UTF-8
Python
false
false
4,785
py
from decimal import Decimal class Datadiffusion: def __init__(self,text): self.text = text self.alphabet = [] for i in text: if i not in self.alphabet: self.alphabet.append(i) def change_alphabet(self,newcharacters): for i in newcharacters: if i not in self.alphabet: self.alphabet.append(i) self.frequency_analysis() #recalculates def delete_characters(self,characters_to_delete): for i in characters_to_delete: if i in self.alphabet: del(self.alphabet[self.alphabet.index(i)]) def change_text(self,text): self.text = text self.alphabet = [] for i in text: if i not in self.alphabet: self.alphabet.append(i) self.frequency_analysis() def frequency_analysis(self): self.values = [0]*len(self.alphabet) for i in self.text: self.values[self.alphabet.index(i)]+=1 def run_test(self): try: self.values.sort() result = 0 length = len(self.values) for i in xrange(length//2): result += self.values[length-1 -i] - self.values[i] length = len(self.text) result = result/float(length) return 1 - result except AttributeError: self.frequency_analysis() return self.run_test() class Tools: #Arrays for lookups lowercase = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') uppercase = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z') def char_to_int(self,char): #Character => integer try: return self.uppercase.index(char) except ValueError: try: return self.lowercase.index(char) except ValueError: print "Failure" return -1 def int_to_char(self,integer): #Integer => character return self.uppercase[integer] def preprocess(self,string): #Removes spaces, punctuation etc result = [] for i in range(len(string)): if string[i] in self.uppercase + self.lowercase: try: lookup = self.uppercase.index(string[i]) except ValueError: lookup = self.lowercase.index(string[i]) result.append(self.uppercase[lookup]) return result text = ''' GRLZEHNRAOTNNPMPVKUGUFLIGYBRPNOSTUHKMGLTTUBRSYUGGNOAFXDALVEIEQGRNUGRLOLNGALUMHGRLHLIMAZGBAAYEIMPGRLDKELRTQNPRNZHGATULGHMEUPLUQRATPLPKITYGRHBGYUNMPPMERTYIOUGANALMPBVTADAEIGDUZARKTPOAOLTUFKZRLUGEPPLADTFADKEBLUGRAVDPLHKMGRLRAEPRDKEUIXLPMFADGKHIOTQOAEPUHMHAPKGGTRUTAHZFYBNEPGRUGNACXOUTUMRGYGRNIIEAMPLHLINVBAOPMMYOKTGYGGTREAYGTYDGAAMAYGYBRSYUGGNADKEBLUGRAGRELUGATBPTYKOHGUHTAHZFYBNRPTYMAUMNLPNNLKOOKTGYGGTUGOAYGGTZCGTNPVDXMKODEEXAKQFIZRARLKOTAHZFYBNLPBVDASNGTPNMGRMARKGATRATHBNEPAORLUNBRKENPIZRAUNUGRLRDEREHRAMVKOLYFBEINGHMADARVDALUGRARDSVTADATUUOBAAGLYGTOIAREDPNIOUFPVGAQYLYGTNGAOEIEQGRHBGYUNBLNKEXEICDAGRENAYAUGEPTAHZFYBNLINBGUBRYATUMRGTUGATBPTYKOHCDBMCHUNSGRNKMGHZTUADPNIOEPUGANAOIEIPAMYEUNUAKRQHRDIELRSPEPREKMGTLTQXGRUGRAUGGEYDARTOBIERUHTOVKFLAMTNUNUAKRQHRDFWGDQUBIERHMEHRANAPLSYUGEPTUEBANTPOMOIYKEPDEGTSEKMLTDALPMPADARTAHOBVTLYAOKOGRABLNKEXNPTLLNTQMUPMFAGYBRSYUGLGLIMAVNTYGTLREQUOMREQGRNIIEAMPLTOPNRMTGMHUGLNBRLKLPYGARLWLDAPKGMPYGFBOKSPDYREEROITHGUUHATHURQGDUGATBPTYKOHCPUUGEPTAHZFYBNLPVBPNGTGDZKARUGKOUGRGBVTVARTPESVDTUBRSYUGATBPTYKOCYLPARUPEORLUNHLEIGDEIAKTMKZKOUZAUMUTLXLPMIOKVMAEAGYZHTYIUDAMPUNHKUHAKIEYGUGRDGQPANPNAUMHMZHDAYGVSRAUTKOARQFPOTNUGGNAREPZKDOXMUHUGLGEPGRAEEILKXENAPUGTEIUTVKFLDFIOPNOTGYKHINIAGTKBLGUHUGDYARQGGRECOAAFPUOBMREKUOIUGYBRUTGRVKFLAFLGUZKEUGRGUZTLKONITYILEUARBRPFLYGTUGUHUZHBEXTLDAFBRLEIEQGRILYGAODEPLKEZKDOUMBLEUUGRARGBAAGLYGTBDPERMHTRLEIAQLPTLEQMZUZLZARTUUHEPKITYRDNSGROUPTANUTREGBLPARUPEORLUNNPULMRRDPLTUEBKOBTMUSGUHUEMZIUPMTYADMTNPUGRLMPHKYAEZMHNIARMHPLADQXUHQKIOGDDERLGABOKEVBTGFXKOUGGNIORKAMRAUFINAGAOTNPLBRSVTVHKKGRSPMIOUNEINUGRAUDAUNHMZHGTSPOANAUFRAHMEHRANAPLARUESREGWSPOPMYGEIRKZHLYTAEUQXUZELGABRALUALTTLEQKRGYDGSYUGLGADQRMBYDAKEKNUDEARDLWNOIYQBRSYUGMPVDTUGRZKDOMHUGGNGRSYUNBLNKEXVKUGZNZHTALOMPPMIOKVUZELAMNDUNUALTGTUNTGMHUGLTDYUHMQUNZNPRKEEINUGREUNUGRHSOHRALPLIDAMIMSEGTULYLNEILKENADPNUPLRHMEZUZLUPQUIEUKOUZDZUHOCANRFNPERLZ ''' Tools = Tools() text = Tools.preprocess(text) Diffusion = Datadiffusion(text) Diffusion.change_alphabet(('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z')) print Diffusion.run_test()
369fd4ab3b738c3c268ae4549cc141ea8c623db8
e5f5468ba082b1c057ac4167831aab95aa7c0d27
/backend/home/migrations/0002_load_initial_data.py
c6bfce958c6507b9aeb1cb4243b11fe43b59d7ea
[]
no_license
crowdbotics-apps/mobile-28-oct-dev-14129
bd98341f59a15200661a3896b1288b229247b906
02abe8260760b9eef10871767982e8407642b9b9
refs/heads/master
2023-01-09T13:41:10.439050
2020-10-28T11:31:33
2020-10-28T11:31:33
307,911,560
0
0
null
null
null
null
UTF-8
Python
false
false
1,310
py
from django.db import migrations def create_customtext(apps, schema_editor): CustomText = apps.get_model("home", "CustomText") customtext_title = "mobile 28 oct" CustomText.objects.create(title=customtext_title) def create_homepage(apps, schema_editor): HomePage = apps.get_model("home", "HomePage") homepage_body = """ <h1 class="display-4 text-center">mobile 28 oct</h1> <p class="lead"> This is the sample application created and deployed from the Crowdbotics app. You can view list of packages selected for this application below. </p>""" HomePage.objects.create(body=homepage_body) def create_site(apps, schema_editor): Site = apps.get_model("sites", "Site") custom_domain = "mobile-28-oct-dev-14129.botics.co" site_params = { "name": "mobile 28 oct", } if custom_domain: site_params["domain"] = custom_domain Site.objects.update_or_create(defaults=site_params, id=1) class Migration(migrations.Migration): dependencies = [ ("home", "0001_initial"), ("sites", "0002_alter_domain_unique"), ] operations = [ migrations.RunPython(create_customtext), migrations.RunPython(create_homepage), migrations.RunPython(create_site), ]
c11655dd2fa086b3766fa7d30fdd14a78dacded3
28c598bf75f3ab287697c7f0ff1fb13bebb7cf75
/mud/world/immortalcommand.py
f344bee01f8e462c83032b469508b953238ba095
[]
no_license
keaysma/solinia_depreciated
4cb8811df4427261960af375cf749903d0ca6bd1
4c265449a5e9ca91f7acf7ac05cd9ff2949214ac
refs/heads/master
2020-03-25T13:08:33.913231
2014-09-12T08:23:26
2014-09-12T08:23:26
null
0
0
null
null
null
null
UTF-8
Python
false
false
44,469
py
# Copyright (C) 2004-2007 Prairie Games, Inc # Please see LICENSE.TXT for details import math from defines import * from zone import Zone from spawn import Spawn from core import * import sys from mud.common.permission import User from damage import XPDamage # Volatile dictionaries for the immortal stasis functionality. # As this generally won't be used in large scale, adding a # separate attribute to mobs just for this functionality # wouldn't make much sense. # STASISDICT is a dictionary with zones as keys and zone dictionaries # as values which have a group name as key and a list with first element # being a set of mobs and second element a flag if the group is in stasis # as values. STASISDICT = {} # MOB_STASISDICT is a dictionary with zones as keys and zone dictionaries # as values which have a mob as key and a list with first element being # group name and second element being a flag if the related mob is in # stasis or not as values. MOB_STASISDICT = {} # Helper function for stasis groups, add a mob to a specific stasis group # and if already present resync stasis status. def addMobToStasisGroup(mob, groupName): # Get the zone. zone = mob.zone # Get the stasis group zone dictionary. zoneDict = STASISDICT.setdefault(zone,{}) # Add the mob to the group. group = zoneDict.setdefault(groupName,[set(),False]) group[0].add(mob) # Check if this mob already was in some stasis group. mobZoneDict = MOB_STASISDICT.get(zone) if mobZoneDict: mobInfo = mobZoneDict.get(mob) # If the mob already was in a stasis group, do some cleanup. if mobInfo: if mobInfo[0] != groupName: stasisSet = zoneDict[mobInfo[0]][0] stasisSet.discard(mob) if not len(stasisSet): del zoneDict[mobInfo[0]] if mobInfo[1]: mob.stun -= 5 mob.invulnerable -= 1 # If this mob is a player mob, give notice. if mob.player: mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "%s has been released from stasis!\\n"%mob.name) # If the group is in stasis, put the mob into stasis as well. if group[1]: mob.stun += 5 mob.invulnerable += 1 # If this mob is a player mob, give notice. if mob.player: mob.player.sendGameText(RPG_MSG_GAME_EVENT, \ "%s has been put into stasis!\\n"%mob.name) # Add the new stasis group mapping to the mob. MOB_STASISDICT.setdefault(zone,{})[mob] = [groupName,group[1]] # Refresh mob info to propagate status changes. mob.mobInfo.refresh() def CmdDespawn(mob, args): zone = mob.zone # Despawn all non-player and non-playerpet mobs. No matter what. mobList = zone.spawnedMobs[:] mobList.extend(zone.activeMobs) for spMob in mobList: if not spMob.player and not (spMob.master and spMob.master.player): zone.removeMob(spMob) def CmdKill(mob, args): from damage import Damage target = mob.target if target: # Make sure the mob is properly initialized. if not target.player: if not target.mobInitialized: target.initMob() # Make sure the immortal and only the immortal gets xp. target.xpDamage = {} target.xpDamage[mob] = XPDamage() target.xpDamage[mob].addDamage(999999) # Kill. target.die(True) # Notify happy player about kill. mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "%s is struck down by lightning from the heavens!\\n"%target.name) # If the target was a player, notify this one as well. if target.player: target.player.sendGameText(RPG_MSG_GAME_CHARDEATH, \ "%s is struck down by lightning from the heavens!\\n"%target.name) def CmdStasis(mob, args): # Check if we got some arguments. if not len(args): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Syntax for immortal command stasis:\\n - '/imm stasis on/off <stasis group name>': Group name here is optional. Turn stasis for a specific group or the target on or off while adding the current target (if any) to this group.\\n - '/imm stasis add/remove <stasis group name>': Group name here is required. Add/remove the target to/from the specified group, without toggling stasis for this group. If group is in stasis, target will be set to stasis as well on add and taken out of stasis on removal.\\n - '/imm stasis info': Returns a list with all stasis groups in the current zone, their members and their status.\\n - '/imm stasis clear': Clear all stasis groups for the current zone, take all mobs out of stasis.\\n") return # Get the subcommand. subcommand = args[0].lower() # Get the immortals zone. zone = mob.zone # Get the immortals target. target = mob.target # Check if we want to clear the stasis dictionary for this zone. if subcommand == 'clear': # Clear the zone entry in the stasis dictionary. try: del STASISDICT[zone] except KeyError: pass # Get and clear the zone dictionary of mob stasis group mappings and # take all mobs in this dictionary out of stasis if necessary. try: zoneDict = MOB_STASISDICT.pop(zone) for stmob,values in zoneDict.iteritems(): if values[1]: stmob.stun -= 5 stmob.invulnerable -= 1 stmob.mobInfo.refresh() # If this mob is a player mob, give notice. if stmob.player: stmob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "%s has been released from stasis!\\n"%stmob.name) except KeyError: pass # Give feedback and return. mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "All stasis groups in %s have been cleared.\\n"%zone.zone.niceName) return # Check if we want info on current stasis groups in this zone. elif subcommand == 'info': # Get the current stasis zone dictionary. zoneDict = STASISDICT.get(zone) if not zoneDict or not len(zoneDict): mob.player.sendGameText(RPG_MSG_GAME_GAINED,"There are currently no stasis groups in %s.\\n"%zone.zone.niceName) return # Build the info string. mobZoneDict = MOB_STASISDICT[zone] stasisGroups = "\\n".join(" - %s:\\n%s"%(groupName,"\\n".join(" -- %s : %s"%(stmob.name,mobZoneDict[stmob][1]) for stmob in groupInfo[0])) for groupName,groupInfo in zoneDict.iteritems()) # Display information to immortal and return. mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Stasis groups in %s:\\n%s\\n"%(zone.zone.niceName,stasisGroups)) return # Check if we want to add the target to a specified stasis group. elif subcommand == 'add': # Check if we have a valid target. if not target: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Please select a target before using this command.\\n") return # Check if a group argument is present. if len(args) == 1: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Please provide a stasis group name with this command.\\n") return # Get the stasis group name. groupName = ' '.join(args[1:]) # Add the target to the group. addMobToStasisGroup(target,groupName) # Give feedback. mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "Added %s to stasis group %s.\\n"%(target.name,groupName)) return # Check if we want to remove the target from a specified stasis group. elif subcommand == 'remove': # Check if we have a valid target. if not target: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Please select a target before using this command.\\n") return # Check if a group argument is present. if len(args) == 1: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Please provide a stasis group name with this command.\\n") return # Get the stasis group name. groupName = ' '.join(args[1:]) # Check if the target mob is in the specified group. zoneDict = MOB_STASISDICT.get(zone) if zoneDict: mobInfo = zoneDict.get(target) if mobInfo and mobInfo[0] == groupName: # Remove the target from the group. stasisSet = STASISDICT[zone][groupName][0] stasisSet.discard(target) if not len(stasisSet): del STASISDICT[zone][groupName] # If the mob was in stasis, cancel stasis. if mobInfo[1]: target.stun -= 5 target.invulnerable -= 1 target.mobInfo.refresh() # If this mob is a player mob, give notice. if target.player: target.player.sendGameText(RPG_MSG_GAME_GAINED, \ "%s has been released from stasis!\\n"%target.name) del MOB_STASISDICT[zone][target] # Give feedback. mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "Removed %s from group %s.\\n"%(target.name,groupName)) return # Failed to remove target from group since group does not exist # or target isn't in that group. mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "%s isn't part of the stasis group %s.\\n"%(target.name,groupName)) return # Check if we want to enable or cancel stasis for a stasis group or target. elif subcommand == 'on' or subcommand == 'off': # Get the group name if any. if len(args) > 1: groupName = ' '.join(args[1:]) # If there is a target, add it to the group. if target: addMobToStasisGroup(target,groupName) group = STASISDICT[zone][groupName] # Otherwise check if the group exists. else: group = None zoneDict = STASISDICT.get(zone) if zoneDict: group = zoneDict.get(groupName) if not group: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Stasis group %s does not exist.\\n"%groupName) return # Otherwise a target will be required. else: if not target: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Please provide a stasis group name or select a target before using this command.\\n") return # Automatically generate a group name for the target. groupName = "%s - %i"%(target.name,target.id) # Add the target to the automatically generated group. addMobToStasisGroup(target,groupName) group = STASISDICT[zone][groupName] mobZoneDict = MOB_STASISDICT[zone] # If the subcommand was on, put the desired group into stasis. if subcommand == 'on': if not group[1]: for stmob in group[0]: if not mobZoneDict[stmob][1]: stmob.stun += 5 stmob.invulnerable += 1 stmob.mobInfo.refresh() # If this mob is a player mob, give notice. if stmob.player: stmob.player.sendGameText(RPG_MSG_GAME_EVENT, \ "%s has been put into stasis!\\n"%stmob.name) mobZoneDict[stmob][1] = True group[1] = True mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "Stasis group %s has been put into stasis.\\n"%groupName) # Otherwise cancel stasis for the desired stasis group. else: if group[1]: for stmob in group[0]: if mobZoneDict[stmob][1]: stmob.stun -= 5 stmob.invulnerable -= 1 stmob.mobInfo.refresh() # If this mob is a player mob, give notice. if stmob.player: stmob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "%s has been released from stasis!\\n"%stmob.name) mobZoneDict[stmob][1] = False group[1] = False mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "Stasis has been cancelled for stasis group %s.\\n"%groupName) return # If we get here, the immortal needs a reminder on the command syntax. mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Syntax for immortal command stasis:\\n - '/imm stasis on/off <group name>': Group name here is optional. Turn stasis for a specific group or the target on or off while adding the current target (if any) to this group.\\n - '/imm stasis add/remove <group name>': Group name here is required. Add/remove the target to/from the specified group, without toggling stasis for this group. If group is in stasis, target will be set to stasis as well on add and taken out of stasis on removal.\\n - '/imm stasis info': Returns a list with all stasis groups, their members and their status.\\n - '/imm stasis clear': Clear all stasis groups for the current zone, take all mobs out of stasis.\\n") def CmdSet(mob, args): if not len(args): return what = args[0].upper() args = args[1:] if not len(args): return SetCommands = { 'WIND': CmdSetWind, 'TIME': CmdSetTime, 'WEATHER': CmdSetWeather } try: SetCommands[what](mob,args) except KeyError: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Only %s can be used in conjunction with the set command.\\n"%', '.join(SetCommands.iterkeys())) def CmdSetWind(mob,args): # Clamp wind to a range from 1 to 10. wind = max(1,min(10,int(args[0]))) mob.zone.weather.windspeed = wind mob.zone.weather.dirty = True mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Wind set.\\n") def CmdSetWeather(mob,args): # Clamp precipitation to something below or equal to 10. precip = min(10,int(args[0])) weather = mob.zone.weather weather.cloudCover = max(1,precip) weather.precip = precip weather.lastPrecipChange = 0 weather.lastCoverChange = 0 weather.dirty = True mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Weather set.\\n") def CmdSetTime(mob, args): try: # Get the arguments for hour and minutes to set. hour = int(args[0]) minute = 0 if len(args) == 2: minute = int(args[1]) # Get a handle to the current world. world = mob.player.world # If this server uses multiple clusters, need to propagate # time change across them. if world.daemonPerspective: world.daemonPerspective.callRemote("propagateCmd","setTime",hour,minute) # Set the new time for the current world instance. world.time.hour = hour world.time.minute = minute # Send a message to all players in the current world instance and # synchronize new time. for player in world.activePlayers: player.mind.callRemote("syncTime",world.time.hour,world.time.minute) player.sendSpeechText(RPG_MSG_SPEECH_SYSTEM,"\\nYou feel as if time has moved\\n\\n") # Send feedback to the immortal who used the command. mob.player.sendGameText(RPG_MSG_GAME_GAINED,"The time is now: %i:%i\\n"%(world.time.hour,world.time.minute)) except: # Syntax was probably wrong, send feedback to calling immortal. mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Problem setting time\\n") def CmdGiveMonster(mob,args): if not len(args): return mspawn = ' '.join(args) lowerSpawn = mspawn.lower() for monsterSpawn in mob.player.monsterSpawns: if monsterSpawn.spawn.lower() == lowerSpawn: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You already have the %s monster template.\\n"%monsterSpawn.spawn) return from spawn import Spawn try: con = Spawn._connection.getConnection() spawn = Spawn.get(con.execute("SELECT id FROM spawn WHERE lower(name)=\"%s\" LIMIT 1;"%lowerSpawn).fetchone()[0]) mspawn = spawn.name except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"No such spawn %s.\\n"%mspawn) return from player import PlayerMonsterSpawn PlayerMonsterSpawn(player=mob.player,spawn=mspawn) mob.player.sendGameText(RPG_MSG_GAME_GAINED,"You now have the %s monster template.\\n"%mspawn) def CmdGrantMonster(mob,args): if len(args) < 2: return pname = args[0] lowerPName = pname.lower() args = args[1:] mspawn = ' '.join(args) lowerSpawn = mspawn.lower() from player import Player try: con = Player._connection.getConnection() player = Player.get(con.execute("SELECT id FROM player WHERE lower(public_name) = \"%s\" LIMIT 1;"%lowerPName).fetchone()[0]) pname = player.publicName except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"No player by public name %s.\\n"%pname) return if not player.party or not len(player.party.members): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Player isn't logged in %s.\\n"%pname) return for monsterSpawn in player.monsterSpawns: if monsterSpawn.spawn.lower() == lowerSpawn: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s already has the %s monster template.\\n"%(pname,monsterSpawn.spawn)) return from spawn import Spawn try: con = Spawn._connection.getConnection() spawn = Spawn.get(con.execute("SELECT id FROM spawn WHERE lower(name) = \"%s\" LIMIT 1;"%lowerSpawn).fetchone()[0]) mspawn = spawn.name except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"No such spawn %s.\\n"%mspawn) return from player import PlayerMonsterSpawn PlayerMonsterSpawn(player=player,spawn=mspawn) mob.player.sendGameText(RPG_MSG_GAME_GAINED,"You have granted %s the %s monster template.\\n"%(pname,mspawn)) if player.zone: player.sendGameText(RPG_MSG_GAME_GAINED,"You now have the %s monster template.\\n"%mspawn) def CmdListMonsters(mob,args): if len(args) < 1: return pname = args[0] lowerPName = pname.lower() from player import Player try: con = Player._connection.getConnection() player = Player.get(con.execute("SELECT id FROM player WHERE lower(public_name) = \"%s\" LIMIT 1;"%lowerPName).fetchone()[0]) pname = player.publicName except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"No player by public name %s.\\n"%pname) return text = "%s has the following monster templates: %s\\n"%(pname,', '.join(ms.spawn for ms in player.monsterSpawns)) mob.player.sendGameText(RPG_MSG_GAME_GAINED,text) def CmdDenyMonster(mob,args): if len(args) < 2: return pname = args[0] lowerPName = pname.lower() args = args[1:] mspawn = ' '.join(args) lowerSpawn = mspawn.lower() from player import Player try: con = Player._connection.getConnection() player = Player.get(con.execute("SELECT id FROM player WHERE lower(public_name) = \"%s\" LIMIT 1;"%lowerPName).fetchone()[0]) pname = player.publicName except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"No player by public name %s.\\n"%pname) return if not player.party or not len(player.party.members): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Player isn't logged in %s.\\n"%pname) return for ms in player.monsterSpawns: if ms.spawn.lower() == lowerSpawn: ms.destroySelf() break else: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s doesn't have the %s monster template.\\n"%(pname,mspawn)) return mob.player.sendGameText(RPG_MSG_GAME_GAINED,"You have denied %s the %s monster template.\\n"%(pname,mspawn)) if player.zone: player.sendGameText(RPG_MSG_GAME_DENIED,"You no longer have the %s monster template.\\n"%mspawn) def CmdGrantLevel(mob,args): if len(args) < 2: return pname = args[0] lowerPName = pname.lower() klass = args[1].lower() from player import Player try: con = Player._connection.getConnection() player = Player.get(con.execute("SELECT id FROM player WHERE lower(public_name) = \"%s\" LIMIT 1;"%lowerPName).fetchone()[0]) pname = player.publicName except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"No player by public name %s.\\n"%pname) return if not player.party or not len(player.party.members): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Player isn't logged in %s.\\n"%pname) return c = player.party.members[0] gained = False spawn = c.spawn if spawn.pclassInternal.lower() == klass: c.gainLevel(0) gained = True if spawn.sclassInternal.lower() == klass: c.gainLevel(1) gained = True if spawn.tclassInternal.lower() == klass: c.gainLevel(2) gained = True if gained: t = "%s %i / %s %i / %s %i"%(spawn.pclassInternal,spawn.plevel,spawn.sclassInternal,spawn.slevel,spawn.tclassInternal,spawn.tlevel) mob.player.sendGameText(RPG_MSG_GAME_GAINED,"%s is now a %s.\\n"%(c.name,t)) else: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Character doesn't have that class\\n") def CmdModStat(mob,args): if not len(args): return # Get the target for the effect. target = mob.target if not target: target = mob # If both last arguments are numbers, then the last number marks # the effect duration in minutes. Default is 30 minutes. duration = 30 * durMinute if args[-2].isdigit(): try: duration = int(args[-1]) * durMinute except ValueError: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s can't be used to set the effect duration."%args[-1]) # Create an effect out of the desired values. mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Implementation of this command is not yet finished.") def CmdGimme(mob,args): from item import ItemProto,getTomeAtLevelForScroll argUpper = args[0].upper() if argUpper == 'TOME': itemname = argUpper tomename = ' '.join(args[2:-1]) # strip "Tome of" and tome level elif argUpper not in ("PLEVEL","SLEVEL","TLEVEL","SKILL","MONEY","XP","RENEW","PRESENCE"): itemname = ' '.join(args) else: itemname = argUpper levels = 0 if len(args) > 1: try: levels = int(args[1]) except: pass if itemname == 'MONEY': if len(args) > 1: try: amount = int(args[1]) except: amount = 1000 else: amount = 1000 mob.player.platinum += amount if mob.player.platinum < 0: mob.player.platinum = 0 if amount > 0: mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Gained %i platinum.\\n"%amount) else: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Lost %i platinum.\\n"%(-amount)) return elif itemname == 'XP': for c in mob.player.party.members: c.gainXP(1000000) return elif itemname == 'PLEVEL': if levels == 0: return #no point in trying for x in xrange(0,levels): mob.player.curChar.gainLevel(0) return elif itemname == 'SLEVEL': if levels == 0: return #no point in trying for x in xrange(0,levels): mob.player.curChar.gainLevel(1) return elif itemname == 'TLEVEL': if levels == 0: return #no point in trying for x in xrange(0,levels): mob.player.curChar.gainLevel(2) return elif itemname == 'SKILL': if levels == 0: return #no point in trying m = mob.player.curChar.mob for x in xrange(0,levels): for skname in m.skillLevels.iterkeys(): mob.player.curChar.checkSkillRaise(skname,0,0) return elif itemname == 'PRESENCE': if levels < 0: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"The value provided must be a positive integer.\\n") return if levels > RPG_MAX_PRESENCE: levels = RPG_MAX_PRESENCE currentCharacter = mob.player.curChar currentCharacter.mob.pre = levels currentCharacter.mob.preBase = levels currentCharacter.spawn.preBase = levels currentCharacter.mob.derivedDirty = True mob.player.sendGameText(RPG_MSG_GAME_GAINED,"You now have %i presence.\\n"%levels) return elif itemname == 'RENEW': for c in mob.player.party.members: m = c.mob m.health = m.maxHealth m.mana = m.maxMana m.stamina = m.maxStamina m.skillReuse = {} m.recastTimers = {} if m.pet: m.pet.health = m.pet.maxHealth mob.player.cinfoDirty = True return elif itemname == 'TOME': char = mob.player.curChar levels = ['1','2','3','4','5','6','7','8','9','10'] lupper = args[-1].upper() try: tomelevel = levels.index(lupper) + 1 except: try: tomelevel = RPG_ROMAN.index(lupper) + 1 except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s isn't a valid tome level!\\n"%args[-1]) return if tomelevel <= 1: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s isn't a valid tome level!\\n"%args[-1]) return try: con = ItemProto._connection.getConnection() scroll = ItemProto.get(con.execute("SELECT id FROM item_proto WHERE lower(name)=lower(\"Scroll of %s\") LIMIT 1;"%tomename).fetchone()[0]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s is no spell name!\\n"%tomename) return nitem = getTomeAtLevelForScroll(scroll,tomelevel) if not char.giveItemInstance(nitem): nitem.destroySelf() mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s doesn't have enough inventory space\\n"%char.name) return char.refreshItems() mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Gained %s\\n"%nitem.name) return from crafting import FocusGenSpecific item = FocusGenSpecific(itemname) if item: if not mob.player.curChar.giveItemInstance(item): item.destroySelf() mob.player.sendGameText(RPG_MSG_GAME_DENIED,"%s doesn't have enough inventory space\\n"%char.name) return else: item = mob.player.giveItem(itemname,True,True) if item: if RPG_SLOT_WORN_END > item.slot >= RPG_SLOT_WORN_BEGIN: mob.equipItem(item.slot,item) mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Gained %s\\n"%item.name) return mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Failure getting %s\\n"%itemname) def CmdSpawn(mob, args): try: # Check if there were coords supplied. if args[-1].endswith(']'): # Extract the coords argument. # It should look like this: [x.x y.y z.z]. x = float(args[-3][1:]) y = float(args[-2]) z = float(args[-1][:-1]) spawnName = ' '.join(args[:-3]) # Otherwise take the immortals position. else: mypos = mob.simObject.position x = mypos[0] y = mypos[1] z = mypos[2] spawnName = ' '.join(args) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Invalid arguments to immortal spawn command. Syntax is '/imm spawn <spawn name> [x-coord y-coord z-coord]' where the coords with their '[]' brackets are optional.\\n") return # Get the spawn. try: con = Spawn._connection.getConnection() spawn = Spawn.get(con.execute("SELECT id FROM spawn WHERE lower(name)=lower(\"%s\") LIMIT 1;"%spawnName).fetchone()[0]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Failure spawning %s, this spawn doesn't exist.\\n"%spawnName) return # Put the transform together. rot = mob.simObject.rotation transform = (x,y,z,rot[0],rot[1],rot[2],rot[3]) # Spawn the desired mob. mob.zone.spawnMob(spawn,transform,-1) # Give feedback about the successful spawning. mob.player.sendGameText(RPG_MSG_GAME_GAINED, \ "%s spawned at [%0.2f %0.2f %0.2f].\\n"%(spawnName,x,y,z)) def CmdWorldAggro(mob, args): # Get a handle to the current world instance. world = mob.player.world # Get the new aggro state. # If there was no argument supplied, just toggle. newAggroState = not world.aggroOn if len(args): if args[0].lower() == 'off': # If the state didn't change, return and give feedback. if newAggroState: mob.player.sendGameText(RPG_MSG_GAME_GLOBAL,"Monsters still won't initiate attacks.\\n") return newAggroState = False else: # If the state didn't change, return and give feedback. if not newAggroState: mob.player.sendGameText(RPG_MSG_GAME_GLOBAL,"Monsters still will initiate attacks.\\n") return newAggroState = True # Set this world instance's aggro state to the new one. world.aggroOn = newAggroState # If the server uses multiple zone clusters, propagate the command # across them. if world.daemonPerspective: world.daemonPerspective.callRemote("propagateCmd","setWorldAggro",newAggroState) # Give feedback to the calling immortal. if newAggroState: mob.player.sendGameText(RPG_MSG_GAME_GLOBAL,"Monsters WILL initiate attacks.\\n") else: mob.player.sendGameText(RPG_MSG_GAME_GLOBAL,"Monsters will NOT initiate an attacks.\\n") def CmdMyAggro(mob,args): aggroOff = mob.aggroOff if not len(args): aggroOff = not aggroOff else: if args[0].lower()=='off': aggroOff = True else: aggroOff = False for c in mob.player.party.members: c.mob.aggroOff = aggroOff if aggroOff: mob.player.sendGameText(RPG_MSG_GAME_GLOBAL,"Monsters will NOT attack your party.\\n") else: mob.player.sendGameText(RPG_MSG_GAME_GLOBAL,"Monsters WILL attack your party.\\n") def CmdTP(mob,args): player = mob.player zname = args[0] if zname.lower() == 'bindstone': if player.darkness: z = player.darknessBindZone trans = player.darknessBindTransform elif player.monster: z = player.monsterBindZone trans = player.monsterBindTransform else: z = player.bindZone trans = player.bindTransform dst = ' '.join(str(i) for i in trans) else: try: z = Zone.byName(zname) dst = z.immTransform except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown zone or zone not setup for immortal command %s.\\n"%zname) return #are we in the same zone? if player.zone.zone == z: #good #we just need to respawn player, whew player.zone.respawnPlayer(player,dst) else: from zone import TempZoneLink zlink = TempZoneLink(zname,dst) player.world.onZoneTrigger(player,zlink) def CmdSystemMsg(mob, args): # Check if there is even a message and return if not. if not len(args): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Need to specify a message to use with this command.") return # Assemble the message. msg = r'SYSTEM: %s\n'%(' '.join(args)) # Get a handle to the current world. world = mob.player.world # If this server uses multiple clusters, need to propagate the # message across them. if world.daemonPerspective: world.daemonPerspective.callRemote("propagateCmd","sendSysMsg",msg) # Run through this servers players and send them the message. for p in world.activePlayers: p.sendSpeechText(RPG_MSG_SPEECH_SYSTEM,msg) def CmdScribeMsg(mob, args): # Check if there is even a message and return if not. if not len(args): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Need to specify a message to use with this command.") return # Assemble the message. msg = "\\nServerNotice: %s\\n\\n"%(' '.join(args)) # Get a handle to the current world. world = mob.player.world # If this server uses multiple clusters, need to propagate the # message across them. if world.daemonPerspective: world.daemonPerspective.callRemote("propagateCmd","sendSysMsg",msg) # Run through this servers players and send them the message. for p in world.activePlayers: p.sendSpeechText(RPG_MSG_SPEECH_SYSTEM,msg) def CmdReloadCommands(mob,args): reload(sys.modules['mud.world.command']) def CmdReloadModule(mob,args): reload(sys.modules[args[0]]) def CmdGrant(mob,args): from mud.common.permission import User,Role if len(args) < 2: return try: user = User.byName(args[0]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0]) return try: role = Role.byName(args[1]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown role %s.\\n"%args[1]) return for r in user.roles: if r.name == role.name: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"User %s already has the %s role.\\n"%(args[0],args[1])) return if role.name == "Immortal": from newplayeravatar import NewPlayerAvatar if mob.player.publicName != NewPlayerAvatar.ownerPublicName: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Immortal access can only be granted by the server's owner.\\n") return mob.player.sendGameText(RPG_MSG_GAME_GAINED,"User %s granted the %s role.\\n"%(args[0],args[1])) user.addRole(role) def CmdDeny(mob,args): from mud.common.permission import User,Role from player import Player if len(args) < 2: return try: user = User.byName(args[0]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0]) return if not IsUserSuperior(mob.player.publicName,user.name): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n") return try: role = Role.byName(args[1]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown role %s.\\n"%args[1]) return for r in user.roles: if r.name == role.name: user.removeRole(r) try: player = Player.byPublicName(args[0]) if player.avatar and player.avatar.masterPerspective: player.avatar.masterPerspective.removeAvatar("GuardianAvatar") except: pass mob.player.sendGameText(RPG_MSG_GAME_GAINED,"User %s denied the %s role.\\n"%(args[0],args[1])) return mob.player.sendGameText(RPG_MSG_GAME_DENIED,"User %s doesn't have the %s role.\\n"%(args[0],args[1])) def CmdSetPlayerPassword(mob,args): from player import Player if CoreSettings.SINGLEPLAYER: return if len(args) != 2: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Please specify a player and a password\\n") return try: player = Player.byPublicName(args[0]) except: try: player = Player.byFantasyName(args[0]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown player %s.\\n"%args[0]) return try: user = User.byName(args[0]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0]) return if not IsUserSuperior(mob.player.publicName,user.name): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n") return pw = args[1] if len(pw) < 6: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Password must be at least 6 characters.\\n") return user.password = player.password = pw mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Player %s password set to %s\\n"%(player.publicName,pw)) def CmdGetPlayerPassword(mob,args): if CoreSettings.SINGLEPLAYER: return if len(args) != 1: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Please specify a player\\n") return try: user = User.byName(args[0]) except: mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0]) return if not IsUserSuperior(mob.player.publicName,user.name): mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n") return mob.player.sendGameText(RPG_MSG_GAME_GAINED,"Player %s password is: %s\\n"%(user.name,user.password)) def CmdTestAFX(mob, args): if not len(args): return effect = ' '.join(args) mob.testAFX(effect,mob.target) def CmdGetDimensions(mob, args): # If there is a target, get this ones dimensions. source = mob if mob.target: source = mob.target # Print out all relevant size information. mob.player.sendGameText(RPG_MSG_GAME_WHITE,"Relevant dimensions of %s are:\\n Mob Size - %f\\n Spawn Scale - %f\\n Current Scale - %f\\n Spawn Radius - %f\\n"%(source.name,source.size,source.spawn.scale,source.spawn.modifiedScale,source.spawn.radius)) def CmdCheckWealth(mob, args): # Check if there is a target available. if not mob.target: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "This command requires a target.\\n") return # Get a handle to the targets player. tplayer = mob.target.player # Query the targets wealth. ext = ('pp','gp','sp','cp','tp') worthLight = (tplayer.lightPlatinum,tplayer.lightGold,tplayer.lightSilver, \ tplayer.lightCopper,tplayer.lightTin) lightString = ', '.join('%i%s'%(w,ext[i]) \ for i,w in enumerate(worthLight) if w != 0) worthDarkness = (tplayer.darknessPlatinum,tplayer.darknessGold, \ tplayer.darknessSilver,tplayer.darknessCopper,tplayer.darknessTin) darknessString = ', '.join('%i%s'%(w,ext[i]) \ for i,w in enumerate(worthDarkness) if w != 0) worthMonster = (tplayer.monsterPlatinum,tplayer.monsterGold, \ tplayer.monsterSilver,tplayer.monsterCopper,tplayer.monsterTin) monsterString = ', '.join('%i%s'%(w,ext[i]) \ for i,w in enumerate(worthMonster) if w != 0) # And print the result to the immortal. mob.player.sendGameText(RPG_MSG_GAME_WHITE, \ "%s's wealth:\\n Light: %s\\n Darkness: %s\\n Monster: %s\\n"% \ (mob.target.name,lightString,darknessString,monsterString)) def CmdSetWealth(mob, args): # Check if there is a target available. if not mob.target: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "This command requires a target.\\n") return # Check if the two needed arguments are present. if len(args) != 2: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Number of supplied arguments incorrect.\\nUsage: /imm setwealth <realm = light/darkness/monster> <amount in tin>.\\n") return # Extract the desired amount of money to set the targets wealth to. try: tp,cp,sp,gp,pp = CollapseMoney(int(args[1])) except ValueError: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Can't extract amount of tin argument.\\nUsage: /imm setwealth <realm = light/darkness/monster> <amount in tin>.\\n") return # Get a handle to the targets player. tplayer = mob.target.player # Extract the realm and set wealth to the new value. realmText = args[0].upper() if realmText == 'LIGHT': tplayer.lightTin = tp tplayer.lightCopper = cp tplayer.lightSilver = sp tplayer.lightGold = gp tplayer.lightPlatinum = pp elif realmText == 'DARKNESS': tplayer.darknessTin = tp tplayer.darknessCopper = cp tplayer.darknessSilver = sp tplayer.darknessGold = gp tplayer.darknessPlatinum = pp elif realmText == 'MONSTER': tplayer.monsterTin = tp tplayer.monsterCopper = cp tplayer.monsterSilver = sp tplayer.monsterGold = gp tplayer.monsterPlatinum = pp else: mob.player.sendGameText(RPG_MSG_GAME_DENIED, \ "Can't extract realm argument.\\nUsage: /imm setwealth <realm = light/darkness/monster> <amount in tin>.\\n") return # Generate the money string. ext = ('pp','gp','sp','cp','tp') worth = (pp,gp,sp,cp,tp) moneyString = ', '.join('%i%s'%(w,ext[i]) for i,w in enumerate(worth) if w != 0) # Print result to the immortal and log. mob.player.sendGameText(RPG_MSG_GAME_WHITE, \ "%s's wealth in the %s realm has been set to: %s.\\nPlease inform the player once all adjustments have taken place.\\n"%(mob.target.name,args[0],moneyString)) print "Immortal %s has set %s's wealth in the %s realm to %s."% \ (mob.player.publicName,tplayer.fantasyName,args[0],moneyString) # Informing the player about the change is left up to the immortal. # Maybe several changes have to be made before the player should be informed. COMMANDS = {} COMMANDS['SPAWN'] = CmdSpawn COMMANDS['DESPAWN'] = CmdDespawn COMMANDS['SET'] = CmdSet COMMANDS['KILL'] = CmdKill COMMANDS['STASIS'] = CmdStasis COMMANDS['WORLDAGGRO'] = CmdWorldAggro COMMANDS['MYAGGRO'] = CmdMyAggro COMMANDS['SYSMSG'] = CmdSystemMsg COMMANDS['SCRIBE'] = CmdScribeMsg COMMANDS['RELOADCOMMANDS'] = CmdReloadCommands COMMANDS['RELOADMODULE'] = CmdReloadModule COMMANDS['GIVEMONSTER'] = CmdGiveMonster COMMANDS['GRANTMONSTER'] = CmdGrantMonster COMMANDS['DENYMONSTER'] = CmdDenyMonster COMMANDS['LISTMONSTERS'] = CmdListMonsters COMMANDS['GETPLAYERPASSWORD'] = CmdGetPlayerPassword COMMANDS['SETPLAYERPASSWORD'] = CmdSetPlayerPassword COMMANDS['TP'] = CmdTP COMMANDS['GIMME'] = CmdGimme COMMANDS['MODSTAT'] = CmdModStat COMMANDS['GRANTLEVEL'] = CmdGrantLevel COMMANDS['GRANT'] = CmdGrant COMMANDS['DENY'] = CmdDeny COMMANDS['TESTAFX'] = CmdTestAFX COMMANDS['GETDIMENSIONS'] = CmdGetDimensions COMMANDS['CHECKWEALTH'] = CmdCheckWealth COMMANDS['SETWEALTH'] = CmdSetWealth def DoImmortalCommand(player,cmd,args): mob = player.curChar.mob if type(args)!=list: args = [args] cmd = cmd.upper() if COMMANDS.has_key(cmd): COMMANDS[cmd](mob,args) else: print "Unknown Command",cmd
87294359d3c089c38ac1634f9454dd7fffc84699
943dca755b940493a8452223cfe5daa2fb4908eb
/abc114/c.py
b6b7ae6b28b7b8b6d6eff7f89534a53858c8d4db
[]
no_license
ymsk-sky/atcoder
5e34556582763b7095a5f3a7bae18cbe5b2696b2
36d7841b70b521bee853cdd6d670f8e283d83e8d
refs/heads/master
2023-08-20T01:34:16.323870
2023-08-13T04:49:12
2023-08-13T04:49:12
254,348,518
0
0
null
null
null
null
UTF-8
Python
false
false
178
py
n=int(input()) c=0 def a(i): if int(i)>n: return 0 r=1 if all(i.count(c)>0for c in '753') else 0 for c in '753': r+=a(i+c) return r print(a('0'))
105f6318e16efd787729c4524688009e64c39a6b
57023b55d9e136b8e2527e2c666b053f73bb6bc9
/get_url.py
9e8146918c444ca7b18e1f93400b9904f267d58e
[]
no_license
zengzhiyi/zhuanzhuan_pyspider
f98867742d9f7c760d7274528f85e91439964a48
4f27f410a75acec467de4fa73b759cb8a4d6351a
refs/heads/master
2021-01-13T10:55:28.659431
2016-10-29T11:34:56
2016-10-29T11:34:56
72,281,052
0
0
null
null
null
null
UTF-8
Python
false
false
1,389
py
from pyspider.libs.base_handler import * import pymysql class Handler(BaseHandler): crawl_config = { } # # def __init__(self): # self.db = pymysql.Connect('localhost', 'localhost', '123456', data=) start_url = 'http://www.zhuanzhuan.com/' grab_url = 'http://zhuanzhuan.58.com/detail/744782895816835076z.shtml' @every(minutes=24*60) def on_start(self): self.crawl(self.start_url, callback=self.channel_page) @config(age=10*24*60*60) def channel_page(self, response): for each in response.doc('a[href^="http://cd.58.com/"').items(): self.crawl(each.attr.href, callback=self.grab_index) @config(age=10*24*60*60) def grab_index(self, response): for each in response.doc('a[href^="http://zhuanzhuan.58.com/detail/"').items(): self.crawl(each.attr.href, callback=self.detail_page) @config(age=10*24*60*60) def detail_page(self, response): title = response.doc('h1').text() place = response.doc('div.palce_li > span > i').text() price = response.doc('div.price_li > span > i').text() quality = response.doc('div.info_massege.left > div.biaoqian_li').text() # self.add_question(title, content) return { 'title': title, 'place': place, 'price': price, 'quality': quality, }
f5b6ae2f4f91bf6d468eaade82e1f94055a1de32
6f21068b31084e81f38db304a51a2609d8af37cd
/1_Crash_Course_on_Python_Basics/history.py
520b3dd6c15086c052178edbb04320e38c777a0c
[]
no_license
vickyf/eurocontrol_datascience
374b889cac7b8d377caa78079fb57098e73bba0a
0a7c09002e3b5f22ad563b05a6b4afe4cb6791d7
refs/heads/master
2020-03-19T06:03:14.864839
2018-06-04T07:24:25
2018-06-04T07:24:25
135,986,678
1
0
null
null
null
null
UTF-8
Python
false
false
25
py
%history -n 1-5 -f log.py
40b7f46aecadddd429b5ea68491717f4c62a0d36
a4ecd7798cfa04676e892898774d1e5824b095fb
/distributed/utils.py
8e2136a99c71da5584d431ba41d5733e85db4cb9
[]
no_license
kevineriklee/distributed
c48ccb6086861c1adb2a5d7091d792a923387a27
b0b7c27e4ee6d7b5eebe6569fcf29b32418be440
refs/heads/master
2020-12-24T21:27:06.374245
2016-02-03T12:43:06
2016-02-03T12:43:06
null
0
0
null
null
null
null
UTF-8
Python
false
false
6,049
py
from __future__ import print_function, division, absolute_import from collections import Iterable from contextlib import contextmanager import logging import os import re import socket import sys import tempfile import traceback from dask import istask from toolz import memoize from tornado import gen logger = logging.getLogger(__name__) def funcname(func): """Get the name of a function.""" while hasattr(func, 'func'): func = func.func try: return func.__name__ except: return str(func) def get_ip(): return [(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1] @contextmanager def ignoring(*exceptions): try: yield except exceptions: pass @gen.coroutine def ignore_exceptions(coroutines, *exceptions): """ Process list of coroutines, ignoring certain exceptions >>> coroutines = [cor(...) for ...] # doctest: +SKIP >>> x = yield ignore_exceptions(coroutines, TypeError) # doctest: +SKIP """ wait_iterator = gen.WaitIterator(*coroutines) results = [] while not wait_iterator.done(): with ignoring(*exceptions): result = yield wait_iterator.next() results.append(result) raise gen.Return(results) @gen.coroutine def All(*args): """ Wait on many tasks at the same time Err once any of the tasks err. See https://github.com/tornadoweb/tornado/issues/1546 """ if len(args) == 1 and isinstance(args[0], Iterable): args = args[0] tasks = gen.WaitIterator(*args) results = [None for _ in args] while not tasks.done(): result = yield tasks.next() results[tasks.current_index] = result raise gen.Return(results) def sync(loop, func, *args, **kwargs): """ Run coroutine in loop running in separate thread """ if not loop._running: try: return loop.run_sync(lambda: func(*args, **kwargs)) except RuntimeError: # loop already running pass from threading import Event e = Event() result = [None] error = [False] @gen.coroutine def f(): try: result[0] = yield gen.maybe_future(func(*args, **kwargs)) except Exception as exc: logger.exception(exc) result[0] = exc error[0] = True finally: e.set() a = loop.add_callback(f) e.wait() if error[0]: raise result[0] else: return result[0] @contextmanager def tmp_text(filename, text): fn = os.path.join(tempfile.gettempdir(), filename) with open(fn, 'w') as f: f.write(text) try: yield fn finally: if os.path.exists(fn): os.remove(fn) def clear_queue(q): while not q.empty(): q.get_nowait() def is_kernel(): """ Determine if we're running within an IPython kernel >>> is_kernel() False """ # http://stackoverflow.com/questions/34091701/determine-if-were-in-an-ipython-notebook-session if 'IPython' not in sys.modules: # IPython hasn't been imported return False from IPython import get_ipython # check for `kernel` attribute on the IPython instance return getattr(get_ipython(), 'kernel', None) is not None def _deps(dsk, arg): """ Get dependencies from keys or tasks Helper function for get_dependencies. >>> inc = lambda x: x + 1 >>> add = lambda x, y: x + y >>> dsk = {'x': 1, 'y': 2} >>> _deps(dsk, 'x') ['x'] >>> _deps(dsk, (add, 'x', 1)) ['x'] >>> _deps(dsk, ['x', 'y']) ['x', 'y'] >>> _deps(dsk, {'name': 'x'}) ['x'] >>> _deps(dsk, (add, 'x', (inc, 'y'))) # doctest: +SKIP ['x', 'y'] """ if istask(arg): result = [] for a in arg[1:]: result.extend(_deps(dsk, a)) return result if isinstance(arg, list): return sum([_deps(dsk, a) for a in arg], []) if isinstance(arg, dict): return sum([_deps(dsk, v) for v in arg.values()], []) try: if arg not in dsk: return [] except TypeError: # not hashable return [] return [arg] def key_split(s): """ >>> key_split('x-1') 'x' >>> key_split('x-1-2-3') 'x' >>> key_split(('x-2', 1)) 'x' >>> key_split(None) 'Other' """ if isinstance(s, tuple): return key_split(s[0]) try: return s.split('-', 1)[0] except: return 'Other' @contextmanager def log_errors(): try: yield except gen.Return: raise except Exception as e: logger.exception(e) raise @memoize def ensure_ip(hostname): """ Ensure that address is an IP address >>> ensure_ip('localhost') '127.0.0.1' >>> ensure_ip('123.123.123.123') # pass through IP addresses '123.123.123.123' """ if re.match('\d+\.\d+\.\d+\.\d+', hostname): # is IP return hostname else: return socket.gethostbyname(hostname) def get_traceback(): exc_type, exc_value, exc_traceback = sys.exc_info() tb = traceback.format_tb(exc_traceback) tb = [line[:10000] for line in tb] return tb def truncate_exception(e, n=10000): """ Truncate exception to be about a certain length """ if len(str(e)) > n: try: return type(e)("Long error message", str(e)[:n]) except: return Exception("Long error message", type(e), str(e)[:n]) else: return e import logging logging.basicConfig(format='%(name)s - %(levelname)s - %(message)s', level=logging.INFO) # http://stackoverflow.com/questions/21234772/python-tornado-disable-logging-to-stderr stream = logging.StreamHandler(sys.stderr) stream.setLevel(logging.CRITICAL) logging.getLogger('tornado').addHandler(stream) logging.getLogger('tornado').propagate = False
7fd3ef46896d70511ef8915b44227ec5c7aea8e2
167c6226bc77c5daaedab007dfdad4377f588ef4
/python/ql/test/query-tests/Expressions/general/compare.py
141b5e6a0286eb0877da38d45efaf28b0cf9277e
[ "MIT", "LicenseRef-scancode-python-cwi", "LicenseRef-scancode-other-copyleft", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Python-2.0" ]
permissive
github/codeql
1eebb449a34f774db9e881b52cb8f7a1b1a53612
d109637e2d7ab3b819812eb960c05cb31d9d2168
refs/heads/main
2023-08-20T11:32:39.162059
2023-08-18T14:33:32
2023-08-18T14:33:32
143,040,428
5,987
1,363
MIT
2023-09-14T19:36:50
2018-07-31T16:35:51
CodeQL
UTF-8
Python
false
false
327
py
#OK a = b = 1 a == b a.x == b.x #Same variables a == a a.x == a.x #Compare constants 1 == 1 1 == 2 #Maybe missing self class X(object): def __init__(self, x): self.x = x def missing_self(self, x): if x == x: print ("Yes") #Compare constants in assert -- ok assert(1 == 1)
ca8a8ac861ee58b34eefc98e9160ef198072392a
145439ad19a9c3c9d40f805ccf9ff5794ca28d62
/senseplot_es.1.py
541013ab8d2377881041a491815ab1ede5137190
[]
no_license
emawind84/sensehat-discotest
f5b122f004eee4e74ba63322aecb723d7a191583
87a7aff71969ef9beab0120eaddc132e0d16b561
refs/heads/master
2020-05-21T04:27:43.090658
2017-10-10T14:30:52
2017-10-10T14:30:52
46,617,896
0
0
null
null
null
null
UTF-8
Python
false
false
2,411
py
#!/usr/bin/env python import csv import sys import logging import argparse import matplotlib import requests import json import dateutil.parser matplotlib.use("Agg") import matplotlib.dates as md import matplotlib.pyplot as plt logging.basicConfig(format='%(asctime)s - %(levelname)s: %(message)s') _logger = logging.getLogger(__name__) _logger.setLevel(logging.DEBUG) x = [] y = [] plotdata = 'temp_h' PLOT_SAVE_PATH = '/home/pi/sensehat-datalog/plot' CSV_MAP = {'temp_h': 0, 'temp_p': 1, 'humidity': 2, 'pressure': 3, 'pitch': 4, 'roll': 5, 'yaw': 6, 'mag_x': 7, 'mag_y': 8, 'mag_z': 9, 'acc_x': 10, 'acc_y': 11, 'acc_z': 12, 'gyro_x': 13, 'gyro_y': 14, 'gyro_z': 15, 'timestamp': 16} def main(): s = requests.session() query = { "query": { "range": { "timestamp": { "gte": "now-4d/d", "lte": "now/d" } } }, "size": 2000, "sort": [{ "timestamp": { "order": "asc" } }] } result = s.get('http://localhost:9200/sense/stats/_search', data=json.dumps(query)) jresult = result.json() datalist = jresult['hits']['hits'] _t = len(datalist) // 40 _i = -1 for rowdata in datalist: _i += 1 if _i % _t != 0: continue rowdata = rowdata['_source'] _logger.debug(rowdata) x.append(dateutil.parser.parse(rowdata['timestamp'])) y.append(rowdata[plotdata]) plt.plot(x, y) plt.gca().xaxis.set_major_formatter(md.DateFormatter("%Y-%m-%d %H:%M")) plt.gca().get_yaxis().get_major_formatter().set_useOffset(False) plt.axhline(0, color='black', lw=2) plt.xlabel("timestamp") plt.ylabel(plotdata) plt.gcf().autofmt_xdate() #plt.savefig(PLOT_SAVE_PATH + "/senselog.png") plt.savefig(PLOT_SAVE_PATH + "/senselog.png", bbox_inches = "tight") plt.clf() if __name__ == '__main__': if len(sys.argv) > 1 and sys.argv[1] in CSV_MAP: plotdata = sys.argv[1] ''' parser = argparse.ArgumentParser() parser.add_argument('--debug', '-d', action='store_true', dest='debug', help='More logging on console') _args = parser.parse_args() if _args.debug: _logger.setLevel(logging.DEBUG) ''' main()
640b1981de612c8310929ae47e05cb72c6ab8ffd
243d0543f8d38f91954616c014456122292a1a3c
/CS1/0340_lists/challenge1.py
34564036d9d41147eeed4c7ecb4f996fdaf78e98
[ "MIT" ]
permissive
roni-kemp/python_programming_curricula
758be921953d82d97c816d4768fbcf400649e969
eda4432dab97178b4a5712b160f5b1da74c068cb
refs/heads/master
2023-03-23T13:46:42.186939
2020-07-15T17:03:34
2020-07-15T17:03:34
null
0
0
null
null
null
null
UTF-8
Python
false
false
850
py
#For 35 points, answer the following questions. '''1. Write a function that takes a single number named x and returns a list of all the numbers from x to 0 in descending order. For example, if 5 is passed to the function, then the function should return a list that equals [5,4,3,2,1,0].''' '''2. The following program contains a function that searches for the smallest value in a list and returns the index of that value. The program also includes an example call to the function to test it out. Unscramble the code to make it work. Include proper indentation.''' index = 0 print('working correctly.') smallest = 2**30 #Start very large smallest=numbers[i] index = i def getSmallest(numbers): if result == 3: return index my_list = [-45,2,78,-100,331,-4] if numbers[i] < smallest: result = getSmallest(my_list) for i in range(len(numbers)):
65d7ff9326e1b49582142df46e4ec8e58c0ea585
32fdc94d1b8d98085db5d1e8caae4161d3e70667
/3rd_party/python3.7/lib/python3.7/site-packages/aliyunsdkcore/acs_exception/exceptions.py
c5a3152d161d237e31cef9651573890127244bbf
[ "Python-2.0" ]
permissive
czfdlut/ticket_proxy
fa0f1924a86babfa7ce96cf97e929f7bf78643b7
0d7c19448741bc9030484a97c1b8f118098213ad
refs/heads/master
2022-12-23T05:25:58.207123
2019-11-20T03:58:31
2019-11-20T03:58:31
174,579,562
1
3
null
2022-12-18T01:18:07
2019-03-08T17:22:48
Python
UTF-8
Python
false
false
2,808
py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # coding=utf-8 """ SDK exception module. """ from aliyunsdkcore.acs_exception import error_type class ClientException(Exception): """client exception""" def __init__(self, code, msg): """ :param code: error code :param message: error message :return: """ Exception.__init__(self) self.__error_type = error_type.ERROR_TYPE_CLIENT self.message = msg self.error_code = code def __str__(self): return "%s %s" % ( self.error_code, self.message, ) def set_error_code(self, code): self.error_code = code def set_error_msg(self, msg): self.message = msg def get_error_type(self): return self.__error_type def get_error_code(self): return self.error_code def get_error_msg(self): return self.message class ServerException(Exception): """ server exception """ def __init__(self, code, msg, http_status=None, request_id=None): Exception.__init__(self) self.error_code = code self.message = msg self.__error_type = error_type.ERROR_TYPE_SERVER self.http_status = http_status self.request_id = request_id def __str__(self): return "HTTP Status: %s Error:%s %s RequestID: %s" % ( str(self.http_status), self.error_code, self.message, self.request_id ) def set_error_code(self, code): self.error_code = code def set_error_msg(self, msg): self.message = msg def get_error_type(self): return self.__error_type def get_error_code(self): return self.error_code def get_error_msg(self): return self.message def get_http_status(self): return self.http_status def get_request_id(self): return self.request_id
2e365c5f23fc5bd007dc780fa71c4e5598e856d1
0529196c4d0f8ac25afa8d657413d4fc1e6dd241
/runnie0427/01919/1919.py2.py
1a8557553de03d0c7ca6ef7a57f3254ee8eb8954
[]
no_license
riyuna/boj
af9e1054737816ec64cbef5df4927c749808d04e
06420dd38d4ac8e7faa9e26172b30c9a3d4e7f91
refs/heads/master
2023-03-17T17:47:37.198570
2021-03-09T06:11:41
2021-03-09T06:11:41
345,656,935
0
0
null
null
null
null
UTF-8
Python
false
false
17,370
py
<!DOCTYPE html> <html lang="ko"> <head> <title>Baekjoon Online Judge</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta charset="utf-8"><meta name="author" content="스타트링크 (Startlink)"><meta name="keywords" content="ACM-ICPC, ICPC, 프로그래밍, 온라인 저지, 정보올림피아드, 코딩, 알고리즘, 대회, 올림피아드, 자료구조"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta property="og:type" content="website"><meta property="og:image" content="http://onlinejudgeimages.s3-ap-northeast-1.amazonaws.com/images/boj-og-1200.png"><meta property="og:site_name" content="Baekjoon Online Judge"><meta name="format-detection" content = "telephone=no"><meta name="msapplication-config" content="none"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="manifest" href="/site.webmanifest"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#0076c0"><meta name="msapplication-TileColor" content="#00aba9"><meta name="theme-color" content="#ffffff"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css"><link rel="stylesheet" href="https://ddo7jzca0m2vt.cloudfront.net/unify/css/style.css?version=20210107"><link href="https://fonts.googleapis.com/css?family=Noto+Sans+KR:400,700|Open+Sans:400,400i,700,700i|Source+Code+Pro&amp;subset=korean" rel="stylesheet"><link rel="stylesheet" href="https://ddo7jzca0m2vt.cloudfront.net/css/connect.css?version=20210107"><link rel="stylesheet" href="https://ddo7jzca0m2vt.cloudfront.net/css/result.css?version=20210107"><link rel="stylesheet" href="https://ddo7jzca0m2vt.cloudfront.net/unify/css/custom.css?version=20210107"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css"><link rel="stylesheet" href="https://ddo7jzca0m2vt.cloudfront.net/unify/css/theme-colors/blue.css?version=20210107"><link rel="stylesheet" href="https://ddo7jzca0m2vt.cloudfront.net/css/pace.css"> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-10874097-3"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-10874097-3'); </script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.css" /><meta name="username" content=""> <link rel="stylesheet" href="https://ddo7jzca0m2vt.cloudfront.net/unify/css/pages/page_404_error.css"> </head> <body> <div class="wrapper"> <div class="header no-print"><div class="topbar"><div class="container"><ul class="loginbar pull-right"><li><a href = "/register">회원가입</a></li><li class="topbar-devider"></li><li><a href = "/login?next=%2Fsource%2Fdownload%2F5345371">로그인</a></li></ul></div></div><div class="navbar navbar-default mega-menu" role="navigation"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse"><span class="sr-only">Toggle navigation</span><span class="fa fa-bars"></span></button><a class="navbar-brand" href="/"><img id="logo-header" src="https://d2gd6pc034wcta.cloudfront.net/images/[email protected]" alt="Logo" data-retina></a></div><div class="collapse navbar-collapse navbar-responsive-collapse"><ul class="nav navbar-nav"><li class="dropdown mega-menu-fullwidth "><a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">문제</a><ul class="dropdown-menu"><li><div class="mega-menu-content"><div class="container"><div class="row equal-height"><div class="col-md-3 equal-height-in"><ul class="list-unstyled equal-height-list"><li><h3>문제</h3></li><li><a href = "/problemset">전체 문제</a></li><li><a href = "/category">문제 출처</a></li><li><a href = "/step">단계별로 풀어보기</a></li><li><a href = "/problem/tags">알고리즘 분류</a></li><li><a href = "/problem/added">새로 추가된 문제</a></li><li><a href = "/problem/added/1">새로 추가된 영어 문제</a></li><li><a href = "/problem/ranking">문제 순위</a></li></ul></div><div class="col-md-3 equal-height-in"><ul class="list-unstyled equal-height-list"><li><h3>문제</h3></li><li><a href="/problem/only">푼 사람이 한 명인 문제</a></li><li><a href="/problem/nobody">아무도 못 푼 문제</a></li><li><a href="/problem/recent/submit">최근 제출된 문제</a></li><li><a href="/problem/recent/accepted">최근 풀린 문제</a></li><li><a href="/problem/random">랜덤</a></li></ul></div><div class="col-md-3 equal-height-in"><ul class="list-unstyled equal-height-list"><li><h3>출처</h3></li><li><a href = "/category/1">ICPC</a></li><li><a href = "/category/2">Olympiad</a></li><li><a href = "/category/55">한국정보올림피아드</a></li><li><a href = "/category/57">한국정보올림피아드시․도지역본선</a></li><li><a href = "/category/318">전국 대학생 프로그래밍 대회 동아리 연합</a></li><li><a href = "/category/5">대학교 대회</a></li><li><a href = "/category/428">카카오 코드 페스티벌</a></li><li><a href = "/category/215">Coder's High</a></li></ul></div><div class="col-md-3 equal-height-in"><ul class="list-unstyled equal-height-list"><li><h3>ICPC</h3></li><li><a href = "/category/7">Regionals</a></li><li><a href = "/category/4">World Finals</a></li><li><a href = "/category/211">Korea Regional</a></li><li><a href = "/category/34">Africa and the Middle East Regionals</a></li><li><a href = "/category/10">Europe Regionals</a></li><li><a href = "/category/103">Latin America Regionals</a></li><li><a href = "/category/8">North America Regionals</a></li><li><a href = "/category/92">South Pacific Regionals</a></li></ul></div></div></div></div></li></ul></li><li><a href = "/workbook/top">문제집</a></li><li><a href = "/contest/official/list">대회<span class='badge badge-red rounded-2x'>2</span></a></li><li><a href = "/status">채점 현황</a></li><li><a href = "/ranklist">랭킹</a></li><li><a href = "/board/list/all">게시판</a></li><li><a href = "/group/list/all">그룹</a></li><li><a href = "/blog/list">블로그</a></li><li><a href = "/lectures">강의</a></li><li><a href = "/search"><i class="fa fa-search search-btn"></i></a></li></ul></div></div></div></div><form action="/logout" method="post" id="logout_form"><input type='hidden' value='%2Fsource%2Fdownload%2F5345371' name="next"></form> <div class="container content"> <div class="col-md-8 col-md-offset-2"> <div class="error-v1"> <span class="error-v1-title">404</span> <span>Not found</span> <div class="margin-bottom-20"></div> </div> <div class="text-center"> <span style="font-size:18px;">강의 슬라이드의 첨부 소스 코드가 404 에러가 뜨는 경우에는 링크를 복사/붙여넣기 해주세요.</span> </div> <div class="margin-bottom-40"></div> </div> </div> <div class="footer-v3 no-print"><div class="footer"><div class="container"><div class="row"><div class="col-sm-3 md-margin-bottom-40"><div class="thumb-headline"><h2>Baekjoon Online Judge</h2></div><ul class="list-unstyled simple-list margin-bottom-10"><li><a href="/about">소개</a></li><li><a href="/news">뉴스</a></li><li><a href="/live">생중계</a></li><li><a href="/poll">설문조사</a></li><li><a href="/blog">블로그</a></li><li><a href="/calendar">캘린더</a></li><li><a href="/donate">기부하기</a></li><li><a href="https://github.com/Startlink/BOJ-Feature-Request">기능 추가 요청</a></li><li><a href="https://github.com/Startlink/BOJ-spj">스페셜 저지 제작</a></li><li><a href="/labs">실험실</a></li></ul><div class="thumb-headline"><h2>채점 현황</h2></div><ul class="list-unstyled simple-list"><li><a href="/status">채점 현황</a></li></ul></div><div class="col-sm-3 md-margin-bottom-40"><div class="thumb-headline"><h2>문제</h2></div><ul class="list-unstyled simple-list margin-bottom-10"><li><a href="/problemset">문제</a></li><li><a href="/step">단계별로 풀어보기</a></li><li><a href="/problem/tags">알고리즘 분류</a></li><li><a href="/problem/added">새로 추가된 문제</a></li><li><a href="/problem/added/1">새로 추가된 영어 문제</a></li><li><a href="/problem/ranking">문제 순위</a></li><li><a href="/problem/recent/submit">최근 제출된 문제</a></li><li><a href="/problem/recent/accepted">최근 풀린 문제</a></li><li><a href="/change">재채점 및 문제 수정</a></li></ul><div class="thumb-headline"><h2>유저 대회 / 고등학교 대회</h2></div><ul class="list-inline simple-list margin-bottom"><li><a href="/category/353">FunctionCup</a></li><li><a href="/category/319">kriiicon</a></li><li><a href="/category/420">구데기컵</a></li><li><a href="/category/358">꼬마컵</a></li><li><a href="/category/421">네블컵</a></li><li><a href="/category/413">소프트콘</a></li><li><a href="/category/416">웰노운컵</a></li><li><a href="/category/detail/1743">HYEA Cup</a></li><li><a href="/category/364">경기과학고등학교</a></li><li><a href="/category/417">대구과학고등학교</a></li><li><a href="/category/429">부산일과학고</a></li><li><a href="/category/435">서울과학고등학교</a></li><li><a href="/category/394">선린인터넷고등학교</a></li></ul></div><div class="col-sm-3 md-margin-bottom-40"><div class="thumb-headline"><h2>출처</h2></div><ul class="list-unstyled simple-list margin-bottom-10"><li><a href="/category/1">ICPC</a></li><li><a href="/category/211">ICPC Korea Regional</a></li><li><a href="/category/2">Olympiad</a></li><li><a href="/category/55">한국정보올림피아드</a></li><li><a href="/category/57">한국정보올림피아드시․도지역본선</a></li><li><a href="/category/318">전국 대학생 프로그래밍 대회 동아리 연합</a></li><li><a href="/category/5">대학교 대회</a></li><li><a href="/category/428">카카오 코드 페스티벌</a></li><li><a href="/category/215">Coder's High</a></li></ul><div class="thumb-headline"><h2>대학교 대회</h2></div><ul class="list-inline simple-list"><li><a href="/category/320">KAIST</a></li><li><a href="/category/426">POSTECH</a></li><li><a href="/category/341">고려대학교</a></li><li><a href="/category/434">광주과학기술원</a></li><li><a href="/category/361">국민대학교</a></li><li><a href="/category/83">서강대학교</a></li><li><a href="/category/354">서울대학교</a></li><li><a href="/category/352">숭실대학교</a></li><li><a href="/category/408">아주대학교</a></li><li><a href="/category/334">연세대학교</a></li><li><a href="/category/336">인하대학교</a></li><li><a href="/category/347">전북대학교</a></li><li><a href="/category/400">중앙대학교</a></li><li><a href="/category/402">충남대학교</a></li><li><a href="/category/418">한양대 ERICA</a></li><li><a href="/category/363">홍익대학교</a></li><li><a href="/category/409">경인지역 6개대학 연합 프로그래밍 경시대회</a></li></ul></div><div class="col-sm-3 md-margin-bottom-40"><div class="thumb-headline"><h2>도움말</h2></div><ul class="list-unstyled simple-list margin-bottom-10"><li><a href="/help/judge">채점 도움말 및 채점 환경</a></li><li><a href="/help/rejudge">재채점 안내</a></li><li><a href="/help/rte">런타임 에러 도움말</a></li><li><a href="/help/problem">문제 스타일 안내</a></li><li><a href="/help/language">컴파일 또는 실행 옵션, 컴파일러 버전, 언어 도움말</a></li><li><a href="/help/workbook">문제집 도움말</a></li><li><a href="/help/contest">대회 개최 안내</a></li><li><a href="/help/problem-add">문제 출제 안내</a></li><li><a href="/help/rule">이용 규칙</a></li><li><a href="/help/stat">통계 도움말</a></li><li><a href="/help/question">질문 도움말</a></li><li><a href="/help/faq">자주묻는 질문</a></li><li><a href="/help/lecture">강의 안내</a></li><li><a href="/help/short">짧은 주소 안내</a></li><li><a href="/help/ad">광고 안내</a></li></ul></div></div></div><div class="copyright"><div class="container"><div class="row"><div class="col-md-9 col-sm-12"><p>&copy; 2021 All Rights Reserved. <a href="https://startlink.io">주식회사 스타트링크</a>&nbsp;|&nbsp;<a href="/terms">서비스 약관</a>&nbsp;|&nbsp;<a href="/privacy">개인정보 보호</a>&nbsp;|&nbsp;<a href="/terms/payment">결제 이용 약관</a>&nbsp;|&nbsp;<a href="https://boj.startlink.help/hc/ko">도움말</a>&nbsp;|&nbsp;<a href="http://startl.ink/2pmlJaY">광고 문의</a>&nbsp;|&nbsp;<a href="https://github.com/Startlink/update-note/blob/master/boj.md">업데이트 노트</a>&nbsp;|&nbsp;<a href="https://github.com/Startlink/update-note/blob/master/boj-issues.md">이슈</a>&nbsp;|&nbsp;<a href="https://github.com/Startlink/update-note/blob/master/boj-todo.md">TODO</a></p></div><div class="col-md-3 col-sm-12"><ul class="social-icons pull-right"><li><a href="https://www.facebook.com/onlinejudge" data-original-title="Facebook" class="rounded-x social_facebook"></a></li><li><a href="https://startlink.blog" data-original-title="Wordpress" class="rounded-x social_wordpress"></a></li></ul></div></div><div class="row"><div class="col-sm-12"><a href="https://startlink.io" class="hidden-xs"><img src="https://d2gd6pc034wcta.cloudfront.net/logo/startlink-logo-white-only.png" class="pull-right startlink-logo"></a><ul class="list-unstyled simple-list"><li>사업자 등록 번호: 541-88-00682</li><li>대표자명: 최백준</li><li>주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호</li><li>전화번호: 02-521-0487 (이메일로 연락 주세요)</li><li>이메일: <a href="mailto:[email protected]">[email protected]</a></li><li>통신판매신고번호: 제 2017-서울서초-2193 호</li></ul></div><div class="col-xs-9"><p id="no-acm-icpc"></p></div><div class="col-xs-3"></div></div></div></div></div> </div> <div id="fb-root"></div><script> window.fbAsyncInit = function() { FB.init({ appId : '322026491226049', cookie : true, xfbml : true, version : 'v2.8' }); }; (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/ko_KR/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <script> !function(f,b,e,v,n,t,s){ if(f.fbq)return;n=f.fbq=function(){ n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments) };if(!f._fbq)f._fbq=n; n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s) }(window, document,'script','//connect.facebook.net/en_US/fbevents.js'); fbq('init', '1670563073163149'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1670563073163149&ev=PageView&noscript=1"/></noscript><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.0.1/jquery-migrate.min.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.21.0/moment.min.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.21.0/locale/ko.js"></script><script type="text/javascript" src="https://ddo7jzca0m2vt.cloudfront.net/unify/js/app.min.js?version=20210107"></script><script type="text/javascript">jQuery(document).ready(function() {App.init(0);});</script><!--[if lt IE 9]><script src="https://ddo7jzca0m2vt.cloudfront.net/unify/plugins/respond.js"></script><script src="https://ddo7jzca0m2vt.cloudfront.net/unify/plugins/html5shiv.js"></script><script src="https://ddo7jzca0m2vt.cloudfront.net/unify/js/plugins/placeholder-IE-fixes.js"></script><![endif]--><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script><script src="https://js.pusher.com/4.2/pusher.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js"></script> <script> window.MathJax = { tex: { inlineMath: [ ['$', '$'], ['\\(', '\\)'] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, tags: "ams", autoload: { color: [], colorv2: ['color'] }, packages: { '[+]': ['noerrors'] } }, options: { ignoreHtmlClass: "no-mathjax|redactor-editor", processHtmlClass: 'mathjax', enableMenu: false }, chtml: { scale: 0.9 }, loader: { load: ['input/tex', 'output/chtml', '[tex]/noerrors'], } }; </script><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> </body> </html>
462c1c5536931ffd74fe6adb0021f49f47a22917
c4c4a825e361d15aa60603e52195bbeea2b31ad8
/src/generator.py
ae550a23acdbb4d5b1895b970705ac88b8b828f5
[]
no_license
brianyu28/accompaniment
cabb55cd26f6e0525dc60df7a493430860b702e8
a2dd062631d7316bda38823ca23ea6fba33aafb4
refs/heads/master
2021-08-24T08:02:45.675990
2017-12-08T19:28:06
2017-12-08T19:28:06
109,048,094
0
1
null
null
null
null
UTF-8
Python
false
false
2,787
py
import os import uuid from contextlib import redirect_stdout from midi2audio import FluidSynth from midiutil import MIDIFile from pydub import AudioSegment def generate(filename, sequence, configuration, mls, volumes): """ Generates merged audio file. """ print("Generating accompaniment audio...") # Maintain dictionary of which notes of configuration to play. notes = {0: None} prev = None for i, note_number in enumerate(mls): # Don't play notes we've already played, or that aren't meant to be. if note_number in notes or \ str(note_number) not in configuration["accompaniment"]: continue # Add note to dictionary. time = sequence["notes"][i - 1][0] velocity = volumes[configuration["piece"][note_number - 1]["vel"]] pitches = configuration["accompaniment"][str(note_number)] notes[note_number] = { "time": time, "velocity": velocity, "pitches": pitches } # Set duration of the prior note. if prev is not None: notes[prev]["duration"] = time - notes[prev]["time"] prev = note_number # Set duration of the final note. notes[prev]["duration"] = sequence["duration"] - notes[prev]["time"] # Configure MIDI file. midifile = MIDIFile(1, adjust_origin=True) track, channel = 0, 0 midifile.addTempo(0, 0, 60) # Add notes to MIDI file. for i in range(1, prev + 1): if i not in notes: continue for pitch in notes[i]["pitches"]: midifile.addNote(track, channel, pitch, notes[i]["time"], notes[i]["duration"], notes[i]["velocity"]) # Create temporary MIDI file. identifier = str(uuid.uuid4()) with open("{}.mid".format(identifier), "wb") as outfile: midifile.writeFile(outfile) # Convert temporary MIDI file to teporary WAV file. FluidSynth().midi_to_audio("{}.mid".format(identifier), "{}.wav".format(identifier)) # Combine accompaniment audio with soloist audio. merge(filename, "{}.wav".format(identifier), "output.wav") # Clean up temporary files. os.remove("{}.mid".format(identifier)) os.remove("{}.wav".format(identifier)) def merge(file1, file2, outfile): """ Overlays two .wav files and converts to a single .wav output. """ print("Merging recording with accompaniment...") # Take .wav file inputs and adjust volume. audio1 = AudioSegment.from_file(file1) audio1 = audio1 - 10 audio2 = AudioSegment.from_file(file2) audio2 = audio2 + 10 # Overlay audio and export to file. overlayed = audio1.overlay(audio2) overlayed.export(outfile, format="wav")
d81fb844ab079e8c36d9a292a808fafb58ad814e
bde2d795de28f9bbfc414752cc49d8ec3e0f00fd
/syntext/test/test_dynamical_load_classes.py
3f642821f1fa935e8ad25d61bfc44709cb6d2ac1
[]
no_license
lem89757/syntext
b934cd9339fb938db1c0bb9228852cec3d6e5a03
9d3e2e9bb68b325122072d8378217623d3804641
refs/heads/master
2022-12-01T20:06:25.328315
2020-08-18T04:38:06
2020-08-18T04:38:06
294,897,996
1
0
null
2020-09-12T07:57:33
2020-09-12T07:57:32
null
UTF-8
Python
false
false
370
py
from syntext.utils.utils import dynamic_load from syntext.text.generator import TextGenerator module_name = "syntext.text.generator" modules = dynamic_load(module_name, TextGenerator) for module in modules: print(module) # RUN: python -m syntext.test.test_dynamical_load_classes def test_fake_print(*arg): print(*arg) test_fake_print("%s is string" % "xxx")
1296b16346d574fdf337b865e6e24fa10eae71f8
f576f0ea3725d54bd2551883901b25b863fe6688
/sdk/databoxedge/azure-mgmt-databoxedge/azure/mgmt/databoxedge/v2020_05_01_preview/aio/operations/_bandwidth_schedules_operations.py
6e6e33810965c92218ce0476a26194e3548f85e4
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
Azure/azure-sdk-for-python
02e3838e53a33d8ba27e9bcc22bd84e790e4ca7c
c2ca191e736bb06bfbbbc9493e8325763ba990bb
refs/heads/main
2023-09-06T09:30:13.135012
2023-09-06T01:08:06
2023-09-06T01:08:06
4,127,088
4,046
2,755
MIT
2023-09-14T21:48:49
2012-04-24T16:46:12
Python
UTF-8
Python
false
false
26,515
py
# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._bandwidth_schedules_operations import ( build_create_or_update_request, build_delete_request, build_get_request, build_list_by_data_box_edge_device_request, ) if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports else: from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BandwidthSchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.databoxedge.v2020_05_01_preview.aio.DataBoxEdgeManagementClient`'s :attr:`bandwidth_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_data_box_edge_device( self, device_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.BandwidthSchedule"]: """Gets all the bandwidth schedules for a Data Box Edge/Data Box Gateway device. :param device_name: The device name. Required. :type device_name: str :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BandwidthSchedule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: Literal["2020-05-01-preview"] = kwargs.pop( "api_version", _params.pop("api-version", "2020-05-01-preview") ) cls: ClsType[_models.BandwidthSchedulesList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_data_box_edge_device_request( device_name=device_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_data_box_edge_device.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("BandwidthSchedulesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_by_data_box_edge_device.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules" } @distributed_trace_async async def get( self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> _models.BandwidthSchedule: """Gets the properties of the specified bandwidth schedule. :param device_name: The device name. Required. :type device_name: str :param name: The bandwidth schedule name. Required. :type name: str :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BandwidthSchedule or the result of cls(response) :rtype: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: Literal["2020-05-01-preview"] = kwargs.pop( "api_version", _params.pop("api-version", "2020-05-01-preview") ) cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) request = build_get_request( device_name=device_name, name=name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" } async def _create_or_update_initial( self, device_name: str, name: str, resource_group_name: str, parameters: Union[_models.BandwidthSchedule, IO], **kwargs: Any ) -> Optional[_models.BandwidthSchedule]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: Literal["2020-05-01-preview"] = kwargs.pop( "api_version", _params.pop("api-version", "2020-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.BandwidthSchedule]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IO, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "BandwidthSchedule") request = build_create_or_update_request( device_name=device_name, name=name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized _create_or_update_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" } @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, parameters: _models.BandwidthSchedule, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. :param device_name: The device name. Required. :type device_name: str :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. :param device_name: The device name. Required. :type device_name: str :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param parameters: The bandwidth schedule to be added or updated. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def begin_create_or_update( self, device_name: str, name: str, resource_group_name: str, parameters: Union[_models.BandwidthSchedule, IO], **kwargs: Any ) -> AsyncLROPoller[_models.BandwidthSchedule]: """Creates or updates a bandwidth schedule. :param device_name: The device name. Required. :type device_name: str :param name: The bandwidth schedule name which needs to be added/updated. Required. :type name: str :param resource_group_name: The resource group name. Required. :type resource_group_name: str :param parameters: The bandwidth schedule to be added or updated. Is either a BandwidthSchedule type or a IO type. Required. :type parameters: ~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BandwidthSchedule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.databoxedge.v2020_05_01_preview.models.BandwidthSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: Literal["2020-05-01-preview"] = kwargs.pop( "api_version", _params.pop("api-version", "2020-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BandwidthSchedule] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._create_or_update_initial( device_name=device_name, name=name, resource_group_name=resource_group_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("BandwidthSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: Literal["2020-05-01-preview"] = kwargs.pop( "api_version", _params.pop("api-version", "2020-05-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( device_name=device_name, name=name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" } @distributed_trace_async async def begin_delete( self, device_name: str, name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified bandwidth schedule. :param device_name: The device name. Required. :type device_name: str :param name: The bandwidth schedule name. Required. :type name: str :param resource_group_name: The resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: Literal["2020-05-01-preview"] = kwargs.pop( "api_version", _params.pop("api-version", "2020-05-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore device_name=device_name, name=name, resource_group_name=resource_group_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/{deviceName}/bandwidthSchedules/{name}" }
36cf57e1c202ca5edbc650d557e7ec4d3e91c89f
c426a94f2e48a464a19076e4bea5d9553f11a979
/src/collective/cover/tests/test_refresh_behavior.py
9a99f022cfdeafc14722093a42b8a39cb6dacf3a
[]
no_license
Mubra/collective.cover
36932c5ed3df295a9079db5e2786765370b68fcd
410254dc73093181637e7982c25d18f63936fcb1
refs/heads/master
2020-07-31T18:49:26.617963
2019-10-01T15:18:52
2019-10-01T15:18:52
210,716,653
1
0
null
2019-10-01T15:18:54
2019-09-24T23:43:28
Python
UTF-8
Python
false
false
2,325
py
# -*- coding: utf-8 -*- from collective.cover.behaviors.interfaces import IRefresh from collective.cover.interfaces import ICoverLayer from collective.cover.testing import INTEGRATION_TESTING from plone import api from plone.behavior.interfaces import IBehavior from plone.dexterity.interfaces import IDexterityFTI from plone.dexterity.schema import SchemaInvalidatedEvent from zope.component import queryUtility from zope.event import notify from zope.interface import alsoProvides import unittest class RefreshBehaviorTestCase(unittest.TestCase): layer = INTEGRATION_TESTING def _enable_refresh_behavior(self): fti = queryUtility(IDexterityFTI, name='collective.cover.content') behaviors = list(fti.behaviors) behaviors.append(IRefresh.__identifier__) fti.behaviors = tuple(behaviors) # invalidate schema cache notify(SchemaInvalidatedEvent('collective.cover.content')) def _disable_refresh_behavior(self): fti = queryUtility(IDexterityFTI, name='collective.cover.content') behaviors = list(fti.behaviors) behaviors.remove(IRefresh.__identifier__) fti.behaviors = tuple(behaviors) # invalidate schema cache notify(SchemaInvalidatedEvent('collective.cover.content')) def setUp(self): self.portal = self.layer['portal'] self.request = self.layer['request'] alsoProvides(self.request, ICoverLayer) with api.env.adopt_roles(['Manager']): self.cover = api.content.create( self.portal, 'collective.cover.content', 'c1') def test_refresh_registration(self): registration = queryUtility(IBehavior, name=IRefresh.__identifier__) self.assertIsNotNone(registration) def test_refresh_behavior(self): view = api.content.get_view(u'view', self.cover, self.request) self.assertNotIn('<meta http-equiv="refresh" content="300" />', view()) self._enable_refresh_behavior() self.cover.enable_refresh = True self.assertIn('<meta http-equiv="refresh" content="300" />', view()) self.cover.ttl = 5 self.assertIn('<meta http-equiv="refresh" content="5" />', view()) self._disable_refresh_behavior() self.assertNotIn('<meta http-equiv="refresh" content="5" />', view())
66b3e2d6486ac2860cf3d9dc0e2ce7f27b2b2f61
5da5473ff3026165a47f98744bac82903cf008e0
/packages/google-cloud-rapidmigrationassessment/samples/generated_samples/rapidmigrationassessment_v1_generated_rapid_migration_assessment_create_collector_async.py
e8096a9b9f9911d1e03ce9c62faa838ef80f8c2b
[ "Apache-2.0" ]
permissive
googleapis/google-cloud-python
ed61a5f03a476ab6053870f4da7bc5534e25558b
93c4e63408c65129422f65217325f4e7d41f7edf
refs/heads/main
2023-09-04T09:09:07.852632
2023-08-31T22:49:26
2023-08-31T22:49:26
16,316,451
2,792
917
Apache-2.0
2023-09-14T21:45:18
2014-01-28T15:51:47
Python
UTF-8
Python
false
false
2,128
py
# -*- coding: utf-8 -*- # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Generated code. DO NOT EDIT! # # Snippet for CreateCollector # NOTE: This snippet has been automatically generated for illustrative purposes only. # It may require modifications to work in your environment. # To install the latest published package dependency, execute the following: # python3 -m pip install google-cloud-rapidmigrationassessment # [START rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: # - It may require correct/in-range values for request initialization. # - It may require specifying regional endpoints when creating the service # client as shown in: # https://googleapis.dev/python/google-api-core/latest/client_options.html from google.cloud import rapidmigrationassessment_v1 async def sample_create_collector(): # Create a client client = rapidmigrationassessment_v1.RapidMigrationAssessmentAsyncClient() # Initialize request argument(s) request = rapidmigrationassessment_v1.CreateCollectorRequest( parent="parent_value", collector_id="collector_id_value", ) # Make the request operation = client.create_collector(request=request) print("Waiting for operation to complete...") response = (await operation).result() # Handle the response print(response) # [END rapidmigrationassessment_v1_generated_RapidMigrationAssessment_CreateCollector_async]
7ae1c12e9f2be77ce9f0ab92c3f38e121f1a177c
0b79d66196e9bef7cf81c0c17b6baac025b0d7f1
/apps/institute/exchange/models/trans.py
4df3228dfa5fefa15caa4a09069fda9dca77b0a5
[]
no_license
tsevindik/sis-back
bf0244a803ba9432980844ff35498780ac664564
4ba942fe38cc150c70898db4daf211213b84a61a
refs/heads/master
2021-03-24T09:35:49.199712
2017-01-25T08:19:37
2017-01-25T08:19:37
73,540,756
0
0
null
null
null
null
UTF-8
Python
false
false
446
py
from django.utils.translation import ugettext_lazy as _ from django.db import models from utils.models import trans as trans_models from . import main class ExchangeProgramTrans(trans_models.Translation): neutral = models.ForeignKey( main.ExchangeProgram ) name = models.CharField( max_length=150, verbose_name=_("İsim") ) description = models.TextField( verbose_name=_("Açıklama") )
e4ad7da2163fa94929de33817be367d5a2304aa4
9c9c6b8deca524c9401dd24d19510d3843bebe4b
/lib/rosserial-0.7.7/rosserial_python/nodes/message_info_service.py
255dc0b61ed3c8c8ee470478ca83f71d4bb5d3c3
[ "MIT" ]
permissive
tku-iarc/wrs2020
3f6473c2f3077400527b5e3008ae8a6e88eb00d6
a19d1106206e65f9565fa68ad91887e722d30eff
refs/heads/master
2022-12-12T20:33:10.958300
2021-02-01T10:21:09
2021-02-01T10:21:09
238,463,359
3
8
MIT
2022-12-09T02:09:35
2020-02-05T14:00:16
C++
UTF-8
Python
false
false
3,811
py
#!/usr/bin/env python ##################################################################### # Software License Agreement (BSD License) # # Copyright (c) 2013, Clearpath Robotics # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Willow Garage, Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. """ The node provided by this file exposes a helper service used by the C++ rosserial_server. The service allows the C++ driver to look up message definitions and hash strings which would not have been known to it at compile time, allowing it to fully advertise topics originating from microcontrollers. This allows rosserial_server to be distributed in binary form. """ import rospy from rosserial_msgs.srv import RequestMessageInfo from rosserial_msgs.srv import RequestServiceInfo from rosserial_python import load_message from rosserial_python import load_service class MessageInfoService(object): """ """ def __init__(self): rospy.init_node("message_info_service") rospy.loginfo("rosserial message_info_service node") self.service = rospy.Service("message_info", RequestMessageInfo, self._message_info_cb) self.serviceInfoService = rospy.Service("service_info", RequestServiceInfo, self._service_info_cb) self.message_cache = {} self.service_cache = {} def _message_info_cb(self, req): package_message = tuple(req.type.split("/")) if not self.message_cache.has_key(package_message): rospy.loginfo("Loading module to return info on %s/%s." % package_message) msg = load_message(*package_message) self.message_cache[package_message] = (msg._md5sum, msg._full_text) else: rospy.loginfo("Returning info from cache on %s/%s." % package_message) return self.message_cache[package_message] def _service_info_cb(self, req): rospy.logdebug("req.service is %s" % req.service) package_service = tuple(req.service.split("/")) if not self.service_cache.has_key(package_service): rospy.loginfo("Loading module to return info on service %s/%s." % package_service) srv,mreq,mres = load_service(*package_service) self.service_cache[package_service] = (srv._md5sum,mreq._md5sum,mres._md5sum) else: rospy.loginfo("Returning info from cache on %s/%s." % package_service) return self.service_cache[package_service] def spin(self): rospy.spin() if __name__=="__main__": MessageInfoService().spin()
795dbc96c00507330fd13e6649af217203c656ca
ad10cd9aecb8e1b277996484a35f54544a3f56c4
/websiteproject/website/hoster/apps.py
6dad85d641b26d6d519eeb952a0427033c6c76b1
[]
no_license
gokul05021992/whole-projects
4a4264ec75e1878a3661145a63c99c2b4b7c8350
993a8b8db83266e434387730cc5f8b16e4a8b77e
refs/heads/master
2023-05-22T18:36:38.651925
2021-06-13T01:09:11
2021-06-13T01:09:11
376,460,805
0
0
null
null
null
null
UTF-8
Python
false
false
87
py
from django.apps import AppConfig class HosterConfig(AppConfig): name = 'hoster'
e5ea6a00ec40529047d2c1c4091f48835b8d9bcf
ba3cd834eb2810dd672e026f5f809b8b32918052
/app/models.py
c55325761c7e8e42ece2616e51e8e8765ad45bc3
[]
no_license
JellyWX/stripe-donations
6f9fb789fdfb09417b33964edf1c8c7083d7e248
1c4b38dace0c952dfb7a7eb425f83069312fed6a
refs/heads/master
2020-03-21T01:06:57.410200
2018-07-23T17:29:56
2018-07-23T17:29:56
137,925,116
0
0
null
null
null
null
UTF-8
Python
false
false
240
py
from app import db class SimpleUser(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String) email = db.Column(db.String, index=True, unique=True) user_id = db.Column(db.Integer, unique=True)
d7826c4912bd789949d878121f50e3572b86da3f
d05c946e345baa67e7894ee33ca21e24b8d26028
/general/detect-fraudulent-transactions/producer.py
158ba419a43b331f7a476d98ab26bb4e9fd7350e
[ "MIT" ]
permissive
x4nth055/pythoncode-tutorials
327255550812f84149841d56f2d13eaa84efd42e
d6ba5d672f7060ba88384db5910efab1768c7230
refs/heads/master
2023-09-01T02:36:58.442748
2023-08-19T14:04:34
2023-08-19T14:04:34
199,449,624
1,858
2,055
MIT
2023-08-25T20:41:56
2019-07-29T12:35:40
Jupyter Notebook
UTF-8
Python
false
false
641
py
import os import json from time import sleep from kafka import KafkaProducer # import initialization parameters from settings import * from transactions import create_random_transaction if __name__ == "__main__": producer = KafkaProducer(bootstrap_servers = KAFKA_BROKER_URL #Encode all values as JSON ,value_serializer = lambda value: json.dumps(value).encode() ,) while True: transaction: dict = create_random_transaction() producer.send(TRANSACTIONS_TOPIC, value= transaction) print(transaction) #DEBUG sleep(SLEEP_TIME)
fe18a1b59c75b08af2133e32331902343921e6ae
5cd7a8e67a911d1a5562488349db38979ff1c047
/CSV/exercise 25.1/exercise 25.1.py
066d70d3f7456650d769f9e18d8de7595b1fc119
[]
no_license
IshaanBAgrawal/Day-25
3f154186b040de35b19908fb790807954f5805dc
070ab3178c5aa3dde25391e69065e08a69665ee1
refs/heads/master
2023-07-01T18:45:27.997485
2021-08-10T10:04:41
2021-08-10T10:04:41
394,603,857
0
0
null
null
null
null
UTF-8
Python
false
false
605
py
import pandas squirrel_data = pandas.read_csv("Central_Park_Squirrel_census.csv") print(type(squirrel_data)) squirrel_fur_color = squirrel_data["Primary Fur Color"] black = 0 gray = 0 cinnamon = 0 for color in squirrel_fur_color: if color == "Black": black += 1 elif color == "Gray": gray += 1 elif color == "Cinnamon": cinnamon += 1 else: pass squirrel_color = { "colors": ["Black", "Gray", "Cinnamon"], "squirrel_no": [black, gray, cinnamon] } squirrel_color_no = pandas.DataFrame(squirrel_color) squirrel_color_no.to_csv("Squirrel_color.csv")
2d948416a6dd66cd777ca2c42cfed3839faad9e4
25238196fd7f18fc2452c84264a9c1d7a9c3c34a
/ver11/chargingFunctions.py
9a5383bfbf60dcb940153e1546bc884201c92aa6
[]
no_license
jwcn97/Fleet-Simulation
c6765db96f2beacda19f375a3a5bb14a0a4f98c4
3f3ef5f994f68361b13a46336095ffd9fca9f177
refs/heads/master
2022-11-27T01:49:28.566534
2020-08-06T06:58:33
2020-08-06T06:58:33
204,433,252
1
0
null
null
null
null
UTF-8
Python
false
false
20,217
py
import pandas as pd import numpy as np import time from chunks import chunks from supportFunctions import * ###################################################### # FUNCTIONS WHICH SUPPORT CHARGING ###################################################### # ALLOCATE AN AVAILABLE CHARGE PT OR SELECT CURRENT CHARGE PT def findChargePt(carDataDF, car, chargePtDF): # SELECT AVAILABLE CHARGE PTS availablePts = chargePtDF.loc[chargePtDF['inUse'] != 1] chargePt = carDataDF.loc[car, 'chargePt'] # IF CAR IS NOT ON A CHARGE PT, PLUG INTO FIRST AVAILABLE CHARGE PT if np.isnan(chargePt) and len(availablePts) > 0: pt = availablePts.index[0] availablePts = availablePts.drop(pt, axis=0) # UPDATE CHARGE PT DF and CAR DATA DF chargePtDF.loc[pt, 'inUse'] = 1 carDataDF.loc[car, 'chargePt'] = pt # IF CAR HAS A CHARGE PT, PT = CHARGE PT, ELSE PT = NAN else: pt = chargePt return pt, carDataDF, chargePtDF # IN SORTED ORDER, CALCULATE PRIORITY RATIO AND ASSIGN CHARGE def priorityCharge(priorityRows, availablePower, carDataDF, chargePtDF): # CONVERT LIST INTO DATAFRAME AND SORT BY PRIORITY priorities = pd.DataFrame.from_records(priorityRows, columns=['car','priority','battLeft','pt']) priorities = priorities.sort_values(by=['priority'], ascending=False) priorities = priorities.reset_index(drop=True) # CALCULATE THE SUM OF PRIORITY VALUES prioritySum = sum(priorities.priority) # IF THERE ARE VEHICLES AVAILABLE IN DEPOT TO CHARGE if (len(priorityRows) > 0) and (prioritySum > 0): # FOR EVERY CAR: for row in range(0, len(priorities)): # READ IN DATA FOR SELECTED CAR car = priorities.loc[row, 'car'] battLeft = priorities.loc[row, 'battLeft'] priority = priorities.loc[row, 'priority'] pt = priorities.loc[row, 'pt'] maxRate = chargePtDF.loc[pt, 'maxRate'] batt = carDataDF.loc[car, 'battkW'] battSize = carDataDF.loc[car, 'battSize'] # CALCULATE CHARGE RATE USING PRIORITY/SUM OF PRIORITIES chargeRate = (priority/prioritySum)*availablePower # IF CHARGE RATE EXCEEDS MAX RATE: if chargeRate > maxRate: chargeRate = maxRate # IF CHARGE RATE EXCEEDS CHARGE NEEDED BY VEHICLE: if chargeRate/chunks > battLeft: chargeRate = battLeft*chunks # ADJUST REMAINING AVAILABLE POWER AND PRIORITY SUM availablePower -= chargeRate prioritySum -= priority # UPDATE CHARGE RATE carDataDF.loc[car, 'chargeRate'] = chargeRate return carDataDF # CHARGE VEHICLE FOR ONE HOUR def charge(time, carDataDF, sim, pricesDF, predictive): # GET TOTAL COST OF ALL VEHICLES totalCost = carDataDF['totalCost'].sum() # SELECT CARS IN DEPOT inDepotDF = carDataDF.loc[carDataDF['inDepot'] == 1] # DETERMINE WHAT IS THE UPPER LIMIT OF BATTERY if predictive: upperLimit = 'battNeeded' else : upperLimit = 'battSize' # FOR EVERY CAR IN THE DEPOT for index in range(len(inDepotDF)): car = inDepotDF.index[index] # READ IN BATTERY, BATTERY SIZE, BATTERY NEEDED AND CHARGE RATE batt = carDataDF.loc[car,'battkW'] battSize = carDataDF.loc[car, 'battSize'] battNeeded = carDataDF.loc[car, upperLimit] chargeRate = carDataDF.loc[car,'chargeRate'] # DETERMINE EVENT STATUS if chargeRate > 0: event = "charge" elif batt == battSize: event = "full" else: event = "wait" # TAKE INTO ACCOUNT VEHICLES REACHING UPPER LIMIT if chargeRate >= (battNeeded-batt)*chunks: chargeRate = (battNeeded-batt)*chunks # FIND PRICE OF CHARGE AT TIME # * Read in start and end times of green zone lowTariffStartHr = readTime(getData(pricesDF, 'startGreenZone')) lowTariffEndHr = readTime(getData(pricesDF, 'endGreenZone')) # * Read in current time without date timeHr = readTime(str(time.time())) # USE APPROPRIATE PRICING BASED ON CURRENT TIME if lowTariffStartHr <= timeHr < lowTariffEndHr: price = float(getData(pricesDF, 'priceGreenZone')) else: price = float(getData(pricesDF, 'priceRedZone')) # CALCULATE COST OF CHARGE AND ADD THIS TO TOTAL COST costOfCharge = (chargeRate*price)/chunks totalCost += costOfCharge # APPEND DATA TO SIMULATION DATA # time, car, chargeDiff, batt, event, costPerCharge, totalCost sim += [[time, car, round(chargeRate/chunks, 2), round(batt, 2), event, round(costOfCharge, 3), round(totalCost, 3)]] # ASSIGN UPDATED TOTAL COST AND BATTERY KW carTotalCost = carDataDF.loc[car, 'totalCost'] carDataDF.loc[car, 'totalCost'] = carTotalCost + costOfCharge carDataDF.loc[car, 'battkW'] = batt + chargeRate/chunks return carDataDF, sim ################################# # INCREASE BATT DURING CHARGE ################################# def dumbCharge(time, carDataDF, depot, shiftsByCar, availablePower, chargePtDF, pricesDF, eventChange): # SELECT CARS IN DEPOT THAT ARE NOT FULLY CHARGED needChargeDF = carDataDF.loc[(carDataDF['inDepot'] == 1) & (carDataDF['battkW'] < carDataDF['battSize'])] for cars in range(len(needChargeDF)): car = needChargeDF.index[cars] # ALLOCATE AVAILABLE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, car, chargePtDF) # SELECT CARS IN DEPOT WITH VALID CHARGE PTS chargeDF = carDataDF.loc[(carDataDF['inDepot'] == 1) & (carDataDF['battkW'] < carDataDF['battSize']) & (~carDataDF['chargePt'].isna())] # IF THERE ARE CARS WITH VALID CHARGE POINTS THAT REQUIRE CHARGING if len(chargeDF) > 0: # SPLIT CHARGE RATE EQUALLY BETWEEN CARS THAT ARE CHARGING if len(chargeDF) <= len(chargePtDF): splitChargeRate = availablePower/len(chargeDF) else: splitChargeRate = availablePower/len(chargePtDF) # CHARGE SELECTED CARS IN DEPOT for cars in range(len(chargeDF)): car = chargeDF.index[cars] # LET CHARGE RATE = SPLIT CHARGE RATE chargeRate = splitChargeRate # ALLOCATE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, car, chargePtDF) # IF CAR HAS A VALID CHARGE PT if not np.isnan(pt): # LIMIT CHARGE RATE TO MAX RATE OF CHARGE PT maxRatePt = chargePtDF.loc[pt, 'maxRate'] if maxRatePt < chargeRate: chargeRate = maxRatePt # IF NO CHARGE PTS AVAILABLE, DON'T CHARGE else: chargeRate = 0 # UPDATE CHARGE RATE carDataDF.loc[car, 'chargeRate'] = chargeRate return carDataDF ######################################### # INCREASE BATT DURING CHARGE (LEAVETIME) ######################################### def smartCharge_leavetime(time, carDataDF, depot, shiftsByCar, availablePower, chargePtDF, pricesDF, eventChange): # CREATE A LIST FOR CARS AND THEIR LEAVETIMES (TIME UNTIL CAR LEAVSE DEPOT) leaveTList = [] # ***** FIND LEAVETIMES AND APPEND TO A LIST ***** for cars in range(0, len(depot)): car = depot[cars] # FIND THE START AND END TIME OF NEXT SHIFT nextStart, nextEnd = nextShift(car, carDataDF, shiftsByCar) # CALCULATE TIME LEFT UNTIL CAR LEAVES AND APPEND TO LIST hrsLeft = ((rereadTime(nextStart) - rereadTime(time)).total_seconds())/(60*60) leaveTList.append([car, hrsLeft]) # ***** CONVERT LIST INTO DATAFRAME AND SORT ***** leaveTimes = pd.DataFrame.from_records(leaveTList, columns=['car','hrsLeft']) leaveTimes = leaveTimes.sort_values(by=['hrsLeft']) leaveTimes = leaveTimes.reset_index(drop=True) # ***** CHARGE CARS IN SORTED ORDER ***** for row in range(0, len(leaveTimes)): # READ IN DATA FOR SELECTED CAR car = leaveTimes.loc[row, 'car'] batt = carDataDF.loc[car, 'battkW'] battSize = carDataDF.loc[car, 'battSize'] chargePt = carDataDF.loc[car, 'chargePt'] # IF CAR BATT IS NOT 100%, CHARGE CAR if batt < battSize: # ALLOCATE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, car, chargePtDF) chargeRate = 0 # IF CAR HAS A VALID CHARGE PT: if not np.isnan(pt): # READ MAX RATE maxRate = chargePtDF.loc[pt, 'maxRate'] # CALCULATE THE ENERGY LEFT IF CAR WAS CHARGED AT MAX energyLeft = availablePower - maxRate # IF THERE IS ENOUGH ENERGY FOR MAX RATE, CHARGE CAR AT MAX if energyLeft >= 0: chargeRate = maxRate # IF THERE ISN'T ENOUGH FOR MAX RATE, CHARGE USING REMAINING POWER elif energyLeft < 0 and energyLeft > -maxRate: chargeRate = availablePower # IF VEHICLE IS PLUGGED IN BUT NOT ALLOCATED CHARGE else: chargeRate = 0 # UPDATE CHARGE RATE carDataDF.loc[car, 'chargeRate'] = chargeRate # ADJUST AVAILABLE POWER availablePower -= chargeRate return carDataDF ###################################### # INCREASE BATT DURING CHARGE (BATT) ###################################### def smartCharge_batt(time, carDataDF, depot, shiftsByCar, availablePower, chargePtDF, pricesDF, eventChange): # CREATE A LIST FOR CARS AND THEIR BATT NEEDED battNeededList = [] # ***** FOR ALL CARS, FIND BATT NEEEDED UNTIL FULLY CHARGED ***** for cars in range(0, len(depot)): carNum = depot[cars] # CALCULATE BATTERY NEEDED AND APPEND TO LIST battLeft = abs(carDataDF.loc[carNum,'battSize']-carDataDF.loc[carNum,'battkW']) battNeededList.append([carNum, battLeft]) # ***** CONVERT LIST INTO DATAFRAME AND SORT ***** battNeeded = pd.DataFrame.from_records(battNeededList, columns=['car','battLeft']) battNeeded = battNeeded.sort_values(by=['battLeft'], ascending=False) battNeeded = battNeeded.reset_index(drop=True) # ***** CHARGE CARS IN SORTED ORDER ***** for row in range(0, len(battNeeded)): # READ IN DATA FOR SELECTED CAR car = battNeeded.loc[row, 'car'] batt = carDataDF.loc[car, 'battkW'] battSize = carDataDF.loc[car, 'battSize'] chargePt = carDataDF.loc[car, 'chargePt'] # IF CAR BATT IS NOT 100%, CHARGE CAR if batt < battSize: # ALLOCATE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, car, chargePtDF) chargeRate = 0 # IF CAR HAS A VALID CHARGE PT if not np.isnan(pt): # READ MAX RATE maxRate = chargePtDF.loc[pt, 'maxRate'] # CALCULATE THE ENERGY LEFT IF CAR WAS CHARGED AT MAX energyLeft = availablePower - maxRate # IF THERE IS ENOUGH ENERGY FOR MAX RATE, CHARGE CAR AT MAX if energyLeft >= 0: chargeRate = maxRate # IF THERE ISN'T ENOUGH FOR MAX RATE, CHARGE USING REMAINING POWER elif energyLeft < 0 and energyLeft > -maxRate: chargeRate = availablePower # IF VEHICLE IS PLUGGED IN BUT NOT ALLOCATED CHARGE else: chargeRate = 0 # UPDATE CHARGE RATE carDataDF.loc[car, 'chargeRate'] = chargeRate # ADJUST AVAILABLE POWER availablePower -= chargeRate return carDataDF ############################################ # INCREASE BATT DURING CHARGE (PRIORITY) ############################################ """ PRIORITY = BATT LEFT/TIME LEFT IN DEPOT CHARGE RATE = (PRIORITY/SUM OF ALL PRIORITIES)*AVAILABLE POWER """ def smartCharge_battOverLeavetime(time, carDataDF, depot, shiftsByCar, availablePower, chargePtDF, pricesDF, eventChange): # CREATE A LIST FOR CARS AND THEIR PRIORITY AND BATT NEEDED priorityRows = [] # ***** CALCULATE PRIORITY FOR EACH CAR AND APPEND TO A LIST ***** for cars in range(0, len(depot)): carNum = depot[cars] # GET BATTERY AND BATTERY SIZE batt = carDataDF.loc[carNum, 'battkW'] battSize = carDataDF.loc[carNum, 'battSize'] # ALLOCATE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, carNum, chargePtDF) # ONLY CONSIDER VEHICLES THAT ARE ATTACHED TO A CHARGE POINT AND WITHOUT FULL BATTERY if (~np.isnan(pt)) and (batt < battSize): # FIND THE START AND END TIME OF NEXT SHIFT nextStart, nextEnd = nextShift(carNum, carDataDF, shiftsByCar) # CALCULATE TIME LEFT AND BATT LEFT hrsLeft = ((rereadTime(nextStart) - rereadTime(time)).total_seconds())/(60*60) battLeft = battSize-batt # LET PRIORITY = BATTLEFT/TIME LEFT, APPEND TO LIST priorityRows.append([carNum, battLeft/(hrsLeft**2), battLeft, pt]) # IN SORTED ORDER, CALCULATE PRIORITY RATIO AND CHARGE carDataDF = priorityCharge(priorityRows, availablePower, carDataDF, chargePtDF) return carDataDF ############################################## # INCREASE BATT DURING CHARGE (COST SENSITIVE) ############################################## """ PRIORITY = BATT LEFT/TIME LEFT IN DEPOT CHARGE VEHICLE ONLY WHEN LOW TARIFF ZONE STARTS CHARGE RATE = (PRIORITY/SUM OF ALL PRIORITIES)*AVAILABLE POWER """ def costSensitiveCharge(time, carDataDF, depot, shiftsByCar, availablePower, chargePtDF, pricesDF, eventChange): # DEFINE NEXT LOW TARIFF ZONE lowTariffStart, lowTariffEnd = nextLowTariffZone(time, pricesDF) # CREATE A LIST FOR CARS AND THEIR LEAVETIME AND BATT NEEDED priorityRows = [] # ***** CALCULATE PRIORITY FOR EACH CAR AND APPEND TO A LIST ***** for cars in range(0, len(depot)): carNum = depot[cars] # GET BATTERY AND BATTERY SIZE batt = carDataDF.loc[carNum, 'battkW'] battSize = carDataDF.loc[carNum, 'battSize'] # ALLOCATE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, carNum, chargePtDF) # FIND THE START AND END TIME OF NEXT SHIFT nextStart, nextEnd = nextShift(carNum, carDataDF, shiftsByCar) # ONLY CONSIDER VEHICLES THAT ARE # 1) ATTACHED TO A CHARGE POINT # 2) WITHOUT FULL BATTERY # 3) NOT WAITING FOR LOW TARIFF ZONE if (~np.isnan(pt)) and (batt < battSize) and not (time < lowTariffStart < nextStart): # CALCULATE TIME LEFT AND BATT LEFT hrsLeft = ((rereadTime(nextStart) - rereadTime(time)).total_seconds())/(60*60) battLeft = battSize-batt # LET PRIORITY = BATTLEFT/TIME LEFT, APPEND TO LIST priorityRows.append([carNum, battLeft/(hrsLeft**2), battLeft, pt]) # IN SORTED ORDER, CALCULATE PRIORITY RATIO AND CHARGE carDataDF = priorityCharge(priorityRows, availablePower, carDataDF, chargePtDF) return carDataDF ############################################## # INCREASE BATT DURING CHARGE (EXTRA) ############################################## """ PRIORITY = BATT LEFT/TIME LEFT IN DEPOT THERE WILL BE A FUNCTION (READ EXTRA CHARGING) TO LOOK INTO NEXT LOW TARIFF ZONE AND SEE WHETHER VEHICLES NEED EXTRA CHARGING IF YES, IT WILL STATE THAT AN EVENT HAS HAPPENED SO THAT THE ALGORITHM WILL RUN CHARGE VEHICLE WHEN THE TIME COMES CHARGE RATE = (PRIORITY/SUM OF ALL PRIORITIES)*AVAILABLE POWER """ def extraCharge(time, carDataDF, depot, shiftsByCar, availablePower, chargePtDF, pricesDF, eventChange): # DEFINE NEXT LOW TARIFF ZONE lowTariffStart, lowTariffEnd = nextLowTariffZone(time, pricesDF) # CREATE A LIST FOR CARS AND THEIR LEAVETIME AND BATT NEEDED priorityRows = [] # ***** CALCULATE PRIORITY FOR EACH CAR AND APPEND TO A LIST ***** for cars in range(0, len(depot)): carNum = depot[cars] # GET BATTERY AND BATTERY SIZE batt = carDataDF.loc[carNum, 'battkW'] battSize = carDataDF.loc[carNum, 'battSize'] # ALLOCATE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, carNum, chargePtDF) # ONLY CONSIDER VEHICLES THAT ARE # 1) ATTACHED TO A CHARGE POINT # 2) WITHOUT FULL BATTERY if (~np.isnan(pt)) and (batt < battSize): # FIND THE START AND END TIME OF NEXT SHIFT nextStart, nextEnd = nextShift(carNum, carDataDF, shiftsByCar) # IF VEHICLE IS WAITING FOR LOW TARIFF ZONE # IF EXTRA CHARGING EVENT HASN'T OCCURRED: if (time < lowTariffStart < nextStart) and (eventChange != "extraCharging"): # DELAY CHARGING continue else: # CALCULATE TIME LEFT AND BATT LEFT hrsLeft = ((rereadTime(nextStart) - rereadTime(time)).total_seconds())/(60*60) battLeft = battSize-batt # LET PRIORITY = BATTLEFT/TIME LEFT, APPEND TO LIST priorityRows.append([carNum, battLeft/(hrsLeft**2), battLeft, pt]) # IN SORTED ORDER, CALCULATE PRIORITY RATIO AND CHARGE carDataDF = priorityCharge(priorityRows, availablePower, carDataDF, chargePtDF) return carDataDF ############################################## # INCREASE BATT DURING CHARGE (PREDICTIVE) ############################################## """ PRIORITY = BATT NEEDED/TIME LEFT IN DEPOT CHECKS FOR EXTRA CHARGING BEFORE DECIDING WHETHER TO WAIT TILL LOW TARIFF ZONE * NEW!: UPPER LIMIT OF VEHICLE'S BATTERY NEEDED NEED NOT BE ITS BATTERY SIZE IT CAN BE AN ARBITRARY VALUE DEFINED BY FUNCTION "PREDICT BATTERY NEEDED" CHARGE RATE = (PRIORITY/SUM OF ALL PRIORITIES)*AVAILABLE POWER """ def predictiveCharge(time, carDataDF, depot, shiftsByCar, availablePower, chargePtDF, pricesDF, eventChange): # DEFINE NEXT LOW TARIFF ZONE lowTariffStart, lowTariffEnd = nextLowTariffZone(time, pricesDF) # CREATE A LIST FOR CARS AND THEIR LEAVETIME AND BATT NEEDED priorityRows = [] # ***** CALCULATE PRIORITY FOR EACH CAR AND APPEND TO A LIST ***** for cars in range(0, len(depot)): carNum = depot[cars] # GET BATTERY, BATTERY SIZE AND BATTERY NEEDED batt = carDataDF.loc[carNum, 'battkW'] battSize = carDataDF.loc[carNum, 'battSize'] battNeeded = carDataDF.loc[carNum, 'battNeeded'] # ALLOCATE CHARGE PT IF CAR DOESN'T HAVE ONE pt, carDataDF, chargePtDF = findChargePt(carDataDF, carNum, chargePtDF) # ONLY CONSIDER VEHICLES THAT ARE # 1) ATTACHED TO A CHARGE POINT # 2) STILL NEEDS BATTERY if (~np.isnan(pt)) and (batt < battNeeded): # FIND THE START AND END TIME OF NEXT SHIFT nextStart, nextEnd = nextShift(carNum, carDataDF, shiftsByCar) # IF VEHICLE IS WAITING FOR LOW TARIFF ZONE # IF EXTRA CHARGING EVENT HASN'T OCCURRED: if (time < lowTariffStart < nextStart) and (eventChange != "extraCharging"): # DELAY CHARGING continue else: # CALCULATE TIME LEFT AND BATT LEFT hrsLeft = ((rereadTime(nextStart) - rereadTime(time)).total_seconds())/(60*60) battLeft = battNeeded-batt # LET PRIORITY = BATTLEFT/TIME LEFT, APPEND TO LIST priorityRows.append([carNum, battLeft/(hrsLeft**2), battLeft, pt]) # IN SORTED ORDER, CALCULATE PRIORITY RATIO AND CHARGE carDataDF = priorityCharge(priorityRows, availablePower, carDataDF, chargePtDF) return carDataDF
d941836293931263f2257eb353b15328e1114bc3
d6fd55ff015ddcc380ffea2da140d86c5fa9feff
/bin/thecannon
5876059c39690095d755554b6735280b8df52036
[ "BSD-3-Clause" ]
permissive
sdss/astra_thecannon
b3a461b91894ec391318fd4a098b5688299923b8
3062025aa2ac3b8af257490be63201587b23762d
refs/heads/master
2021-07-05T01:08:12.774277
2020-10-06T12:37:53
2020-10-06T12:37:53
182,139,411
0
0
null
null
null
null
UTF-8
Python
false
false
16,794
#!/usr/bin/env python # encoding: utf-8 import argparse import numpy as np import os from astropy.table import (Table, join, unique) from collections import Counter from tqdm import tqdm from warnings import warn from astra import log from astra.utils.data_models import parse_descriptors from astra.tools.parsers.common import component_parser from astra.tools.spectrum import (Spectrum1D, SpectrumList) from thecannon import continuum, vectorizer from thecannon.model import CannonModel if __name__ == '__main__': parser = component_parser(prog=os.path.basename(__file__), description="The Cannon: A data-driven model for stellar spectra") subparsers = parser.add_subparsers(help="Specify whether to train or test", dest="command") subparsers.required = True train_parser = subparsers.add_parser("train", help="Train a data driven model given a training set of " "labels and spectra") train_parser.add_argument("label_path", help="The path that contains the labels for all input paths.") train_parser.add_argument("label_names", help="A comma-separated list of the label names to use in the model.") train_parser.add_argument("--ignore-duplicates", action="store_true", help="if the INPUT_PATHs cannot be uniquely identified as rows in the "\ "LABEL_PATH file, then ignore the duplicate rows (default: False)") # Data arguments. train_parser.add_argument("--spectrum-index", default=0, help="the index of the spectrum to use in the training set spectra " "(default: 0)") # Continuum arguments. train_parser.add_argument("--no-continuum", action="store_true", help="do not fit the pseudo-continuum") train_parser.add_argument("--continuum-regions-path", dest="continuum_regions_path", default=None, help="the path to a file describing regions of continuum pixels") train_parser.add_argument("--continuum-length-scale", dest="continuum_length_scale", default=1400, help="the length scale (in pixels) for the sine and cosine functions " "used in determining the continuum (default: 1400)") train_parser.add_argument("--continuum-order", dest="continuum_order", default=3, help="the number of sine and cosine functions to use to fit the "\ "continuum (default: 3)") # Model arguments. train_parser.add_argument("--order", dest="order", default=2, help="the polynomial order of the model to use (default: 2; quadratic)") train_parser.add_argument("--regularization", dest="regularization", default=0, help="the L1 regularization hyperparameter to use (default: 0)") # Operational arguments. train_parser.add_argument("-t", "--threads", dest="threads", default=1, help="number of parallel threads to use") # Test step. test_parser = subparsers.add_parser("test", help="Use a pre-trained model to estimate stellar labels.") # Model arguments. test_parser.add_argument("model_path", help="the path to a pre-trained model") # Data arguments. test_parser.add_argument("--spectrum-index", default=0, help="the index of the spectrum to use in the training set spectra " "(default: 0)") # Continuum arguments. test_parser.add_argument("--no-continuum", action="store_true", help="do not fit the pseudo-continuum") test_parser.add_argument("--continuum-regions-path", dest="continuum_regions_path", default=None, help="the path to a file describing regions of continuum pixels") test_parser.add_argument("--continuum-length-scale", dest="continuum_length_scale", default=1400, help="the length scale (in pixels) for the sine and cosine functions " "used in determining the continuum (default: 1400)") test_parser.add_argument("--continuum-order", dest="continuum_order", default=3, help="the number of sine and cosine functions to use to fit the " "continuum (default: 3)") # Optimization arguments. test_parser.add_argument("--initialisations", default=1, help="the number of initial points to optimize from (default: 1)") # Operational arguments. test_parser.add_argument("-t", "--threads", dest="threads", default=1, help="number of parallel threads to use") # Parse. args, unknown = parser.parse_known_args() if unknown: warn(f"Ignoring unknown arguments: {unknown}") if args.command == "train": # Check for duplicates in input_paths. if len(set(args.input_paths)) < len(args.input_paths): counts = Counter(args.input_paths) duplicates = "\n".join([f"\t{k}: {v} entries" for k, v in counts.items() if v > 1]) parser.error(f"there are duplicate paths in {args.input_path}:\n" f"{duplicates}") # Load in all the labels. log.info(f"Reading labels from {args.label_path}") labels = Table.read(args.label_path) # Ensure we can match the labels to the appropriate input paths. if len(labels) == len(args.input_paths): warn(f"Assuming each row in INPUT_PATHs corresponds to the same row in LABELS_PATH! " "If this is not true then you're going to have a very bad time!") else: raise NotImplementedError("danger Will Robinson") # Build the labels array. label_names = args.label_names.split(",") log.info(f"Label names to use: {label_names}") training_set_labels = np.array([labels[ln] for ln in label_names]).T for i, label_name in enumerate(label_names): minmax = [np.min(training_set_labels.T[i]), np.max(training_set_labels.T[i])] log.info(f"Minimum/maximum {label_name} in training set: {minmax}") # Find the first useful spectrum. for first_spectrum_idx, input_path in enumerate(args.input_paths): # Deal with all cases of size etc. try: N_pixels = np.atleast_2d(SpectrumList.read(input_path)[0].wavelength).shape[1] except IOError: continue else: break else: raise IOError("all input paths are corrupt or missing") N_paths = len(args.input_paths) log.info(f"There are {N_paths} spectra in the training set") log.info(f"There are {N_pixels} assumed per spectrum") log.info(f"Using spectrum index {args.spectrum_index} (zero-indexed) from --spectrum-index") wavelengths = np.nan * np.ones((N_paths, N_pixels), dtype=float) training_set_flux = np.ones_like(wavelengths) training_set_ivar = np.zeros_like(wavelengths) # Continuum normalize if necessary. continuum_kwds = dict() if not args.no_continuum: continuum_kwds.update(L=args.continuum_length_scale, order=args.continuum_order) if args.continuum_regions_path is not None: continuum_kwds.update(continuum_regions=np.loadtxt(args.continuum_regions_path)) log.info(f"Pseudo-continuum normalization keywords: {continuum_kwds}") log.info(f"Loading training set spectra and pseudo-continuum normalizing..") else: log.info(f"No pseudo-continuum normalization will take place!") log.info(f"Loading training set spectra..") for i, input_path in enumerate(tqdm(args.input_paths)): if not os.path.exists(input_path): log.info(f"Path {input_path} does not exist. Skipping..") continue try: spectrum = Spectrum1D.read(input_path, verbosity=0) except OSError: log.info(f"Exception raised when trying to load {input_path}. Skipping..") continue # TODO: Write a general parallelised wrapper in Astra that makes use of tqdm wavelengths[i] = spectrum.wavelength.value # Continuum normalize if necessary if continuum_kwds: norm_flux, norm_ivar, cont, meta = continuum.normalize( spectrum.wavelength.value, spectrum.flux.value[args.spectrum_index], spectrum.uncertainty.array[args.spectrum_index], **continuum_kwds) # continuum.normalize will always return a 2D array training_set_flux[i] = norm_flux[0] training_set_ivar[i] = norm_ivar[0] else: training_set_flux[i] = spectrum.flux.value[args.spectrum_index] training_set_ivar[i] = spectrum.uncertainty.array[args.spectrum_index] log.info(f"Training set spectra loaded") log.info(f"Creating common dispersion mapping..") # Put everything on a common wavelength scale. min_wl = np.nanmax(wavelengths[:, 0]) max_wl = np.nanmin(wavelengths[:, -1]) # Check for uniform sampling in linear or logarithmic space. lin_space = np.std(np.diff(wavelengths[first_spectrum_idx])) log_space = np.std(np.diff(np.log10(wavelengths[first_spectrum_idx]))) is_log_lambda_spaced = (lin_space > log_space) if is_log_lambda_spaced: log.info("Identified as uniform spacing in log-wavelength") delta = np.mean(np.diff(np.log10(wavelengths[first_spectrum_idx]))) common_wavelengths = 10**np.arange(np.log10(min_wl), np.log10(max_wl) + delta, delta) else: log.info("Identified as uniform spacing in linear wavelength") delta = np.mean(np.diff(wavelengths[first_spectrum_idx])) common_wavelengths = np.arange(min_wl, max_wl + delta, delta) log.info(f"Common wavelength grid {min_wl:.1f} to {max_wl:.1f} ({common_wavelengths.size} pixels") assert common_wavelengths.size == training_set_flux.shape[1] log.info(f"Re-sampling training set spectra onto common wavelength grid..") for i, (wave_, flux_, ivar_) \ in enumerate(tqdm(zip(wavelengths, training_set_flux, training_set_ivar), total=N_paths)): training_set_flux[i] = np.interp(common_wavelengths, wave_, flux_) training_set_ivar[i] = np.interp(common_wavelengths, wave_, ivar_) log.info(f"Correcting bad pixels..") bad = (~np.isfinite(training_set_flux)) + (~np.isfinite(training_set_ivar)) training_set_flux[bad] = 1.0 training_set_ivar[bad] = 0.0 N_bad = np.sum(bad) f_bad = 100 * N_bad/training_set_flux.size log.info(f"Corrected {N_bad} pixels ({f_bad:.0e}%)") log.info(f"Creating the model") model = CannonModel(training_set_labels, training_set_flux, training_set_ivar, vectorizer=vectorizer.PolynomialVectorizer(label_names, args.order), dispersion=common_wavelengths, regularization=args.regularization) log.info(f"Training the model {model}") model.train(threads=args.threads) # Prepare outputs. os.makedirs(args.output_dir, exist_ok=True) log.info(f"Created output directory {args.output_dir}") # Write the model to disk. output_path = os.path.join(args.output_dir, "Cannon.model") model.write(output_path, include_training_set_spectra=False, overwrite=True) log.info(f"Model ({model}) written to {output_path}") log.info(f"Running one-to-one test for sanity") test_labels, cov, meta = model.test(training_set_flux, training_set_ivar, threads=args.threads) fig_path = os.path.join(args.output_dir, "one-to-one.png") log.info(f"Creating figure..") try: from thecannon import plot fig = plot.one_to_one(model, test_labels) fig.savefig(fig_path) except: log.exception("Figure could not be produced:") else: log.info(f"Created output figure {fig_path}") elif args.command == "test": # Load the model. model = CannonModel.read(args.model_path) log.info(f"Loaded Cannon model from {args.model_path}: {model}") # Check continuum. continuum_kwds = dict() if not args.no_continuum: continuum_kwds.update(L=args.continuum_length_scale, order=args.continuum_order) if args.continuum_regions_path is not None: continuum_kwds.update(continuum_regions=np.loadtxt(args.continuum_regions_path)) log.info(f"Pseudo-continuum normalization keywords: {continuum_kwds}") else: log.info(f"No pseudo-continuum normalization will take place!") log.info(f"We will access index {args.spectrum_index} from available spectra in each input path") # Prepare outputs. os.makedirs(args.output_dir, exist_ok=True) log.info(f"Created output directory {args.output_dir}") # The N and message keywords are just to suppress any progressbar from model.test() test_kwds = dict(initialisations=args.initialisations, N=-1, message=None) # TODO: spread over threads? # For each input_path we must do the following: N_paths = len(args.input_paths) for i, input_path in enumerate(tqdm(args.input_paths, total=N_paths)): # 1. Load the spectra. # For some data models this could truly be a list of spectra of different sources. # But for most it will be a Spectrum1D that may have multiple visits and spectra that have # been combined in various ways. try: spectra = SpectrumList.read(input_path) except OSError: log.info(f"Exception raised when loading path {input_path}") continue if len(spectra) > 1: # The spectra are of different objects. This is the case for the MaStar spectral library. # TODO: Not sure if we *should* handle this yet. raise NotImplementedError("MaNGA MaStar spectra cannot be processed by this component yet") # TODO: allow spectrum index to be able to test on *all* spectra spectrum = spectra[0] N_spectra, N_pixels = spectrum.flux.shape # 2. Re-sample onto the model dispersion. # Re-sample onto the model dispersion. # TODO: put this into the cannon utils because it will be needed for # training flux = np.interp(model.dispersion, spectrum.wavelength.value, spectrum.flux.value[args.spectrum_index]) ivar = np.interp(model.dispersion, spectrum.wavelength.value, spectrum.uncertainty.array[args.spectrum_index]) # 3. Continuum-normalize if instructed. # TODO: refactor continuum normalization to deal with Spectrum1D objects. if continuum_kwds: norm_flux, norm_ivar, cont, meta = continuum.normalize( spectrum.wavelength.value, spectrum.flux.value[args.spectrum_index], spectrum.uncertainty.array[args.spectrum_index], **continuum_kwds) else: norm_flux, norm_ivar = (flux, ivar) # 4. Run the test step on the spectra. labels, cov, meta = model.test(norm_flux, norm_ivar, **test_kwds) # 5. Save the outputs. # TODO: We need a data model specification for this. log.info(f"Inferred labels: {labels}") log.info(f"Metadata: {meta}") log.error("Not saving output because no data model exists yet!") else: raise NotImplementedError("train or test. that's it.")
4884e627947c1a84244aa794d41b96402c958e6a
8ca19f1a31070738b376c0370c4bebf6b7efcb43
/office365/sharepoint/marketplace/corporatecuratedgallery/addins/permission_request.py
c469197f73d604628987ef49b387a4b49065b3f0
[ "MIT" ]
permissive
vgrem/Office365-REST-Python-Client
2ef153d737c6ed5445ba1e446aeaec39c4ef4ed3
cbd245d1af8d69e013c469cfc2a9851f51c91417
refs/heads/master
2023-09-02T14:20:40.109462
2023-08-31T19:14:05
2023-08-31T19:14:05
51,305,798
1,006
326
MIT
2023-08-28T05:38:02
2016-02-08T15:24:51
Python
UTF-8
Python
false
false
113
py
from office365.runtime.client_value import ClientValue class SPAddinPermissionRequest(ClientValue): """"""
65cdcdf0253ddb4b8e88d7d4ee6ec35326b939af
8e1844578805b43b7b5ef81b6a4efb85e5481af2
/sysfacts/api.py
0ea674167d2cec14bf352976739e2419bbfcdd07
[ "MIT" ]
permissive
pmav99/sysfacts
d73720c42d00b5d8327e483cef0221bacd13035e
09a5658a8f4e789db71844759dd4ae61369f4f4a
refs/heads/master
2020-04-17T14:08:13.182321
2019-01-25T20:20:36
2019-01-25T23:31:03
166,644,847
2
0
null
null
null
null
UTF-8
Python
false
false
1,442
py
# from __future__ import annotations import platform import cpuinfo # type: ignore import distro # type: ignore import pendulum # type: ignore import psutil # type: ignore # TODO @##@#$! mypy def _to_dict(named_tuple) -> dict: return dict(named_tuple._asdict()) def get_timestamp() -> str: return str(pendulum.now()) def get_os_release() -> dict: return distro.os_release_info() def get_lsb_release() -> dict: return distro.lsb_release_info() def get_distro_release() -> dict: return distro.distro_release_info() def get_uname() -> dict: return _to_dict(platform.uname()) def get_cpuinfo() -> dict: return cpuinfo.get_cpu_info() def get_memory_info() -> dict: return _to_dict(psutil.virtual_memory()) def get_swap_info() -> dict: return _to_dict(psutil.swap_memory()) def get_cpu_usage() -> dict: return _to_dict(psutil.cpu_times_percent()) def collect_facts() -> dict: """ Return a dictionary with data collected from various source. """ data: dict = { "timestamp": get_timestamp(), "os_release": get_os_release(), "lsb_release": get_lsb_release(), "distro_release": get_distro_release(), "uname": get_uname(), "cpu_info": get_cpuinfo(), "memory_info": get_memory_info(), "swap_info": get_swap_info(), "cpu_usage": get_cpu_usage(), } return data __all__ = ["collect_facts"]
07931e2f7377890e3555fc52ea41e287579a4de0
c62fc7366ba080c22d54249561ce572dee085f07
/tests/test_widget_selectdate.py
bc18260ede55a64d3e9fa4d93660e608ef939aa2
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
wendelas/django-material
9b69e7040e7279b88e45f82ad6aea33a46a82d02
e29d1568bd450a8066b637d0018a9bf07d2f7948
refs/heads/master
2021-01-13T15:45:24.107306
2015-12-31T02:19:17
2015-12-31T02:19:17
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,767
py
import json from django import forms from django.test.utils import override_settings from django_webtest import WebTest from . import build_test_urls try: from django.forms.widgets import SelectDateWidget except ImportError: # django 1.8 from django.forms.extras import SelectDateWidget class SelectForm(forms.Form): test_field = forms.DateField( widget=SelectDateWidget) data_field = forms.BooleanField(required=False, widget=forms.HiddenInput, initial=True, help_text='To produce non empty POST for empty test_field') @override_settings(ROOT_URLCONF=__name__) class Test(WebTest): default_form = SelectForm def test_default_usecase(self): page = self.app.get(self.test_default_usecase.url) self.assertIn('id="id_test_field_container"', page.body.decode('utf-8')) self.assertIn('id="id_test_field_year"', page.body.decode('utf-8')) self.assertIn('id="id_test_field_month"', page.body.decode('utf-8')) self.assertIn('id="id_test_field_day"', page.body.decode('utf-8')) # self.assertIn('data-test="Test Attr"', page.body.decode('utf-8')) form = page.form self.assertIn('test_field_year', form.fields) self.assertIn('test_field_month', form.fields) self.assertIn('test_field_day', form.fields) form['test_field_year'] = '2015' form['test_field_month'] = '1' form['test_field_day'] = '13' response = json.loads(form.submit().body.decode('utf-8')) self.assertIn('cleaned_data', response) self.assertIn('test_field', response['cleaned_data']) self.assertEquals('2015-01-13', response['cleaned_data']['test_field']) urlpatterns = build_test_urls(Test)
282f92d219f4319d4135b439015cae5d7125a0fa
80ac93cf96c5db72d1cd610585cf3243ec8565b1
/tensorflow_federated/python/core/impl/intrinsic_bodies.py
ec213bc691bf19f66e3dbbdf6b702e6311d6636c
[ "Apache-2.0" ]
permissive
KaiqiangQi/federated
6821ed387ce802dcb484054dd20ae2059b9c2a81
d8c402686766897c735e74731bd17b9df373b77f
refs/heads/master
2020-06-13T20:52:03.472327
2019-07-02T03:32:18
2019-07-02T03:32:52
null
0
0
null
null
null
null
UTF-8
Python
false
false
13,380
py
# Lint as: python3 # Copyright 2018, The TensorFlow Federated Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Bodies of intrinsics to be added as replacements by the compiler pipleine.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import collections import tensorflow as tf from tensorflow_federated.python.common_libs import anonymous_tuple from tensorflow_federated.python.common_libs import py_typecheck from tensorflow_federated.python.core.api import computation_types from tensorflow_federated.python.core.impl import computation_building_blocks from tensorflow_federated.python.core.impl import computation_constructing_utils from tensorflow_federated.python.core.impl import context_stack_base from tensorflow_federated.python.core.impl import intrinsic_defs from tensorflow_federated.python.core.impl import intrinsic_factory from tensorflow_federated.python.core.impl import intrinsic_utils from tensorflow_federated.python.core.impl import type_utils from tensorflow_federated.python.core.impl import value_impl def get_intrinsic_bodies(context_stack): """Returns a dictionary of intrinsic bodies. Args: context_stack: The context stack to use. """ py_typecheck.check_type(context_stack, context_stack_base.ContextStack) intrinsics = intrinsic_factory.IntrinsicFactory(context_stack) # TODO(b/122728050): Implement reductions that follow roughly the following # breakdown in order to minimize the number of intrinsics that backends need # to support and maximize opportunities for merging processing logic to keep # the number of communication phases as small as it is practical. Perform # these reductions before FEDERATED_SUM (more reductions documented below). # # - FEDERATED_AGGREGATE(x, zero, accu, merge, report) := # GENERIC_MAP( # GENERIC_REDUCE( # GENERIC_PARTIAL_REDUCE(x, zero, accu, INTERMEDIATE_AGGREGATORS), # zero, merge, SERVER), # report) # # - FEDERATED_APPLY(f, x) := GENERIC_APPLY(f, x) # # - FEDERATED_BROADCAST(x) := GENERIC_BROADCAST(x, CLIENTS) # # - FEDERATED_COLLECT(x) := GENERIC_COLLECT(x, SERVER) # # - FEDERATED_MAP(f, x) := GENERIC_MAP(f, x) # # - FEDERATED_VALUE_AT_CLIENTS(x) := GENERIC_PLACE(x, CLIENTS) # # - FEDERATED_VALUE_AT_SERVER(x) := GENERIC_PLACE(x, SERVER) # # - FEDERATED_MEAN(x) := FEDERATED_WEIGHTED_MEAN( # x, FEDERATED_VALUE_AT_CLIENTS(GENERIC_ONE)) # # - FEDERATED_WEIGHTED_MEAN(x, w) := # GENERIC_DIVIDE(FEDERATED_SUM(GENERIC_MULTIPLY(x, w)), w) def _pack_binary_operator_args(x, y): """Packs arguments to binary operator into a single arg.""" def _only_tuple_or_tensor(value): return type_utils.type_tree_contains_only( value.type_signature, (computation_types.NamedTupleType, computation_types.TensorType)) if _only_tuple_or_tensor(x) and _only_tuple_or_tensor(y): arg = value_impl.ValueImpl( computation_building_blocks.Tuple([ value_impl.ValueImpl.get_comp(x), value_impl.ValueImpl.get_comp(y) ]), context_stack) elif (isinstance(x.type_signature, computation_types.FederatedType) and isinstance(y.type_signature, computation_types.FederatedType) and x.type_signature.placement == y.type_signature.placement): if not type_utils.is_binary_op_with_upcast_compatible_pair( x.type_signature.member, y.type_signature.member): raise TypeError( 'The members of the federated types {} and {} are not division ' 'compatible; see `type_utils.is_binary_op_with_upcast_compatible_pair` ' 'for more details.'.format(x.type_signature, y.type_signature)) packed_arg = value_impl.ValueImpl( computation_building_blocks.Tuple([ value_impl.ValueImpl.get_comp(x), value_impl.ValueImpl.get_comp(y) ]), context_stack) arg = intrinsics.federated_zip(packed_arg) else: raise TypeError return arg def _check_top_level_compatibility_with_generic_operators(x, y, op_name): """Performs non-recursive check on the types of `x` and `y`.""" x_compatible = type_utils.type_tree_contains_only( x.type_signature, (computation_types.NamedTupleType, computation_types.TensorType, computation_types.FederatedType)) y_compatible = type_utils.type_tree_contains_only( y.type_signature, (computation_types.NamedTupleType, computation_types.TensorType, computation_types.FederatedType)) def _make_bad_type_tree_string(index, type_spec): return ('{} is only implemented for pairs of ' 'arguments both containing only federated, tuple and ' 'tensor types; you have passed argument at index {} of type {} ' .format(op_name, index, type_spec)) if not (x_compatible and y_compatible): if y_compatible: raise TypeError(_make_bad_type_tree_string(0, x.type_signature)) elif x_compatible: raise TypeError(_make_bad_type_tree_string(1, y.type_signature)) else: raise TypeError( '{} is only implemented for pairs of ' 'arguments both containing only federated, tuple and ' 'tensor types; both your arguments fail this condition. ' 'You have passed first argument of type {} ' 'and second argument of type {}.'.format(op_name, x.type_signature, y.type_signature)) top_level_mismatch_string = ( '{} does not accept arguments of type {} and ' '{}, as they are mismatched at the top level.'.format( x.type_signature, y.type_signature, op_name)) if isinstance(x.type_signature, computation_types.FederatedType): if (not isinstance(y.type_signature, computation_types.FederatedType) or x.type_signature.placement != y.type_signature.placement or x.type_signature.all_equal != y.type_signature.all_equal or not type_utils.is_binary_op_with_upcast_compatible_pair( x.type_signature.member, y.type_signature.member)): raise TypeError(top_level_mismatch_string) if isinstance(x.type_signature, computation_types.NamedTupleType): if not isinstance(y.type_signature, computation_types.NamedTupleType) or dir( x.type_signature) != dir(x.type_signature): raise TypeError(top_level_mismatch_string) def federated_weighted_mean(arg): w = arg[1] multiplied = generic_multiply(arg) summed = federated_sum(intrinsics.federated_zip([multiplied, w])) return generic_divide(summed) def federated_sum(x): zero = intrinsic_utils.zero_for(x.type_signature.member, context_stack) plus_op = value_impl.ValueImpl( intrinsic_utils.construct_binary_operator_with_upcast( computation_types.NamedTupleType( [x.type_signature.member, x.type_signature.member]), tf.add), context_stack) return federated_reduce([x, zero, plus_op]) def federated_reduce(arg): x = arg[0] zero = arg[1] op = arg[2] identity = computation_constructing_utils.construct_compiled_identity( op.type_signature.result) return intrinsics.federated_aggregate(x, zero, op, op, identity) def generic_divide(arg): """Divides two arguments when possible.""" x = arg[0] y = arg[1] _check_top_level_compatibility_with_generic_operators( x, y, 'Generic divide') if isinstance(x.type_signature, computation_types.NamedTupleType): # This case is needed if federated types are nested deeply. names = [t[0] for t in anonymous_tuple.to_elements(x.type_signature)] divided = [ value_impl.ValueImpl.get_comp(generic_divide([x[i], y[i]])) for i in range(len(names)) ] named_divided = computation_constructing_utils.create_named_tuple( computation_building_blocks.Tuple(divided), names) return value_impl.ValueImpl(named_divided, context_stack) arg = _pack_binary_operator_args(x, y) arg_comp = value_impl.ValueImpl.get_comp(arg) divided = intrinsic_utils.apply_binary_operator_with_upcast( arg_comp, tf.divide) return value_impl.ValueImpl(divided, context_stack) def generic_multiply(arg): """Multiplies two arguments when possible.""" x = arg[0] y = arg[1] _check_top_level_compatibility_with_generic_operators( x, y, 'Generic multiply') if isinstance(x.type_signature, computation_types.NamedTupleType): # This case is needed if federated types are nested deeply. names = [t[0] for t in anonymous_tuple.to_elements(x.type_signature)] multiplied = [ value_impl.ValueImpl.get_comp(generic_multiply([x[i], y[i]])) for i in range(len(names)) ] named_multiplied = computation_constructing_utils.create_named_tuple( computation_building_blocks.Tuple(multiplied), names) return value_impl.ValueImpl(named_multiplied, context_stack) arg = _pack_binary_operator_args(x, y) arg_comp = value_impl.ValueImpl.get_comp(arg) multiplied = intrinsic_utils.apply_binary_operator_with_upcast( arg_comp, tf.multiply) return value_impl.ValueImpl(multiplied, context_stack) def generic_plus(arg): """Adds two arguments when possible.""" x = arg[0] y = arg[1] _check_top_level_compatibility_with_generic_operators(x, y, 'Generic plus') if isinstance(x.type_signature, computation_types.NamedTupleType): # This case is needed if federated types are nested deeply. names = [t[0] for t in anonymous_tuple.to_elements(x.type_signature)] added = [ value_impl.ValueImpl.get_comp(generic_plus([x[i], y[i]])) for i in range(len(names)) ] named_added = computation_constructing_utils.create_named_tuple( computation_building_blocks.Tuple(added), names) return value_impl.ValueImpl(named_added, context_stack) arg = _pack_binary_operator_args(x, y) arg_comp = value_impl.ValueImpl.get_comp(arg) added = intrinsic_utils.apply_binary_operator_with_upcast(arg_comp, tf.add) return value_impl.ValueImpl(added, context_stack) # - FEDERATED_ZIP(x, y) := GENERIC_ZIP(x, y) # # - GENERIC_AVERAGE(x: {T}@p, q: placement) := # GENERIC_WEIGHTED_AVERAGE(x, GENERIC_ONE, q) # # - GENERIC_WEIGHTED_AVERAGE(x: {T}@p, w: {U}@p, q: placement) := # GENERIC_MAP(GENERIC_DIVIDE, GENERIC_SUM( # GENERIC_MAP(GENERIC_MULTIPLY, GENERIC_ZIP(x, w)), p)) # # NOTE: The above formula does not account for type casting issues that # arise due to the interplay betwen the types of values and weights and # how they relate to types of products and ratios, and either the formula # or the type signatures may need to be tweaked. # # - GENERIC_SUM(x: {T}@p, q: placement) := # GENERIC_REDUCE(x, GENERIC_ZERO, GENERIC_PLUS, q) # # - GENERIC_PARTIAL_SUM(x: {T}@p, q: placement) := # GENERIC_PARTIAL_REDUCE(x, GENERIC_ZERO, GENERIC_PLUS, q) # # - GENERIC_AGGREGATE( # x: {T}@p, zero: U, accu: <U,T>->U, merge: <U,U>=>U, report: U->R, # q: placement) := # GENERIC_MAP(report, GENERIC_REDUCE(x, zero, accu, q)) # # - GENERIC_REDUCE(x: {T}@p, zero: U, op: <U,T>->U, q: placement) := # GENERIC_MAP((a -> SEQUENCE_REDUCE(a, zero, op)), GENERIC_COLLECT(x, q)) # # - GENERIC_PARTIAL_REDUCE(x: {T}@p, zero: U, op: <U,T>->U, q: placement) := # GENERIC_MAP( # (a -> SEQUENCE_REDUCE(a, zero, op)), GENERIC_PARTIAL_COLLECT(x, q)) # # - SEQUENCE_SUM(x: T*) := # SEQUENCE_REDUCE(x, GENERIC_ZERO, GENERIC_PLUS) # # After performing the full set of reductions, we should only see instances # of the following intrinsics in the result, all of which are currently # considered non-reducible, and intrinsics such as GENERIC_PLUS should apply # only to non-federated, non-sequence types (with the appropriate calls to # GENERIC_MAP or SEQUENCE_MAP injected). # # - GENERIC_APPLY # - GENERIC_BROADCAST # - GENERIC_COLLECT # - GENERIC_DIVIDE # - GENERIC_MAP # - GENERIC_MULTIPLY # - GENERIC_ONE # - GENERIC_ONLY # - GENERIC_PARTIAL_COLLECT # - GENERIC_PLACE # - GENERIC_PLUS # - GENERIC_ZERO # - GENERIC_ZIP # - SEQUENCE_MAP # - SEQUENCE_REDUCE return collections.OrderedDict([ (intrinsic_defs.FEDERATED_WEIGHTED_MEAN.uri, federated_weighted_mean), (intrinsic_defs.FEDERATED_SUM.uri, federated_sum), (intrinsic_defs.GENERIC_DIVIDE.uri, generic_divide), (intrinsic_defs.GENERIC_MULTIPLY.uri, generic_multiply), (intrinsic_defs.GENERIC_PLUS.uri, generic_plus), ])
38b591a059118ab9ffeab0935c9478871024ae69
f4b60f5e49baf60976987946c20a8ebca4880602
/lib64/python2.7/site-packages/acimodel-1.3_2j-py2.7.egg/cobra/modelimpl/fv/rtmontofveppinbandevent.py
24b4d9e2fc69ef395df32b30f4c6e25c9bc538ef
[]
no_license
cqbomb/qytang_aci
12e508d54d9f774b537c33563762e694783d6ba8
a7fab9d6cda7fadcc995672e55c0ef7e7187696e
refs/heads/master
2022-12-21T13:30:05.240231
2018-12-04T01:46:53
2018-12-04T01:46:53
159,911,666
0
0
null
2022-12-07T23:53:02
2018-12-01T05:17:50
Python
UTF-8
Python
false
false
4,643
py
# coding=UTF-8 # ********************************************************************** # Copyright (c) 2013-2016 Cisco Systems, Inc. All rights reserved # written by zen warriors, do not modify! # ********************************************************************** from cobra.mit.meta import ClassMeta from cobra.mit.meta import StatsClassMeta from cobra.mit.meta import CounterMeta from cobra.mit.meta import PropMeta from cobra.mit.meta import Category from cobra.mit.meta import SourceRelationMeta from cobra.mit.meta import NamedSourceRelationMeta from cobra.mit.meta import TargetRelationMeta from cobra.mit.meta import DeploymentPathMeta, DeploymentCategory from cobra.model.category import MoCategory, PropCategory, CounterCategory from cobra.mit.mo import Mo # ################################################## class RtMonToFvEppInbandEvent(Mo): """ A target relation to the in-band management endpoint profile for a fabric node management endpoint group. """ meta = TargetRelationMeta("cobra.model.fv.RtMonToFvEppInbandEvent", "cobra.model.fault.RelnHolder") meta.moClassName = "fvRtMonToFvEppInbandEvent" meta.rnFormat = "rtfaultMonToFvEppInbandEvent-[%(tDn)s]" meta.category = MoCategory.RELATIONSHIP_FROM_LOCAL meta.label = "Policy holder container" meta.writeAccessMask = 0x1 meta.readAccessMask = 0x610021000683 meta.isDomainable = False meta.isReadOnly = True meta.isConfigurable = False meta.isDeletable = False meta.isContextRoot = False meta.parentClasses.add("cobra.model.fv.InBEpP") meta.superClasses.add("cobra.model.reln.From") meta.superClasses.add("cobra.model.reln.Inst") meta.rnPrefixes = [ ('rtfaultMonToFvEppInbandEvent-', True), ] prop = PropMeta("str", "childAction", "childAction", 4, PropCategory.CHILD_ACTION) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop._addConstant("deleteAll", "deleteall", 16384) prop._addConstant("deleteNonPresent", "deletenonpresent", 8192) prop._addConstant("ignore", "ignore", 4096) meta.props.add("childAction", prop) prop = PropMeta("str", "dn", "dn", 1, PropCategory.DN) prop.label = "None" prop.isDn = True prop.isImplicit = True prop.isAdmin = True prop.isCreateOnly = True meta.props.add("dn", prop) prop = PropMeta("str", "lcOwn", "lcOwn", 9, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 0 prop.defaultValueStr = "local" prop._addConstant("implicit", "implicit", 4) prop._addConstant("local", "local", 0) prop._addConstant("policy", "policy", 1) prop._addConstant("replica", "replica", 2) prop._addConstant("resolveOnBehalf", "resolvedonbehalf", 3) meta.props.add("lcOwn", prop) prop = PropMeta("str", "modTs", "modTs", 7, PropCategory.REGULAR) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 0 prop.defaultValueStr = "never" prop._addConstant("never", "never", 0) meta.props.add("modTs", prop) prop = PropMeta("str", "rn", "rn", 2, PropCategory.RN) prop.label = "None" prop.isRn = True prop.isImplicit = True prop.isAdmin = True prop.isCreateOnly = True meta.props.add("rn", prop) prop = PropMeta("str", "status", "status", 3, PropCategory.STATUS) prop.label = "None" prop.isImplicit = True prop.isAdmin = True prop._addConstant("created", "created", 2) prop._addConstant("deleted", "deleted", 8) prop._addConstant("modified", "modified", 4) meta.props.add("status", prop) prop = PropMeta("str", "tCl", "tCl", 16192, PropCategory.REGULAR) prop.label = "Target-class" prop.isImplicit = True prop.isAdmin = True prop.defaultValue = 5512 prop.defaultValueStr = "faultRelnHolder" prop._addConstant("faultRelnHolder", None, 5512) prop._addConstant("unspecified", "unspecified", 0) meta.props.add("tCl", prop) prop = PropMeta("str", "tDn", "tDn", 16191, PropCategory.REGULAR) prop.label = "Target-dn" prop.isConfig = True prop.isAdmin = True prop.isCreateOnly = True prop.isNaming = True meta.props.add("tDn", prop) meta.namingProps.append(getattr(meta.props, "tDn")) getattr(meta.props, "tDn").needDelimiter = True def __init__(self, parentMoOrDn, tDn, markDirty=True, **creationProps): namingVals = [tDn] Mo.__init__(self, parentMoOrDn, markDirty, *namingVals, **creationProps) # End of package file # ##################################################