├── .gitignore ├── LICENSE ├── PB ├── AccountSupervisorService.py ├── AgeCheckService.py ├── AuthService.py ├── BuddyManagementService.py ├── BuddyService.py ├── CallService.py ├── ChannelApplicationProvidedService.py ├── ChannelService.py ├── MessageService.py ├── ShopService.py ├── SnsAdaptorService.py ├── SquareService.py ├── TalkService.py ├── UniversalNotificationService.py ├── __init__.py ├── __pycache__ │ ├── CallService.cpython-34.pyc │ ├── CallService.cpython-35.pyc │ ├── CallService.cpython-36.pyc │ ├── ChannelService.cpython-34.pyc │ ├── ChannelService.cpython-35.pyc │ ├── ChannelService.cpython-36.pyc │ ├── TalkService.cpython-34.pyc │ ├── TalkService.cpython-35.pyc │ ├── TalkService.cpython-36.pyc │ ├── __init__.cpython-34.pyc │ ├── __init__.cpython-35.pyc │ ├── __init__.cpython-36.pyc │ ├── ttypes.cpython-34.pyc │ ├── ttypes.cpython-35.pyc │ └── ttypes.cpython-36.pyc ├── constants.py └── ttypes.py ├── PRANKBOTS ├── __init__.py ├── __pycache__ │ ├── Acil │ ├── __init__.cpython-34.pyc │ ├── __init__.cpython-35.pyc │ ├── __init__.cpython-36.pyc │ ├── __init__.cpython-37.pyc │ ├── api.cpython-34.pyc │ ├── api.cpython-35.pyc │ ├── api.cpython-36.pyc │ ├── api.cpython-37.pyc │ ├── call.cpython-34.pyc │ ├── call.cpython-35.pyc │ ├── call.cpython-36.pyc │ ├── call.cpython-37.pyc │ ├── callback.cpython-34.pyc │ ├── callback.cpython-35.pyc │ ├── callback.cpython-36.pyc │ ├── callback.cpython-37.pyc │ ├── channel.cpython-34.pyc │ ├── channel.cpython-35.pyc │ ├── channel.cpython-36.pyc │ ├── channel.cpython-37.pyc │ ├── client.cpython-34.pyc │ ├── client.cpython-35.pyc │ ├── client.cpython-36.pyc │ ├── client.cpython-37.pyc │ ├── models.cpython-34.pyc │ ├── models.cpython-35.pyc │ ├── models.cpython-36.pyc │ ├── models.cpython-37.pyc │ ├── object.cpython-34.pyc │ ├── object.cpython-35.pyc │ ├── object.cpython-36.pyc │ ├── object.cpython-37.pyc │ ├── poll.cpython-34.pyc │ ├── poll.cpython-35.pyc │ ├── poll.cpython-36.pyc │ ├── poll.cpython-37.pyc │ ├── server.cpython-34.pyc │ ├── server.cpython-35.pyc │ ├── server.cpython-36.pyc │ ├── server.cpython-37.pyc │ ├── session.cpython-34.pyc │ ├── session.cpython-35.pyc │ ├── session.cpython-36.pyc │ ├── session.cpython-37.pyc │ ├── timeline.cpython-34.pyc │ ├── timeline.cpython-35.pyc │ ├── timeline.cpython-36.pyc │ └── timeline.cpython-37.pyc ├── api.py ├── call.py ├── callback.py ├── channel.py ├── client.py ├── models.py ├── object.py ├── poll.py ├── server.py ├── session.py └── timeline.py ├── README.md ├── prankbots.json ├── prankbots.png └── prankpy3.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /PB/AgeCheckService.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.10.0) 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | # options string: py 7 | # 8 | 9 | from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException 10 | from thrift.protocol.TProtocol import TProtocolException 11 | import sys 12 | import logging 13 | from .ttypes import * 14 | from thrift.Thrift import TProcessor 15 | from thrift.transport import TTransport 16 | 17 | 18 | class Iface(object): 19 | def checkUserAge(self, carrier, sessionId, verifier, standardAge): 20 | """ 21 | Parameters: 22 | - carrier 23 | - sessionId 24 | - verifier 25 | - standardAge 26 | """ 27 | pass 28 | 29 | def checkUserAgeWithDocomo(self, openIdRedirectUrl, standardAge, verifier): 30 | """ 31 | Parameters: 32 | - openIdRedirectUrl 33 | - standardAge 34 | - verifier 35 | """ 36 | pass 37 | 38 | def retrieveOpenIdAuthUrlWithDocomo(self): 39 | pass 40 | 41 | def retrieveRequestToken(self, carrier): 42 | """ 43 | Parameters: 44 | - carrier 45 | """ 46 | pass 47 | 48 | 49 | class Client(Iface): 50 | def __init__(self, iprot, oprot=None): 51 | self._iprot = self._oprot = iprot 52 | if oprot is not None: 53 | self._oprot = oprot 54 | self._seqid = 0 55 | 56 | def checkUserAge(self, carrier, sessionId, verifier, standardAge): 57 | """ 58 | Parameters: 59 | - carrier 60 | - sessionId 61 | - verifier 62 | - standardAge 63 | """ 64 | self.send_checkUserAge(carrier, sessionId, verifier, standardAge) 65 | return self.recv_checkUserAge() 66 | 67 | def send_checkUserAge(self, carrier, sessionId, verifier, standardAge): 68 | self._oprot.writeMessageBegin('checkUserAge', TMessageType.CALL, self._seqid) 69 | args = checkUserAge_args() 70 | args.carrier = carrier 71 | args.sessionId = sessionId 72 | args.verifier = verifier 73 | args.standardAge = standardAge 74 | args.write(self._oprot) 75 | self._oprot.writeMessageEnd() 76 | self._oprot.trans.flush() 77 | 78 | def recv_checkUserAge(self): 79 | iprot = self._iprot 80 | (fname, mtype, rseqid) = iprot.readMessageBegin() 81 | if mtype == TMessageType.EXCEPTION: 82 | x = TApplicationException() 83 | x.read(iprot) 84 | iprot.readMessageEnd() 85 | raise x 86 | result = checkUserAge_result() 87 | result.read(iprot) 88 | iprot.readMessageEnd() 89 | if result.success is not None: 90 | return result.success 91 | if result.e is not None: 92 | raise result.e 93 | raise TApplicationException(TApplicationException.MISSING_RESULT, "checkUserAge failed: unknown result") 94 | 95 | def checkUserAgeWithDocomo(self, openIdRedirectUrl, standardAge, verifier): 96 | """ 97 | Parameters: 98 | - openIdRedirectUrl 99 | - standardAge 100 | - verifier 101 | """ 102 | self.send_checkUserAgeWithDocomo(openIdRedirectUrl, standardAge, verifier) 103 | return self.recv_checkUserAgeWithDocomo() 104 | 105 | def send_checkUserAgeWithDocomo(self, openIdRedirectUrl, standardAge, verifier): 106 | self._oprot.writeMessageBegin('checkUserAgeWithDocomo', TMessageType.CALL, self._seqid) 107 | args = checkUserAgeWithDocomo_args() 108 | args.openIdRedirectUrl = openIdRedirectUrl 109 | args.standardAge = standardAge 110 | args.verifier = verifier 111 | args.write(self._oprot) 112 | self._oprot.writeMessageEnd() 113 | self._oprot.trans.flush() 114 | 115 | def recv_checkUserAgeWithDocomo(self): 116 | iprot = self._iprot 117 | (fname, mtype, rseqid) = iprot.readMessageBegin() 118 | if mtype == TMessageType.EXCEPTION: 119 | x = TApplicationException() 120 | x.read(iprot) 121 | iprot.readMessageEnd() 122 | raise x 123 | result = checkUserAgeWithDocomo_result() 124 | result.read(iprot) 125 | iprot.readMessageEnd() 126 | if result.success is not None: 127 | return result.success 128 | if result.e is not None: 129 | raise result.e 130 | raise TApplicationException(TApplicationException.MISSING_RESULT, "checkUserAgeWithDocomo failed: unknown result") 131 | 132 | def retrieveOpenIdAuthUrlWithDocomo(self): 133 | self.send_retrieveOpenIdAuthUrlWithDocomo() 134 | return self.recv_retrieveOpenIdAuthUrlWithDocomo() 135 | 136 | def send_retrieveOpenIdAuthUrlWithDocomo(self): 137 | self._oprot.writeMessageBegin('retrieveOpenIdAuthUrlWithDocomo', TMessageType.CALL, self._seqid) 138 | args = retrieveOpenIdAuthUrlWithDocomo_args() 139 | args.write(self._oprot) 140 | self._oprot.writeMessageEnd() 141 | self._oprot.trans.flush() 142 | 143 | def recv_retrieveOpenIdAuthUrlWithDocomo(self): 144 | iprot = self._iprot 145 | (fname, mtype, rseqid) = iprot.readMessageBegin() 146 | if mtype == TMessageType.EXCEPTION: 147 | x = TApplicationException() 148 | x.read(iprot) 149 | iprot.readMessageEnd() 150 | raise x 151 | result = retrieveOpenIdAuthUrlWithDocomo_result() 152 | result.read(iprot) 153 | iprot.readMessageEnd() 154 | if result.success is not None: 155 | return result.success 156 | if result.e is not None: 157 | raise result.e 158 | raise TApplicationException(TApplicationException.MISSING_RESULT, "retrieveOpenIdAuthUrlWithDocomo failed: unknown result") 159 | 160 | def retrieveRequestToken(self, carrier): 161 | """ 162 | Parameters: 163 | - carrier 164 | """ 165 | self.send_retrieveRequestToken(carrier) 166 | return self.recv_retrieveRequestToken() 167 | 168 | def send_retrieveRequestToken(self, carrier): 169 | self._oprot.writeMessageBegin('retrieveRequestToken', TMessageType.CALL, self._seqid) 170 | args = retrieveRequestToken_args() 171 | args.carrier = carrier 172 | args.write(self._oprot) 173 | self._oprot.writeMessageEnd() 174 | self._oprot.trans.flush() 175 | 176 | def recv_retrieveRequestToken(self): 177 | iprot = self._iprot 178 | (fname, mtype, rseqid) = iprot.readMessageBegin() 179 | if mtype == TMessageType.EXCEPTION: 180 | x = TApplicationException() 181 | x.read(iprot) 182 | iprot.readMessageEnd() 183 | raise x 184 | result = retrieveRequestToken_result() 185 | result.read(iprot) 186 | iprot.readMessageEnd() 187 | if result.success is not None: 188 | return result.success 189 | if result.e is not None: 190 | raise result.e 191 | raise TApplicationException(TApplicationException.MISSING_RESULT, "retrieveRequestToken failed: unknown result") 192 | 193 | 194 | class Processor(Iface, TProcessor): 195 | def __init__(self, handler): 196 | self._handler = handler 197 | self._processMap = {} 198 | self._processMap["checkUserAge"] = Processor.process_checkUserAge 199 | self._processMap["checkUserAgeWithDocomo"] = Processor.process_checkUserAgeWithDocomo 200 | self._processMap["retrieveOpenIdAuthUrlWithDocomo"] = Processor.process_retrieveOpenIdAuthUrlWithDocomo 201 | self._processMap["retrieveRequestToken"] = Processor.process_retrieveRequestToken 202 | 203 | def process(self, iprot, oprot): 204 | (name, type, seqid) = iprot.readMessageBegin() 205 | if name not in self._processMap: 206 | iprot.skip(TType.STRUCT) 207 | iprot.readMessageEnd() 208 | x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) 209 | oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) 210 | x.write(oprot) 211 | oprot.writeMessageEnd() 212 | oprot.trans.flush() 213 | return 214 | else: 215 | self._processMap[name](self, seqid, iprot, oprot) 216 | return True 217 | 218 | def process_checkUserAge(self, seqid, iprot, oprot): 219 | args = checkUserAge_args() 220 | args.read(iprot) 221 | iprot.readMessageEnd() 222 | result = checkUserAge_result() 223 | try: 224 | result.success = self._handler.checkUserAge(args.carrier, args.sessionId, args.verifier, args.standardAge) 225 | msg_type = TMessageType.REPLY 226 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 227 | raise 228 | except TalkException as e: 229 | msg_type = TMessageType.REPLY 230 | result.e = e 231 | except Exception as ex: 232 | msg_type = TMessageType.EXCEPTION 233 | logging.exception(ex) 234 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 235 | oprot.writeMessageBegin("checkUserAge", msg_type, seqid) 236 | result.write(oprot) 237 | oprot.writeMessageEnd() 238 | oprot.trans.flush() 239 | 240 | def process_checkUserAgeWithDocomo(self, seqid, iprot, oprot): 241 | args = checkUserAgeWithDocomo_args() 242 | args.read(iprot) 243 | iprot.readMessageEnd() 244 | result = checkUserAgeWithDocomo_result() 245 | try: 246 | result.success = self._handler.checkUserAgeWithDocomo(args.openIdRedirectUrl, args.standardAge, args.verifier) 247 | msg_type = TMessageType.REPLY 248 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 249 | raise 250 | except TalkException as e: 251 | msg_type = TMessageType.REPLY 252 | result.e = e 253 | except Exception as ex: 254 | msg_type = TMessageType.EXCEPTION 255 | logging.exception(ex) 256 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 257 | oprot.writeMessageBegin("checkUserAgeWithDocomo", msg_type, seqid) 258 | result.write(oprot) 259 | oprot.writeMessageEnd() 260 | oprot.trans.flush() 261 | 262 | def process_retrieveOpenIdAuthUrlWithDocomo(self, seqid, iprot, oprot): 263 | args = retrieveOpenIdAuthUrlWithDocomo_args() 264 | args.read(iprot) 265 | iprot.readMessageEnd() 266 | result = retrieveOpenIdAuthUrlWithDocomo_result() 267 | try: 268 | result.success = self._handler.retrieveOpenIdAuthUrlWithDocomo() 269 | msg_type = TMessageType.REPLY 270 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 271 | raise 272 | except TalkException as e: 273 | msg_type = TMessageType.REPLY 274 | result.e = e 275 | except Exception as ex: 276 | msg_type = TMessageType.EXCEPTION 277 | logging.exception(ex) 278 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 279 | oprot.writeMessageBegin("retrieveOpenIdAuthUrlWithDocomo", msg_type, seqid) 280 | result.write(oprot) 281 | oprot.writeMessageEnd() 282 | oprot.trans.flush() 283 | 284 | def process_retrieveRequestToken(self, seqid, iprot, oprot): 285 | args = retrieveRequestToken_args() 286 | args.read(iprot) 287 | iprot.readMessageEnd() 288 | result = retrieveRequestToken_result() 289 | try: 290 | result.success = self._handler.retrieveRequestToken(args.carrier) 291 | msg_type = TMessageType.REPLY 292 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 293 | raise 294 | except TalkException as e: 295 | msg_type = TMessageType.REPLY 296 | result.e = e 297 | except Exception as ex: 298 | msg_type = TMessageType.EXCEPTION 299 | logging.exception(ex) 300 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 301 | oprot.writeMessageBegin("retrieveRequestToken", msg_type, seqid) 302 | result.write(oprot) 303 | oprot.writeMessageEnd() 304 | oprot.trans.flush() 305 | 306 | # HELPER FUNCTIONS AND STRUCTURES 307 | 308 | 309 | class checkUserAge_args(object): 310 | """ 311 | Attributes: 312 | - carrier 313 | - sessionId 314 | - verifier 315 | - standardAge 316 | """ 317 | 318 | thrift_spec = ( 319 | None, # 0 320 | None, # 1 321 | (2, TType.I32, 'carrier', None, None, ), # 2 322 | (3, TType.STRING, 'sessionId', 'UTF8', None, ), # 3 323 | (4, TType.STRING, 'verifier', 'UTF8', None, ), # 4 324 | (5, TType.I32, 'standardAge', None, None, ), # 5 325 | ) 326 | 327 | def __init__(self, carrier=None, sessionId=None, verifier=None, standardAge=None,): 328 | self.carrier = carrier 329 | self.sessionId = sessionId 330 | self.verifier = verifier 331 | self.standardAge = standardAge 332 | 333 | def read(self, iprot): 334 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 335 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 336 | return 337 | iprot.readStructBegin() 338 | while True: 339 | (fname, ftype, fid) = iprot.readFieldBegin() 340 | if ftype == TType.STOP: 341 | break 342 | if fid == 2: 343 | if ftype == TType.I32: 344 | self.carrier = iprot.readI32() 345 | else: 346 | iprot.skip(ftype) 347 | elif fid == 3: 348 | if ftype == TType.STRING: 349 | self.sessionId = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 350 | else: 351 | iprot.skip(ftype) 352 | elif fid == 4: 353 | if ftype == TType.STRING: 354 | self.verifier = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 355 | else: 356 | iprot.skip(ftype) 357 | elif fid == 5: 358 | if ftype == TType.I32: 359 | self.standardAge = iprot.readI32() 360 | else: 361 | iprot.skip(ftype) 362 | else: 363 | iprot.skip(ftype) 364 | iprot.readFieldEnd() 365 | iprot.readStructEnd() 366 | 367 | def write(self, oprot): 368 | if oprot._fast_encode is not None and self.thrift_spec is not None: 369 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 370 | return 371 | oprot.writeStructBegin('checkUserAge_args') 372 | if self.carrier is not None: 373 | oprot.writeFieldBegin('carrier', TType.I32, 2) 374 | oprot.writeI32(self.carrier) 375 | oprot.writeFieldEnd() 376 | if self.sessionId is not None: 377 | oprot.writeFieldBegin('sessionId', TType.STRING, 3) 378 | oprot.writeString(self.sessionId.encode('utf-8') if sys.version_info[0] == 2 else self.sessionId) 379 | oprot.writeFieldEnd() 380 | if self.verifier is not None: 381 | oprot.writeFieldBegin('verifier', TType.STRING, 4) 382 | oprot.writeString(self.verifier.encode('utf-8') if sys.version_info[0] == 2 else self.verifier) 383 | oprot.writeFieldEnd() 384 | if self.standardAge is not None: 385 | oprot.writeFieldBegin('standardAge', TType.I32, 5) 386 | oprot.writeI32(self.standardAge) 387 | oprot.writeFieldEnd() 388 | oprot.writeFieldStop() 389 | oprot.writeStructEnd() 390 | 391 | def validate(self): 392 | return 393 | 394 | def __repr__(self): 395 | L = ['%s=%r' % (key, value) 396 | for key, value in self.__dict__.items()] 397 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 398 | 399 | def __eq__(self, other): 400 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 401 | 402 | def __ne__(self, other): 403 | return not (self == other) 404 | 405 | 406 | class checkUserAge_result(object): 407 | """ 408 | Attributes: 409 | - success 410 | - e 411 | """ 412 | 413 | thrift_spec = ( 414 | (0, TType.I32, 'success', None, None, ), # 0 415 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 416 | ) 417 | 418 | def __init__(self, success=None, e=None,): 419 | self.success = success 420 | self.e = e 421 | 422 | def read(self, iprot): 423 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 424 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 425 | return 426 | iprot.readStructBegin() 427 | while True: 428 | (fname, ftype, fid) = iprot.readFieldBegin() 429 | if ftype == TType.STOP: 430 | break 431 | if fid == 0: 432 | if ftype == TType.I32: 433 | self.success = iprot.readI32() 434 | else: 435 | iprot.skip(ftype) 436 | elif fid == 1: 437 | if ftype == TType.STRUCT: 438 | self.e = TalkException() 439 | self.e.read(iprot) 440 | else: 441 | iprot.skip(ftype) 442 | else: 443 | iprot.skip(ftype) 444 | iprot.readFieldEnd() 445 | iprot.readStructEnd() 446 | 447 | def write(self, oprot): 448 | if oprot._fast_encode is not None and self.thrift_spec is not None: 449 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 450 | return 451 | oprot.writeStructBegin('checkUserAge_result') 452 | if self.success is not None: 453 | oprot.writeFieldBegin('success', TType.I32, 0) 454 | oprot.writeI32(self.success) 455 | oprot.writeFieldEnd() 456 | if self.e is not None: 457 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 458 | self.e.write(oprot) 459 | oprot.writeFieldEnd() 460 | oprot.writeFieldStop() 461 | oprot.writeStructEnd() 462 | 463 | def validate(self): 464 | return 465 | 466 | def __repr__(self): 467 | L = ['%s=%r' % (key, value) 468 | for key, value in self.__dict__.items()] 469 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 470 | 471 | def __eq__(self, other): 472 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 473 | 474 | def __ne__(self, other): 475 | return not (self == other) 476 | 477 | 478 | class checkUserAgeWithDocomo_args(object): 479 | """ 480 | Attributes: 481 | - openIdRedirectUrl 482 | - standardAge 483 | - verifier 484 | """ 485 | 486 | thrift_spec = ( 487 | None, # 0 488 | None, # 1 489 | (2, TType.STRING, 'openIdRedirectUrl', 'UTF8', None, ), # 2 490 | (3, TType.I32, 'standardAge', None, None, ), # 3 491 | (4, TType.STRING, 'verifier', 'UTF8', None, ), # 4 492 | ) 493 | 494 | def __init__(self, openIdRedirectUrl=None, standardAge=None, verifier=None,): 495 | self.openIdRedirectUrl = openIdRedirectUrl 496 | self.standardAge = standardAge 497 | self.verifier = verifier 498 | 499 | def read(self, iprot): 500 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 501 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 502 | return 503 | iprot.readStructBegin() 504 | while True: 505 | (fname, ftype, fid) = iprot.readFieldBegin() 506 | if ftype == TType.STOP: 507 | break 508 | if fid == 2: 509 | if ftype == TType.STRING: 510 | self.openIdRedirectUrl = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 511 | else: 512 | iprot.skip(ftype) 513 | elif fid == 3: 514 | if ftype == TType.I32: 515 | self.standardAge = iprot.readI32() 516 | else: 517 | iprot.skip(ftype) 518 | elif fid == 4: 519 | if ftype == TType.STRING: 520 | self.verifier = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 521 | else: 522 | iprot.skip(ftype) 523 | else: 524 | iprot.skip(ftype) 525 | iprot.readFieldEnd() 526 | iprot.readStructEnd() 527 | 528 | def write(self, oprot): 529 | if oprot._fast_encode is not None and self.thrift_spec is not None: 530 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 531 | return 532 | oprot.writeStructBegin('checkUserAgeWithDocomo_args') 533 | if self.openIdRedirectUrl is not None: 534 | oprot.writeFieldBegin('openIdRedirectUrl', TType.STRING, 2) 535 | oprot.writeString(self.openIdRedirectUrl.encode('utf-8') if sys.version_info[0] == 2 else self.openIdRedirectUrl) 536 | oprot.writeFieldEnd() 537 | if self.standardAge is not None: 538 | oprot.writeFieldBegin('standardAge', TType.I32, 3) 539 | oprot.writeI32(self.standardAge) 540 | oprot.writeFieldEnd() 541 | if self.verifier is not None: 542 | oprot.writeFieldBegin('verifier', TType.STRING, 4) 543 | oprot.writeString(self.verifier.encode('utf-8') if sys.version_info[0] == 2 else self.verifier) 544 | oprot.writeFieldEnd() 545 | oprot.writeFieldStop() 546 | oprot.writeStructEnd() 547 | 548 | def validate(self): 549 | return 550 | 551 | def __repr__(self): 552 | L = ['%s=%r' % (key, value) 553 | for key, value in self.__dict__.items()] 554 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 555 | 556 | def __eq__(self, other): 557 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 558 | 559 | def __ne__(self, other): 560 | return not (self == other) 561 | 562 | 563 | class checkUserAgeWithDocomo_result(object): 564 | """ 565 | Attributes: 566 | - success 567 | - e 568 | """ 569 | 570 | thrift_spec = ( 571 | (0, TType.STRUCT, 'success', (AgeCheckDocomoResult, AgeCheckDocomoResult.thrift_spec), None, ), # 0 572 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 573 | ) 574 | 575 | def __init__(self, success=None, e=None,): 576 | self.success = success 577 | self.e = e 578 | 579 | def read(self, iprot): 580 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 581 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 582 | return 583 | iprot.readStructBegin() 584 | while True: 585 | (fname, ftype, fid) = iprot.readFieldBegin() 586 | if ftype == TType.STOP: 587 | break 588 | if fid == 0: 589 | if ftype == TType.STRUCT: 590 | self.success = AgeCheckDocomoResult() 591 | self.success.read(iprot) 592 | else: 593 | iprot.skip(ftype) 594 | elif fid == 1: 595 | if ftype == TType.STRUCT: 596 | self.e = TalkException() 597 | self.e.read(iprot) 598 | else: 599 | iprot.skip(ftype) 600 | else: 601 | iprot.skip(ftype) 602 | iprot.readFieldEnd() 603 | iprot.readStructEnd() 604 | 605 | def write(self, oprot): 606 | if oprot._fast_encode is not None and self.thrift_spec is not None: 607 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 608 | return 609 | oprot.writeStructBegin('checkUserAgeWithDocomo_result') 610 | if self.success is not None: 611 | oprot.writeFieldBegin('success', TType.STRUCT, 0) 612 | self.success.write(oprot) 613 | oprot.writeFieldEnd() 614 | if self.e is not None: 615 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 616 | self.e.write(oprot) 617 | oprot.writeFieldEnd() 618 | oprot.writeFieldStop() 619 | oprot.writeStructEnd() 620 | 621 | def validate(self): 622 | return 623 | 624 | def __repr__(self): 625 | L = ['%s=%r' % (key, value) 626 | for key, value in self.__dict__.items()] 627 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 628 | 629 | def __eq__(self, other): 630 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 631 | 632 | def __ne__(self, other): 633 | return not (self == other) 634 | 635 | 636 | class retrieveOpenIdAuthUrlWithDocomo_args(object): 637 | 638 | thrift_spec = ( 639 | ) 640 | 641 | def read(self, iprot): 642 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 643 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 644 | return 645 | iprot.readStructBegin() 646 | while True: 647 | (fname, ftype, fid) = iprot.readFieldBegin() 648 | if ftype == TType.STOP: 649 | break 650 | else: 651 | iprot.skip(ftype) 652 | iprot.readFieldEnd() 653 | iprot.readStructEnd() 654 | 655 | def write(self, oprot): 656 | if oprot._fast_encode is not None and self.thrift_spec is not None: 657 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 658 | return 659 | oprot.writeStructBegin('retrieveOpenIdAuthUrlWithDocomo_args') 660 | oprot.writeFieldStop() 661 | oprot.writeStructEnd() 662 | 663 | def validate(self): 664 | return 665 | 666 | def __repr__(self): 667 | L = ['%s=%r' % (key, value) 668 | for key, value in self.__dict__.items()] 669 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 670 | 671 | def __eq__(self, other): 672 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 673 | 674 | def __ne__(self, other): 675 | return not (self == other) 676 | 677 | 678 | class retrieveOpenIdAuthUrlWithDocomo_result(object): 679 | """ 680 | Attributes: 681 | - success 682 | - e 683 | """ 684 | 685 | thrift_spec = ( 686 | (0, TType.STRING, 'success', 'UTF8', None, ), # 0 687 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 688 | ) 689 | 690 | def __init__(self, success=None, e=None,): 691 | self.success = success 692 | self.e = e 693 | 694 | def read(self, iprot): 695 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 696 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 697 | return 698 | iprot.readStructBegin() 699 | while True: 700 | (fname, ftype, fid) = iprot.readFieldBegin() 701 | if ftype == TType.STOP: 702 | break 703 | if fid == 0: 704 | if ftype == TType.STRING: 705 | self.success = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 706 | else: 707 | iprot.skip(ftype) 708 | elif fid == 1: 709 | if ftype == TType.STRUCT: 710 | self.e = TalkException() 711 | self.e.read(iprot) 712 | else: 713 | iprot.skip(ftype) 714 | else: 715 | iprot.skip(ftype) 716 | iprot.readFieldEnd() 717 | iprot.readStructEnd() 718 | 719 | def write(self, oprot): 720 | if oprot._fast_encode is not None and self.thrift_spec is not None: 721 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 722 | return 723 | oprot.writeStructBegin('retrieveOpenIdAuthUrlWithDocomo_result') 724 | if self.success is not None: 725 | oprot.writeFieldBegin('success', TType.STRING, 0) 726 | oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) 727 | oprot.writeFieldEnd() 728 | if self.e is not None: 729 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 730 | self.e.write(oprot) 731 | oprot.writeFieldEnd() 732 | oprot.writeFieldStop() 733 | oprot.writeStructEnd() 734 | 735 | def validate(self): 736 | return 737 | 738 | def __repr__(self): 739 | L = ['%s=%r' % (key, value) 740 | for key, value in self.__dict__.items()] 741 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 742 | 743 | def __eq__(self, other): 744 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 745 | 746 | def __ne__(self, other): 747 | return not (self == other) 748 | 749 | 750 | class retrieveRequestToken_args(object): 751 | """ 752 | Attributes: 753 | - carrier 754 | """ 755 | 756 | thrift_spec = ( 757 | None, # 0 758 | None, # 1 759 | (2, TType.I32, 'carrier', None, None, ), # 2 760 | ) 761 | 762 | def __init__(self, carrier=None,): 763 | self.carrier = carrier 764 | 765 | def read(self, iprot): 766 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 767 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 768 | return 769 | iprot.readStructBegin() 770 | while True: 771 | (fname, ftype, fid) = iprot.readFieldBegin() 772 | if ftype == TType.STOP: 773 | break 774 | if fid == 2: 775 | if ftype == TType.I32: 776 | self.carrier = iprot.readI32() 777 | else: 778 | iprot.skip(ftype) 779 | else: 780 | iprot.skip(ftype) 781 | iprot.readFieldEnd() 782 | iprot.readStructEnd() 783 | 784 | def write(self, oprot): 785 | if oprot._fast_encode is not None and self.thrift_spec is not None: 786 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 787 | return 788 | oprot.writeStructBegin('retrieveRequestToken_args') 789 | if self.carrier is not None: 790 | oprot.writeFieldBegin('carrier', TType.I32, 2) 791 | oprot.writeI32(self.carrier) 792 | oprot.writeFieldEnd() 793 | oprot.writeFieldStop() 794 | oprot.writeStructEnd() 795 | 796 | def validate(self): 797 | return 798 | 799 | def __repr__(self): 800 | L = ['%s=%r' % (key, value) 801 | for key, value in self.__dict__.items()] 802 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 803 | 804 | def __eq__(self, other): 805 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 806 | 807 | def __ne__(self, other): 808 | return not (self == other) 809 | 810 | 811 | class retrieveRequestToken_result(object): 812 | """ 813 | Attributes: 814 | - success 815 | - e 816 | """ 817 | 818 | thrift_spec = ( 819 | (0, TType.STRUCT, 'success', (AgeCheckRequestResult, AgeCheckRequestResult.thrift_spec), None, ), # 0 820 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 821 | ) 822 | 823 | def __init__(self, success=None, e=None,): 824 | self.success = success 825 | self.e = e 826 | 827 | def read(self, iprot): 828 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 829 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 830 | return 831 | iprot.readStructBegin() 832 | while True: 833 | (fname, ftype, fid) = iprot.readFieldBegin() 834 | if ftype == TType.STOP: 835 | break 836 | if fid == 0: 837 | if ftype == TType.STRUCT: 838 | self.success = AgeCheckRequestResult() 839 | self.success.read(iprot) 840 | else: 841 | iprot.skip(ftype) 842 | elif fid == 1: 843 | if ftype == TType.STRUCT: 844 | self.e = TalkException() 845 | self.e.read(iprot) 846 | else: 847 | iprot.skip(ftype) 848 | else: 849 | iprot.skip(ftype) 850 | iprot.readFieldEnd() 851 | iprot.readStructEnd() 852 | 853 | def write(self, oprot): 854 | if oprot._fast_encode is not None and self.thrift_spec is not None: 855 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 856 | return 857 | oprot.writeStructBegin('retrieveRequestToken_result') 858 | if self.success is not None: 859 | oprot.writeFieldBegin('success', TType.STRUCT, 0) 860 | self.success.write(oprot) 861 | oprot.writeFieldEnd() 862 | if self.e is not None: 863 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 864 | self.e.write(oprot) 865 | oprot.writeFieldEnd() 866 | oprot.writeFieldStop() 867 | oprot.writeStructEnd() 868 | 869 | def validate(self): 870 | return 871 | 872 | def __repr__(self): 873 | L = ['%s=%r' % (key, value) 874 | for key, value in self.__dict__.items()] 875 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 876 | 877 | def __eq__(self, other): 878 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 879 | 880 | def __ne__(self, other): 881 | return not (self == other) 882 | -------------------------------------------------------------------------------- /PB/MessageService.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.10.0) 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | # options string: py 7 | # 8 | 9 | from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException 10 | from thrift.protocol.TProtocol import TProtocolException 11 | import sys 12 | import logging 13 | from .ttypes import * 14 | from thrift.Thrift import TProcessor 15 | from thrift.transport import TTransport 16 | 17 | 18 | class Iface(object): 19 | def fetchMessageOperations(self, localRevision, lastOpTimestamp, count): 20 | """ 21 | Parameters: 22 | - localRevision 23 | - lastOpTimestamp 24 | - count 25 | """ 26 | pass 27 | 28 | def getLastReadMessageIds(self, chatId): 29 | """ 30 | Parameters: 31 | - chatId 32 | """ 33 | pass 34 | 35 | def multiGetLastReadMessageIds(self, chatIds): 36 | """ 37 | Parameters: 38 | - chatIds 39 | """ 40 | pass 41 | 42 | 43 | class Client(Iface): 44 | def __init__(self, iprot, oprot=None): 45 | self._iprot = self._oprot = iprot 46 | if oprot is not None: 47 | self._oprot = oprot 48 | self._seqid = 0 49 | 50 | def fetchMessageOperations(self, localRevision, lastOpTimestamp, count): 51 | """ 52 | Parameters: 53 | - localRevision 54 | - lastOpTimestamp 55 | - count 56 | """ 57 | self.send_fetchMessageOperations(localRevision, lastOpTimestamp, count) 58 | return self.recv_fetchMessageOperations() 59 | 60 | def send_fetchMessageOperations(self, localRevision, lastOpTimestamp, count): 61 | self._oprot.writeMessageBegin('fetchMessageOperations', TMessageType.CALL, self._seqid) 62 | args = fetchMessageOperations_args() 63 | args.localRevision = localRevision 64 | args.lastOpTimestamp = lastOpTimestamp 65 | args.count = count 66 | args.write(self._oprot) 67 | self._oprot.writeMessageEnd() 68 | self._oprot.trans.flush() 69 | 70 | def recv_fetchMessageOperations(self): 71 | iprot = self._iprot 72 | (fname, mtype, rseqid) = iprot.readMessageBegin() 73 | if mtype == TMessageType.EXCEPTION: 74 | x = TApplicationException() 75 | x.read(iprot) 76 | iprot.readMessageEnd() 77 | raise x 78 | result = fetchMessageOperations_result() 79 | result.read(iprot) 80 | iprot.readMessageEnd() 81 | if result.success is not None: 82 | return result.success 83 | if result.e is not None: 84 | raise result.e 85 | raise TApplicationException(TApplicationException.MISSING_RESULT, "fetchMessageOperations failed: unknown result") 86 | 87 | def getLastReadMessageIds(self, chatId): 88 | """ 89 | Parameters: 90 | - chatId 91 | """ 92 | self.send_getLastReadMessageIds(chatId) 93 | return self.recv_getLastReadMessageIds() 94 | 95 | def send_getLastReadMessageIds(self, chatId): 96 | self._oprot.writeMessageBegin('getLastReadMessageIds', TMessageType.CALL, self._seqid) 97 | args = getLastReadMessageIds_args() 98 | args.chatId = chatId 99 | args.write(self._oprot) 100 | self._oprot.writeMessageEnd() 101 | self._oprot.trans.flush() 102 | 103 | def recv_getLastReadMessageIds(self): 104 | iprot = self._iprot 105 | (fname, mtype, rseqid) = iprot.readMessageBegin() 106 | if mtype == TMessageType.EXCEPTION: 107 | x = TApplicationException() 108 | x.read(iprot) 109 | iprot.readMessageEnd() 110 | raise x 111 | result = getLastReadMessageIds_result() 112 | result.read(iprot) 113 | iprot.readMessageEnd() 114 | if result.success is not None: 115 | return result.success 116 | if result.e is not None: 117 | raise result.e 118 | raise TApplicationException(TApplicationException.MISSING_RESULT, "getLastReadMessageIds failed: unknown result") 119 | 120 | def multiGetLastReadMessageIds(self, chatIds): 121 | """ 122 | Parameters: 123 | - chatIds 124 | """ 125 | self.send_multiGetLastReadMessageIds(chatIds) 126 | return self.recv_multiGetLastReadMessageIds() 127 | 128 | def send_multiGetLastReadMessageIds(self, chatIds): 129 | self._oprot.writeMessageBegin('multiGetLastReadMessageIds', TMessageType.CALL, self._seqid) 130 | args = multiGetLastReadMessageIds_args() 131 | args.chatIds = chatIds 132 | args.write(self._oprot) 133 | self._oprot.writeMessageEnd() 134 | self._oprot.trans.flush() 135 | 136 | def recv_multiGetLastReadMessageIds(self): 137 | iprot = self._iprot 138 | (fname, mtype, rseqid) = iprot.readMessageBegin() 139 | if mtype == TMessageType.EXCEPTION: 140 | x = TApplicationException() 141 | x.read(iprot) 142 | iprot.readMessageEnd() 143 | raise x 144 | result = multiGetLastReadMessageIds_result() 145 | result.read(iprot) 146 | iprot.readMessageEnd() 147 | if result.success is not None: 148 | return result.success 149 | if result.e is not None: 150 | raise result.e 151 | raise TApplicationException(TApplicationException.MISSING_RESULT, "multiGetLastReadMessageIds failed: unknown result") 152 | 153 | 154 | class Processor(Iface, TProcessor): 155 | def __init__(self, handler): 156 | self._handler = handler 157 | self._processMap = {} 158 | self._processMap["fetchMessageOperations"] = Processor.process_fetchMessageOperations 159 | self._processMap["getLastReadMessageIds"] = Processor.process_getLastReadMessageIds 160 | self._processMap["multiGetLastReadMessageIds"] = Processor.process_multiGetLastReadMessageIds 161 | 162 | def process(self, iprot, oprot): 163 | (name, type, seqid) = iprot.readMessageBegin() 164 | if name not in self._processMap: 165 | iprot.skip(TType.STRUCT) 166 | iprot.readMessageEnd() 167 | x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) 168 | oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) 169 | x.write(oprot) 170 | oprot.writeMessageEnd() 171 | oprot.trans.flush() 172 | return 173 | else: 174 | self._processMap[name](self, seqid, iprot, oprot) 175 | return True 176 | 177 | def process_fetchMessageOperations(self, seqid, iprot, oprot): 178 | args = fetchMessageOperations_args() 179 | args.read(iprot) 180 | iprot.readMessageEnd() 181 | result = fetchMessageOperations_result() 182 | try: 183 | result.success = self._handler.fetchMessageOperations(args.localRevision, args.lastOpTimestamp, args.count) 184 | msg_type = TMessageType.REPLY 185 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 186 | raise 187 | except TalkException as e: 188 | msg_type = TMessageType.REPLY 189 | result.e = e 190 | except Exception as ex: 191 | msg_type = TMessageType.EXCEPTION 192 | logging.exception(ex) 193 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 194 | oprot.writeMessageBegin("fetchMessageOperations", msg_type, seqid) 195 | result.write(oprot) 196 | oprot.writeMessageEnd() 197 | oprot.trans.flush() 198 | 199 | def process_getLastReadMessageIds(self, seqid, iprot, oprot): 200 | args = getLastReadMessageIds_args() 201 | args.read(iprot) 202 | iprot.readMessageEnd() 203 | result = getLastReadMessageIds_result() 204 | try: 205 | result.success = self._handler.getLastReadMessageIds(args.chatId) 206 | msg_type = TMessageType.REPLY 207 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 208 | raise 209 | except TalkException as e: 210 | msg_type = TMessageType.REPLY 211 | result.e = e 212 | except Exception as ex: 213 | msg_type = TMessageType.EXCEPTION 214 | logging.exception(ex) 215 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 216 | oprot.writeMessageBegin("getLastReadMessageIds", msg_type, seqid) 217 | result.write(oprot) 218 | oprot.writeMessageEnd() 219 | oprot.trans.flush() 220 | 221 | def process_multiGetLastReadMessageIds(self, seqid, iprot, oprot): 222 | args = multiGetLastReadMessageIds_args() 223 | args.read(iprot) 224 | iprot.readMessageEnd() 225 | result = multiGetLastReadMessageIds_result() 226 | try: 227 | result.success = self._handler.multiGetLastReadMessageIds(args.chatIds) 228 | msg_type = TMessageType.REPLY 229 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 230 | raise 231 | except TalkException as e: 232 | msg_type = TMessageType.REPLY 233 | result.e = e 234 | except Exception as ex: 235 | msg_type = TMessageType.EXCEPTION 236 | logging.exception(ex) 237 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 238 | oprot.writeMessageBegin("multiGetLastReadMessageIds", msg_type, seqid) 239 | result.write(oprot) 240 | oprot.writeMessageEnd() 241 | oprot.trans.flush() 242 | 243 | # HELPER FUNCTIONS AND STRUCTURES 244 | 245 | 246 | class fetchMessageOperations_args(object): 247 | """ 248 | Attributes: 249 | - localRevision 250 | - lastOpTimestamp 251 | - count 252 | """ 253 | 254 | thrift_spec = ( 255 | None, # 0 256 | None, # 1 257 | (2, TType.I64, 'localRevision', None, None, ), # 2 258 | (3, TType.I64, 'lastOpTimestamp', None, None, ), # 3 259 | (4, TType.I32, 'count', None, None, ), # 4 260 | ) 261 | 262 | def __init__(self, localRevision=None, lastOpTimestamp=None, count=None,): 263 | self.localRevision = localRevision 264 | self.lastOpTimestamp = lastOpTimestamp 265 | self.count = count 266 | 267 | def read(self, iprot): 268 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 269 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 270 | return 271 | iprot.readStructBegin() 272 | while True: 273 | (fname, ftype, fid) = iprot.readFieldBegin() 274 | if ftype == TType.STOP: 275 | break 276 | if fid == 2: 277 | if ftype == TType.I64: 278 | self.localRevision = iprot.readI64() 279 | else: 280 | iprot.skip(ftype) 281 | elif fid == 3: 282 | if ftype == TType.I64: 283 | self.lastOpTimestamp = iprot.readI64() 284 | else: 285 | iprot.skip(ftype) 286 | elif fid == 4: 287 | if ftype == TType.I32: 288 | self.count = iprot.readI32() 289 | else: 290 | iprot.skip(ftype) 291 | else: 292 | iprot.skip(ftype) 293 | iprot.readFieldEnd() 294 | iprot.readStructEnd() 295 | 296 | def write(self, oprot): 297 | if oprot._fast_encode is not None and self.thrift_spec is not None: 298 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 299 | return 300 | oprot.writeStructBegin('fetchMessageOperations_args') 301 | if self.localRevision is not None: 302 | oprot.writeFieldBegin('localRevision', TType.I64, 2) 303 | oprot.writeI64(self.localRevision) 304 | oprot.writeFieldEnd() 305 | if self.lastOpTimestamp is not None: 306 | oprot.writeFieldBegin('lastOpTimestamp', TType.I64, 3) 307 | oprot.writeI64(self.lastOpTimestamp) 308 | oprot.writeFieldEnd() 309 | if self.count is not None: 310 | oprot.writeFieldBegin('count', TType.I32, 4) 311 | oprot.writeI32(self.count) 312 | oprot.writeFieldEnd() 313 | oprot.writeFieldStop() 314 | oprot.writeStructEnd() 315 | 316 | def validate(self): 317 | return 318 | 319 | def __repr__(self): 320 | L = ['%s=%r' % (key, value) 321 | for key, value in self.__dict__.items()] 322 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 323 | 324 | def __eq__(self, other): 325 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 326 | 327 | def __ne__(self, other): 328 | return not (self == other) 329 | 330 | 331 | class fetchMessageOperations_result(object): 332 | """ 333 | Attributes: 334 | - success 335 | - e 336 | """ 337 | 338 | thrift_spec = ( 339 | (0, TType.STRUCT, 'success', (MessageOperations, MessageOperations.thrift_spec), None, ), # 0 340 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 341 | ) 342 | 343 | def __init__(self, success=None, e=None,): 344 | self.success = success 345 | self.e = e 346 | 347 | def read(self, iprot): 348 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 349 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 350 | return 351 | iprot.readStructBegin() 352 | while True: 353 | (fname, ftype, fid) = iprot.readFieldBegin() 354 | if ftype == TType.STOP: 355 | break 356 | if fid == 0: 357 | if ftype == TType.STRUCT: 358 | self.success = MessageOperations() 359 | self.success.read(iprot) 360 | else: 361 | iprot.skip(ftype) 362 | elif fid == 1: 363 | if ftype == TType.STRUCT: 364 | self.e = TalkException() 365 | self.e.read(iprot) 366 | else: 367 | iprot.skip(ftype) 368 | else: 369 | iprot.skip(ftype) 370 | iprot.readFieldEnd() 371 | iprot.readStructEnd() 372 | 373 | def write(self, oprot): 374 | if oprot._fast_encode is not None and self.thrift_spec is not None: 375 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 376 | return 377 | oprot.writeStructBegin('fetchMessageOperations_result') 378 | if self.success is not None: 379 | oprot.writeFieldBegin('success', TType.STRUCT, 0) 380 | self.success.write(oprot) 381 | oprot.writeFieldEnd() 382 | if self.e is not None: 383 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 384 | self.e.write(oprot) 385 | oprot.writeFieldEnd() 386 | oprot.writeFieldStop() 387 | oprot.writeStructEnd() 388 | 389 | def validate(self): 390 | return 391 | 392 | def __repr__(self): 393 | L = ['%s=%r' % (key, value) 394 | for key, value in self.__dict__.items()] 395 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 396 | 397 | def __eq__(self, other): 398 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 399 | 400 | def __ne__(self, other): 401 | return not (self == other) 402 | 403 | 404 | class getLastReadMessageIds_args(object): 405 | """ 406 | Attributes: 407 | - chatId 408 | """ 409 | 410 | thrift_spec = ( 411 | None, # 0 412 | None, # 1 413 | (2, TType.STRING, 'chatId', 'UTF8', None, ), # 2 414 | ) 415 | 416 | def __init__(self, chatId=None,): 417 | self.chatId = chatId 418 | 419 | def read(self, iprot): 420 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 421 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 422 | return 423 | iprot.readStructBegin() 424 | while True: 425 | (fname, ftype, fid) = iprot.readFieldBegin() 426 | if ftype == TType.STOP: 427 | break 428 | if fid == 2: 429 | if ftype == TType.STRING: 430 | self.chatId = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 431 | else: 432 | iprot.skip(ftype) 433 | else: 434 | iprot.skip(ftype) 435 | iprot.readFieldEnd() 436 | iprot.readStructEnd() 437 | 438 | def write(self, oprot): 439 | if oprot._fast_encode is not None and self.thrift_spec is not None: 440 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 441 | return 442 | oprot.writeStructBegin('getLastReadMessageIds_args') 443 | if self.chatId is not None: 444 | oprot.writeFieldBegin('chatId', TType.STRING, 2) 445 | oprot.writeString(self.chatId.encode('utf-8') if sys.version_info[0] == 2 else self.chatId) 446 | oprot.writeFieldEnd() 447 | oprot.writeFieldStop() 448 | oprot.writeStructEnd() 449 | 450 | def validate(self): 451 | return 452 | 453 | def __repr__(self): 454 | L = ['%s=%r' % (key, value) 455 | for key, value in self.__dict__.items()] 456 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 457 | 458 | def __eq__(self, other): 459 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 460 | 461 | def __ne__(self, other): 462 | return not (self == other) 463 | 464 | 465 | class getLastReadMessageIds_result(object): 466 | """ 467 | Attributes: 468 | - success 469 | - e 470 | """ 471 | 472 | thrift_spec = ( 473 | (0, TType.STRUCT, 'success', (LastReadMessageIds, LastReadMessageIds.thrift_spec), None, ), # 0 474 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 475 | ) 476 | 477 | def __init__(self, success=None, e=None,): 478 | self.success = success 479 | self.e = e 480 | 481 | def read(self, iprot): 482 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 483 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 484 | return 485 | iprot.readStructBegin() 486 | while True: 487 | (fname, ftype, fid) = iprot.readFieldBegin() 488 | if ftype == TType.STOP: 489 | break 490 | if fid == 0: 491 | if ftype == TType.STRUCT: 492 | self.success = LastReadMessageIds() 493 | self.success.read(iprot) 494 | else: 495 | iprot.skip(ftype) 496 | elif fid == 1: 497 | if ftype == TType.STRUCT: 498 | self.e = TalkException() 499 | self.e.read(iprot) 500 | else: 501 | iprot.skip(ftype) 502 | else: 503 | iprot.skip(ftype) 504 | iprot.readFieldEnd() 505 | iprot.readStructEnd() 506 | 507 | def write(self, oprot): 508 | if oprot._fast_encode is not None and self.thrift_spec is not None: 509 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 510 | return 511 | oprot.writeStructBegin('getLastReadMessageIds_result') 512 | if self.success is not None: 513 | oprot.writeFieldBegin('success', TType.STRUCT, 0) 514 | self.success.write(oprot) 515 | oprot.writeFieldEnd() 516 | if self.e is not None: 517 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 518 | self.e.write(oprot) 519 | oprot.writeFieldEnd() 520 | oprot.writeFieldStop() 521 | oprot.writeStructEnd() 522 | 523 | def validate(self): 524 | return 525 | 526 | def __repr__(self): 527 | L = ['%s=%r' % (key, value) 528 | for key, value in self.__dict__.items()] 529 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 530 | 531 | def __eq__(self, other): 532 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 533 | 534 | def __ne__(self, other): 535 | return not (self == other) 536 | 537 | 538 | class multiGetLastReadMessageIds_args(object): 539 | """ 540 | Attributes: 541 | - chatIds 542 | """ 543 | 544 | thrift_spec = ( 545 | None, # 0 546 | None, # 1 547 | (2, TType.LIST, 'chatIds', (TType.STRING, 'UTF8', False), None, ), # 2 548 | ) 549 | 550 | def __init__(self, chatIds=None,): 551 | self.chatIds = chatIds 552 | 553 | def read(self, iprot): 554 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 555 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 556 | return 557 | iprot.readStructBegin() 558 | while True: 559 | (fname, ftype, fid) = iprot.readFieldBegin() 560 | if ftype == TType.STOP: 561 | break 562 | if fid == 2: 563 | if ftype == TType.LIST: 564 | self.chatIds = [] 565 | (_etype1064, _size1061) = iprot.readListBegin() 566 | for _i1065 in range(_size1061): 567 | _elem1066 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 568 | self.chatIds.append(_elem1066) 569 | iprot.readListEnd() 570 | else: 571 | iprot.skip(ftype) 572 | else: 573 | iprot.skip(ftype) 574 | iprot.readFieldEnd() 575 | iprot.readStructEnd() 576 | 577 | def write(self, oprot): 578 | if oprot._fast_encode is not None and self.thrift_spec is not None: 579 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 580 | return 581 | oprot.writeStructBegin('multiGetLastReadMessageIds_args') 582 | if self.chatIds is not None: 583 | oprot.writeFieldBegin('chatIds', TType.LIST, 2) 584 | oprot.writeListBegin(TType.STRING, len(self.chatIds)) 585 | for iter1067 in self.chatIds: 586 | oprot.writeString(iter1067.encode('utf-8') if sys.version_info[0] == 2 else iter1067) 587 | oprot.writeListEnd() 588 | oprot.writeFieldEnd() 589 | oprot.writeFieldStop() 590 | oprot.writeStructEnd() 591 | 592 | def validate(self): 593 | return 594 | 595 | def __repr__(self): 596 | L = ['%s=%r' % (key, value) 597 | for key, value in self.__dict__.items()] 598 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 599 | 600 | def __eq__(self, other): 601 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 602 | 603 | def __ne__(self, other): 604 | return not (self == other) 605 | 606 | 607 | class multiGetLastReadMessageIds_result(object): 608 | """ 609 | Attributes: 610 | - success 611 | - e 612 | """ 613 | 614 | thrift_spec = ( 615 | (0, TType.LIST, 'success', (TType.STRUCT, (LastReadMessageIds, LastReadMessageIds.thrift_spec), False), None, ), # 0 616 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 617 | ) 618 | 619 | def __init__(self, success=None, e=None,): 620 | self.success = success 621 | self.e = e 622 | 623 | def read(self, iprot): 624 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 625 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 626 | return 627 | iprot.readStructBegin() 628 | while True: 629 | (fname, ftype, fid) = iprot.readFieldBegin() 630 | if ftype == TType.STOP: 631 | break 632 | if fid == 0: 633 | if ftype == TType.LIST: 634 | self.success = [] 635 | (_etype1071, _size1068) = iprot.readListBegin() 636 | for _i1072 in range(_size1068): 637 | _elem1073 = LastReadMessageIds() 638 | _elem1073.read(iprot) 639 | self.success.append(_elem1073) 640 | iprot.readListEnd() 641 | else: 642 | iprot.skip(ftype) 643 | elif fid == 1: 644 | if ftype == TType.STRUCT: 645 | self.e = TalkException() 646 | self.e.read(iprot) 647 | else: 648 | iprot.skip(ftype) 649 | else: 650 | iprot.skip(ftype) 651 | iprot.readFieldEnd() 652 | iprot.readStructEnd() 653 | 654 | def write(self, oprot): 655 | if oprot._fast_encode is not None and self.thrift_spec is not None: 656 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 657 | return 658 | oprot.writeStructBegin('multiGetLastReadMessageIds_result') 659 | if self.success is not None: 660 | oprot.writeFieldBegin('success', TType.LIST, 0) 661 | oprot.writeListBegin(TType.STRUCT, len(self.success)) 662 | for iter1074 in self.success: 663 | iter1074.write(oprot) 664 | oprot.writeListEnd() 665 | oprot.writeFieldEnd() 666 | if self.e is not None: 667 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 668 | self.e.write(oprot) 669 | oprot.writeFieldEnd() 670 | oprot.writeFieldStop() 671 | oprot.writeStructEnd() 672 | 673 | def validate(self): 674 | return 675 | 676 | def __repr__(self): 677 | L = ['%s=%r' % (key, value) 678 | for key, value in self.__dict__.items()] 679 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 680 | 681 | def __eq__(self, other): 682 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 683 | 684 | def __ne__(self, other): 685 | return not (self == other) 686 | -------------------------------------------------------------------------------- /PB/SnsAdaptorService.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.10.0) 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | # options string: py 7 | # 8 | 9 | from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException 10 | from thrift.protocol.TProtocol import TProtocolException 11 | import sys 12 | import logging 13 | from .ttypes import * 14 | from thrift.Thrift import TProcessor 15 | from thrift.transport import TTransport 16 | 17 | 18 | class Iface(object): 19 | def getSnsFriends(self, snsIdType, snsAccessToken, startIdx, limit): 20 | """ 21 | Parameters: 22 | - snsIdType 23 | - snsAccessToken 24 | - startIdx 25 | - limit 26 | """ 27 | pass 28 | 29 | def getSnsMyProfile(self, snsIdType, snsAccessToken): 30 | """ 31 | Parameters: 32 | - snsIdType 33 | - snsAccessToken 34 | """ 35 | pass 36 | 37 | def postSnsInvitationMessage(self, snsIdType, snsAccessToken, toSnsUserId): 38 | """ 39 | Parameters: 40 | - snsIdType 41 | - snsAccessToken 42 | - toSnsUserId 43 | """ 44 | pass 45 | 46 | 47 | class Client(Iface): 48 | def __init__(self, iprot, oprot=None): 49 | self._iprot = self._oprot = iprot 50 | if oprot is not None: 51 | self._oprot = oprot 52 | self._seqid = 0 53 | 54 | def getSnsFriends(self, snsIdType, snsAccessToken, startIdx, limit): 55 | """ 56 | Parameters: 57 | - snsIdType 58 | - snsAccessToken 59 | - startIdx 60 | - limit 61 | """ 62 | self.send_getSnsFriends(snsIdType, snsAccessToken, startIdx, limit) 63 | return self.recv_getSnsFriends() 64 | 65 | def send_getSnsFriends(self, snsIdType, snsAccessToken, startIdx, limit): 66 | self._oprot.writeMessageBegin('getSnsFriends', TMessageType.CALL, self._seqid) 67 | args = getSnsFriends_args() 68 | args.snsIdType = snsIdType 69 | args.snsAccessToken = snsAccessToken 70 | args.startIdx = startIdx 71 | args.limit = limit 72 | args.write(self._oprot) 73 | self._oprot.writeMessageEnd() 74 | self._oprot.trans.flush() 75 | 76 | def recv_getSnsFriends(self): 77 | iprot = self._iprot 78 | (fname, mtype, rseqid) = iprot.readMessageBegin() 79 | if mtype == TMessageType.EXCEPTION: 80 | x = TApplicationException() 81 | x.read(iprot) 82 | iprot.readMessageEnd() 83 | raise x 84 | result = getSnsFriends_result() 85 | result.read(iprot) 86 | iprot.readMessageEnd() 87 | if result.success is not None: 88 | return result.success 89 | if result.e is not None: 90 | raise result.e 91 | raise TApplicationException(TApplicationException.MISSING_RESULT, "getSnsFriends failed: unknown result") 92 | 93 | def getSnsMyProfile(self, snsIdType, snsAccessToken): 94 | """ 95 | Parameters: 96 | - snsIdType 97 | - snsAccessToken 98 | """ 99 | self.send_getSnsMyProfile(snsIdType, snsAccessToken) 100 | return self.recv_getSnsMyProfile() 101 | 102 | def send_getSnsMyProfile(self, snsIdType, snsAccessToken): 103 | self._oprot.writeMessageBegin('getSnsMyProfile', TMessageType.CALL, self._seqid) 104 | args = getSnsMyProfile_args() 105 | args.snsIdType = snsIdType 106 | args.snsAccessToken = snsAccessToken 107 | args.write(self._oprot) 108 | self._oprot.writeMessageEnd() 109 | self._oprot.trans.flush() 110 | 111 | def recv_getSnsMyProfile(self): 112 | iprot = self._iprot 113 | (fname, mtype, rseqid) = iprot.readMessageBegin() 114 | if mtype == TMessageType.EXCEPTION: 115 | x = TApplicationException() 116 | x.read(iprot) 117 | iprot.readMessageEnd() 118 | raise x 119 | result = getSnsMyProfile_result() 120 | result.read(iprot) 121 | iprot.readMessageEnd() 122 | if result.success is not None: 123 | return result.success 124 | if result.e is not None: 125 | raise result.e 126 | raise TApplicationException(TApplicationException.MISSING_RESULT, "getSnsMyProfile failed: unknown result") 127 | 128 | def postSnsInvitationMessage(self, snsIdType, snsAccessToken, toSnsUserId): 129 | """ 130 | Parameters: 131 | - snsIdType 132 | - snsAccessToken 133 | - toSnsUserId 134 | """ 135 | self.send_postSnsInvitationMessage(snsIdType, snsAccessToken, toSnsUserId) 136 | self.recv_postSnsInvitationMessage() 137 | 138 | def send_postSnsInvitationMessage(self, snsIdType, snsAccessToken, toSnsUserId): 139 | self._oprot.writeMessageBegin('postSnsInvitationMessage', TMessageType.CALL, self._seqid) 140 | args = postSnsInvitationMessage_args() 141 | args.snsIdType = snsIdType 142 | args.snsAccessToken = snsAccessToken 143 | args.toSnsUserId = toSnsUserId 144 | args.write(self._oprot) 145 | self._oprot.writeMessageEnd() 146 | self._oprot.trans.flush() 147 | 148 | def recv_postSnsInvitationMessage(self): 149 | iprot = self._iprot 150 | (fname, mtype, rseqid) = iprot.readMessageBegin() 151 | if mtype == TMessageType.EXCEPTION: 152 | x = TApplicationException() 153 | x.read(iprot) 154 | iprot.readMessageEnd() 155 | raise x 156 | result = postSnsInvitationMessage_result() 157 | result.read(iprot) 158 | iprot.readMessageEnd() 159 | if result.e is not None: 160 | raise result.e 161 | return 162 | 163 | 164 | class Processor(Iface, TProcessor): 165 | def __init__(self, handler): 166 | self._handler = handler 167 | self._processMap = {} 168 | self._processMap["getSnsFriends"] = Processor.process_getSnsFriends 169 | self._processMap["getSnsMyProfile"] = Processor.process_getSnsMyProfile 170 | self._processMap["postSnsInvitationMessage"] = Processor.process_postSnsInvitationMessage 171 | 172 | def process(self, iprot, oprot): 173 | (name, type, seqid) = iprot.readMessageBegin() 174 | if name not in self._processMap: 175 | iprot.skip(TType.STRUCT) 176 | iprot.readMessageEnd() 177 | x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) 178 | oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) 179 | x.write(oprot) 180 | oprot.writeMessageEnd() 181 | oprot.trans.flush() 182 | return 183 | else: 184 | self._processMap[name](self, seqid, iprot, oprot) 185 | return True 186 | 187 | def process_getSnsFriends(self, seqid, iprot, oprot): 188 | args = getSnsFriends_args() 189 | args.read(iprot) 190 | iprot.readMessageEnd() 191 | result = getSnsFriends_result() 192 | try: 193 | result.success = self._handler.getSnsFriends(args.snsIdType, args.snsAccessToken, args.startIdx, args.limit) 194 | msg_type = TMessageType.REPLY 195 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 196 | raise 197 | except TalkException as e: 198 | msg_type = TMessageType.REPLY 199 | result.e = e 200 | except Exception as ex: 201 | msg_type = TMessageType.EXCEPTION 202 | logging.exception(ex) 203 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 204 | oprot.writeMessageBegin("getSnsFriends", msg_type, seqid) 205 | result.write(oprot) 206 | oprot.writeMessageEnd() 207 | oprot.trans.flush() 208 | 209 | def process_getSnsMyProfile(self, seqid, iprot, oprot): 210 | args = getSnsMyProfile_args() 211 | args.read(iprot) 212 | iprot.readMessageEnd() 213 | result = getSnsMyProfile_result() 214 | try: 215 | result.success = self._handler.getSnsMyProfile(args.snsIdType, args.snsAccessToken) 216 | msg_type = TMessageType.REPLY 217 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 218 | raise 219 | except TalkException as e: 220 | msg_type = TMessageType.REPLY 221 | result.e = e 222 | except Exception as ex: 223 | msg_type = TMessageType.EXCEPTION 224 | logging.exception(ex) 225 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 226 | oprot.writeMessageBegin("getSnsMyProfile", msg_type, seqid) 227 | result.write(oprot) 228 | oprot.writeMessageEnd() 229 | oprot.trans.flush() 230 | 231 | def process_postSnsInvitationMessage(self, seqid, iprot, oprot): 232 | args = postSnsInvitationMessage_args() 233 | args.read(iprot) 234 | iprot.readMessageEnd() 235 | result = postSnsInvitationMessage_result() 236 | try: 237 | self._handler.postSnsInvitationMessage(args.snsIdType, args.snsAccessToken, args.toSnsUserId) 238 | msg_type = TMessageType.REPLY 239 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 240 | raise 241 | except TalkException as e: 242 | msg_type = TMessageType.REPLY 243 | result.e = e 244 | except Exception as ex: 245 | msg_type = TMessageType.EXCEPTION 246 | logging.exception(ex) 247 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 248 | oprot.writeMessageBegin("postSnsInvitationMessage", msg_type, seqid) 249 | result.write(oprot) 250 | oprot.writeMessageEnd() 251 | oprot.trans.flush() 252 | 253 | # HELPER FUNCTIONS AND STRUCTURES 254 | 255 | 256 | class getSnsFriends_args(object): 257 | """ 258 | Attributes: 259 | - snsIdType 260 | - snsAccessToken 261 | - startIdx 262 | - limit 263 | """ 264 | 265 | thrift_spec = ( 266 | None, # 0 267 | None, # 1 268 | (2, TType.I32, 'snsIdType', None, None, ), # 2 269 | (3, TType.STRING, 'snsAccessToken', 'UTF8', None, ), # 3 270 | (4, TType.I32, 'startIdx', None, None, ), # 4 271 | (5, TType.I32, 'limit', None, None, ), # 5 272 | ) 273 | 274 | def __init__(self, snsIdType=None, snsAccessToken=None, startIdx=None, limit=None,): 275 | self.snsIdType = snsIdType 276 | self.snsAccessToken = snsAccessToken 277 | self.startIdx = startIdx 278 | self.limit = limit 279 | 280 | def read(self, iprot): 281 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 282 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 283 | return 284 | iprot.readStructBegin() 285 | while True: 286 | (fname, ftype, fid) = iprot.readFieldBegin() 287 | if ftype == TType.STOP: 288 | break 289 | if fid == 2: 290 | if ftype == TType.I32: 291 | self.snsIdType = iprot.readI32() 292 | else: 293 | iprot.skip(ftype) 294 | elif fid == 3: 295 | if ftype == TType.STRING: 296 | self.snsAccessToken = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 297 | else: 298 | iprot.skip(ftype) 299 | elif fid == 4: 300 | if ftype == TType.I32: 301 | self.startIdx = iprot.readI32() 302 | else: 303 | iprot.skip(ftype) 304 | elif fid == 5: 305 | if ftype == TType.I32: 306 | self.limit = iprot.readI32() 307 | else: 308 | iprot.skip(ftype) 309 | else: 310 | iprot.skip(ftype) 311 | iprot.readFieldEnd() 312 | iprot.readStructEnd() 313 | 314 | def write(self, oprot): 315 | if oprot._fast_encode is not None and self.thrift_spec is not None: 316 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 317 | return 318 | oprot.writeStructBegin('getSnsFriends_args') 319 | if self.snsIdType is not None: 320 | oprot.writeFieldBegin('snsIdType', TType.I32, 2) 321 | oprot.writeI32(self.snsIdType) 322 | oprot.writeFieldEnd() 323 | if self.snsAccessToken is not None: 324 | oprot.writeFieldBegin('snsAccessToken', TType.STRING, 3) 325 | oprot.writeString(self.snsAccessToken.encode('utf-8') if sys.version_info[0] == 2 else self.snsAccessToken) 326 | oprot.writeFieldEnd() 327 | if self.startIdx is not None: 328 | oprot.writeFieldBegin('startIdx', TType.I32, 4) 329 | oprot.writeI32(self.startIdx) 330 | oprot.writeFieldEnd() 331 | if self.limit is not None: 332 | oprot.writeFieldBegin('limit', TType.I32, 5) 333 | oprot.writeI32(self.limit) 334 | oprot.writeFieldEnd() 335 | oprot.writeFieldStop() 336 | oprot.writeStructEnd() 337 | 338 | def validate(self): 339 | return 340 | 341 | def __repr__(self): 342 | L = ['%s=%r' % (key, value) 343 | for key, value in self.__dict__.items()] 344 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 345 | 346 | def __eq__(self, other): 347 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 348 | 349 | def __ne__(self, other): 350 | return not (self == other) 351 | 352 | 353 | class getSnsFriends_result(object): 354 | """ 355 | Attributes: 356 | - success 357 | - e 358 | """ 359 | 360 | thrift_spec = ( 361 | (0, TType.STRUCT, 'success', (SnsFriends, SnsFriends.thrift_spec), None, ), # 0 362 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 363 | ) 364 | 365 | def __init__(self, success=None, e=None,): 366 | self.success = success 367 | self.e = e 368 | 369 | def read(self, iprot): 370 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 371 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 372 | return 373 | iprot.readStructBegin() 374 | while True: 375 | (fname, ftype, fid) = iprot.readFieldBegin() 376 | if ftype == TType.STOP: 377 | break 378 | if fid == 0: 379 | if ftype == TType.STRUCT: 380 | self.success = SnsFriends() 381 | self.success.read(iprot) 382 | else: 383 | iprot.skip(ftype) 384 | elif fid == 1: 385 | if ftype == TType.STRUCT: 386 | self.e = TalkException() 387 | self.e.read(iprot) 388 | else: 389 | iprot.skip(ftype) 390 | else: 391 | iprot.skip(ftype) 392 | iprot.readFieldEnd() 393 | iprot.readStructEnd() 394 | 395 | def write(self, oprot): 396 | if oprot._fast_encode is not None and self.thrift_spec is not None: 397 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 398 | return 399 | oprot.writeStructBegin('getSnsFriends_result') 400 | if self.success is not None: 401 | oprot.writeFieldBegin('success', TType.STRUCT, 0) 402 | self.success.write(oprot) 403 | oprot.writeFieldEnd() 404 | if self.e is not None: 405 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 406 | self.e.write(oprot) 407 | oprot.writeFieldEnd() 408 | oprot.writeFieldStop() 409 | oprot.writeStructEnd() 410 | 411 | def validate(self): 412 | return 413 | 414 | def __repr__(self): 415 | L = ['%s=%r' % (key, value) 416 | for key, value in self.__dict__.items()] 417 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 418 | 419 | def __eq__(self, other): 420 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 421 | 422 | def __ne__(self, other): 423 | return not (self == other) 424 | 425 | 426 | class getSnsMyProfile_args(object): 427 | """ 428 | Attributes: 429 | - snsIdType 430 | - snsAccessToken 431 | """ 432 | 433 | thrift_spec = ( 434 | None, # 0 435 | None, # 1 436 | (2, TType.I32, 'snsIdType', None, None, ), # 2 437 | (3, TType.STRING, 'snsAccessToken', 'UTF8', None, ), # 3 438 | ) 439 | 440 | def __init__(self, snsIdType=None, snsAccessToken=None,): 441 | self.snsIdType = snsIdType 442 | self.snsAccessToken = snsAccessToken 443 | 444 | def read(self, iprot): 445 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 446 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 447 | return 448 | iprot.readStructBegin() 449 | while True: 450 | (fname, ftype, fid) = iprot.readFieldBegin() 451 | if ftype == TType.STOP: 452 | break 453 | if fid == 2: 454 | if ftype == TType.I32: 455 | self.snsIdType = iprot.readI32() 456 | else: 457 | iprot.skip(ftype) 458 | elif fid == 3: 459 | if ftype == TType.STRING: 460 | self.snsAccessToken = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 461 | else: 462 | iprot.skip(ftype) 463 | else: 464 | iprot.skip(ftype) 465 | iprot.readFieldEnd() 466 | iprot.readStructEnd() 467 | 468 | def write(self, oprot): 469 | if oprot._fast_encode is not None and self.thrift_spec is not None: 470 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 471 | return 472 | oprot.writeStructBegin('getSnsMyProfile_args') 473 | if self.snsIdType is not None: 474 | oprot.writeFieldBegin('snsIdType', TType.I32, 2) 475 | oprot.writeI32(self.snsIdType) 476 | oprot.writeFieldEnd() 477 | if self.snsAccessToken is not None: 478 | oprot.writeFieldBegin('snsAccessToken', TType.STRING, 3) 479 | oprot.writeString(self.snsAccessToken.encode('utf-8') if sys.version_info[0] == 2 else self.snsAccessToken) 480 | oprot.writeFieldEnd() 481 | oprot.writeFieldStop() 482 | oprot.writeStructEnd() 483 | 484 | def validate(self): 485 | return 486 | 487 | def __repr__(self): 488 | L = ['%s=%r' % (key, value) 489 | for key, value in self.__dict__.items()] 490 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 491 | 492 | def __eq__(self, other): 493 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 494 | 495 | def __ne__(self, other): 496 | return not (self == other) 497 | 498 | 499 | class getSnsMyProfile_result(object): 500 | """ 501 | Attributes: 502 | - success 503 | - e 504 | """ 505 | 506 | thrift_spec = ( 507 | (0, TType.STRUCT, 'success', (SnsProfile, SnsProfile.thrift_spec), None, ), # 0 508 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 509 | ) 510 | 511 | def __init__(self, success=None, e=None,): 512 | self.success = success 513 | self.e = e 514 | 515 | def read(self, iprot): 516 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 517 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 518 | return 519 | iprot.readStructBegin() 520 | while True: 521 | (fname, ftype, fid) = iprot.readFieldBegin() 522 | if ftype == TType.STOP: 523 | break 524 | if fid == 0: 525 | if ftype == TType.STRUCT: 526 | self.success = SnsProfile() 527 | self.success.read(iprot) 528 | else: 529 | iprot.skip(ftype) 530 | elif fid == 1: 531 | if ftype == TType.STRUCT: 532 | self.e = TalkException() 533 | self.e.read(iprot) 534 | else: 535 | iprot.skip(ftype) 536 | else: 537 | iprot.skip(ftype) 538 | iprot.readFieldEnd() 539 | iprot.readStructEnd() 540 | 541 | def write(self, oprot): 542 | if oprot._fast_encode is not None and self.thrift_spec is not None: 543 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 544 | return 545 | oprot.writeStructBegin('getSnsMyProfile_result') 546 | if self.success is not None: 547 | oprot.writeFieldBegin('success', TType.STRUCT, 0) 548 | self.success.write(oprot) 549 | oprot.writeFieldEnd() 550 | if self.e is not None: 551 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 552 | self.e.write(oprot) 553 | oprot.writeFieldEnd() 554 | oprot.writeFieldStop() 555 | oprot.writeStructEnd() 556 | 557 | def validate(self): 558 | return 559 | 560 | def __repr__(self): 561 | L = ['%s=%r' % (key, value) 562 | for key, value in self.__dict__.items()] 563 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 564 | 565 | def __eq__(self, other): 566 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 567 | 568 | def __ne__(self, other): 569 | return not (self == other) 570 | 571 | 572 | class postSnsInvitationMessage_args(object): 573 | """ 574 | Attributes: 575 | - snsIdType 576 | - snsAccessToken 577 | - toSnsUserId 578 | """ 579 | 580 | thrift_spec = ( 581 | None, # 0 582 | None, # 1 583 | (2, TType.I32, 'snsIdType', None, None, ), # 2 584 | (3, TType.STRING, 'snsAccessToken', 'UTF8', None, ), # 3 585 | (4, TType.STRING, 'toSnsUserId', 'UTF8', None, ), # 4 586 | ) 587 | 588 | def __init__(self, snsIdType=None, snsAccessToken=None, toSnsUserId=None,): 589 | self.snsIdType = snsIdType 590 | self.snsAccessToken = snsAccessToken 591 | self.toSnsUserId = toSnsUserId 592 | 593 | def read(self, iprot): 594 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 595 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 596 | return 597 | iprot.readStructBegin() 598 | while True: 599 | (fname, ftype, fid) = iprot.readFieldBegin() 600 | if ftype == TType.STOP: 601 | break 602 | if fid == 2: 603 | if ftype == TType.I32: 604 | self.snsIdType = iprot.readI32() 605 | else: 606 | iprot.skip(ftype) 607 | elif fid == 3: 608 | if ftype == TType.STRING: 609 | self.snsAccessToken = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 610 | else: 611 | iprot.skip(ftype) 612 | elif fid == 4: 613 | if ftype == TType.STRING: 614 | self.toSnsUserId = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() 615 | else: 616 | iprot.skip(ftype) 617 | else: 618 | iprot.skip(ftype) 619 | iprot.readFieldEnd() 620 | iprot.readStructEnd() 621 | 622 | def write(self, oprot): 623 | if oprot._fast_encode is not None and self.thrift_spec is not None: 624 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 625 | return 626 | oprot.writeStructBegin('postSnsInvitationMessage_args') 627 | if self.snsIdType is not None: 628 | oprot.writeFieldBegin('snsIdType', TType.I32, 2) 629 | oprot.writeI32(self.snsIdType) 630 | oprot.writeFieldEnd() 631 | if self.snsAccessToken is not None: 632 | oprot.writeFieldBegin('snsAccessToken', TType.STRING, 3) 633 | oprot.writeString(self.snsAccessToken.encode('utf-8') if sys.version_info[0] == 2 else self.snsAccessToken) 634 | oprot.writeFieldEnd() 635 | if self.toSnsUserId is not None: 636 | oprot.writeFieldBegin('toSnsUserId', TType.STRING, 4) 637 | oprot.writeString(self.toSnsUserId.encode('utf-8') if sys.version_info[0] == 2 else self.toSnsUserId) 638 | oprot.writeFieldEnd() 639 | oprot.writeFieldStop() 640 | oprot.writeStructEnd() 641 | 642 | def validate(self): 643 | return 644 | 645 | def __repr__(self): 646 | L = ['%s=%r' % (key, value) 647 | for key, value in self.__dict__.items()] 648 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 649 | 650 | def __eq__(self, other): 651 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 652 | 653 | def __ne__(self, other): 654 | return not (self == other) 655 | 656 | 657 | class postSnsInvitationMessage_result(object): 658 | """ 659 | Attributes: 660 | - e 661 | """ 662 | 663 | thrift_spec = ( 664 | None, # 0 665 | (1, TType.STRUCT, 'e', (TalkException, TalkException.thrift_spec), None, ), # 1 666 | ) 667 | 668 | def __init__(self, e=None,): 669 | self.e = e 670 | 671 | def read(self, iprot): 672 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 673 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 674 | return 675 | iprot.readStructBegin() 676 | while True: 677 | (fname, ftype, fid) = iprot.readFieldBegin() 678 | if ftype == TType.STOP: 679 | break 680 | if fid == 1: 681 | if ftype == TType.STRUCT: 682 | self.e = TalkException() 683 | self.e.read(iprot) 684 | else: 685 | iprot.skip(ftype) 686 | else: 687 | iprot.skip(ftype) 688 | iprot.readFieldEnd() 689 | iprot.readStructEnd() 690 | 691 | def write(self, oprot): 692 | if oprot._fast_encode is not None and self.thrift_spec is not None: 693 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 694 | return 695 | oprot.writeStructBegin('postSnsInvitationMessage_result') 696 | if self.e is not None: 697 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 698 | self.e.write(oprot) 699 | oprot.writeFieldEnd() 700 | oprot.writeFieldStop() 701 | oprot.writeStructEnd() 702 | 703 | def validate(self): 704 | return 705 | 706 | def __repr__(self): 707 | L = ['%s=%r' % (key, value) 708 | for key, value in self.__dict__.items()] 709 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 710 | 711 | def __eq__(self, other): 712 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 713 | 714 | def __ne__(self, other): 715 | return not (self == other) 716 | -------------------------------------------------------------------------------- /PB/UniversalNotificationService.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.10.0) 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | # options string: py 7 | # 8 | 9 | from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException 10 | from thrift.protocol.TProtocol import TProtocolException 11 | import sys 12 | import logging 13 | from .ttypes import * 14 | from thrift.Thrift import TProcessor 15 | from thrift.transport import TTransport 16 | 17 | 18 | class Iface(object): 19 | def notify(self, event): 20 | """ 21 | Parameters: 22 | - event 23 | """ 24 | pass 25 | 26 | 27 | class Client(Iface): 28 | def __init__(self, iprot, oprot=None): 29 | self._iprot = self._oprot = iprot 30 | if oprot is not None: 31 | self._oprot = oprot 32 | self._seqid = 0 33 | 34 | def notify(self, event): 35 | """ 36 | Parameters: 37 | - event 38 | """ 39 | self.send_notify(event) 40 | self.recv_notify() 41 | 42 | def send_notify(self, event): 43 | self._oprot.writeMessageBegin('notify', TMessageType.CALL, self._seqid) 44 | args = notify_args() 45 | args.event = event 46 | args.write(self._oprot) 47 | self._oprot.writeMessageEnd() 48 | self._oprot.trans.flush() 49 | 50 | def recv_notify(self): 51 | iprot = self._iprot 52 | (fname, mtype, rseqid) = iprot.readMessageBegin() 53 | if mtype == TMessageType.EXCEPTION: 54 | x = TApplicationException() 55 | x.read(iprot) 56 | iprot.readMessageEnd() 57 | raise x 58 | result = notify_result() 59 | result.read(iprot) 60 | iprot.readMessageEnd() 61 | if result.e is not None: 62 | raise result.e 63 | return 64 | 65 | 66 | class Processor(Iface, TProcessor): 67 | def __init__(self, handler): 68 | self._handler = handler 69 | self._processMap = {} 70 | self._processMap["notify"] = Processor.process_notify 71 | 72 | def process(self, iprot, oprot): 73 | (name, type, seqid) = iprot.readMessageBegin() 74 | if name not in self._processMap: 75 | iprot.skip(TType.STRUCT) 76 | iprot.readMessageEnd() 77 | x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) 78 | oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) 79 | x.write(oprot) 80 | oprot.writeMessageEnd() 81 | oprot.trans.flush() 82 | return 83 | else: 84 | self._processMap[name](self, seqid, iprot, oprot) 85 | return True 86 | 87 | def process_notify(self, seqid, iprot, oprot): 88 | args = notify_args() 89 | args.read(iprot) 90 | iprot.readMessageEnd() 91 | result = notify_result() 92 | try: 93 | self._handler.notify(args.event) 94 | msg_type = TMessageType.REPLY 95 | except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): 96 | raise 97 | except UniversalNotificationServiceException as e: 98 | msg_type = TMessageType.REPLY 99 | result.e = e 100 | except Exception as ex: 101 | msg_type = TMessageType.EXCEPTION 102 | logging.exception(ex) 103 | result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') 104 | oprot.writeMessageBegin("notify", msg_type, seqid) 105 | result.write(oprot) 106 | oprot.writeMessageEnd() 107 | oprot.trans.flush() 108 | 109 | # HELPER FUNCTIONS AND STRUCTURES 110 | 111 | 112 | class notify_args(object): 113 | """ 114 | Attributes: 115 | - event 116 | """ 117 | 118 | thrift_spec = ( 119 | None, # 0 120 | None, # 1 121 | (2, TType.STRUCT, 'event', (GlobalEvent, GlobalEvent.thrift_spec), None, ), # 2 122 | ) 123 | 124 | def __init__(self, event=None,): 125 | self.event = event 126 | 127 | def read(self, iprot): 128 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 129 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 130 | return 131 | iprot.readStructBegin() 132 | while True: 133 | (fname, ftype, fid) = iprot.readFieldBegin() 134 | if ftype == TType.STOP: 135 | break 136 | if fid == 2: 137 | if ftype == TType.STRUCT: 138 | self.event = GlobalEvent() 139 | self.event.read(iprot) 140 | else: 141 | iprot.skip(ftype) 142 | else: 143 | iprot.skip(ftype) 144 | iprot.readFieldEnd() 145 | iprot.readStructEnd() 146 | 147 | def write(self, oprot): 148 | if oprot._fast_encode is not None and self.thrift_spec is not None: 149 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 150 | return 151 | oprot.writeStructBegin('notify_args') 152 | if self.event is not None: 153 | oprot.writeFieldBegin('event', TType.STRUCT, 2) 154 | self.event.write(oprot) 155 | oprot.writeFieldEnd() 156 | oprot.writeFieldStop() 157 | oprot.writeStructEnd() 158 | 159 | def validate(self): 160 | return 161 | 162 | def __repr__(self): 163 | L = ['%s=%r' % (key, value) 164 | for key, value in self.__dict__.items()] 165 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 166 | 167 | def __eq__(self, other): 168 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 169 | 170 | def __ne__(self, other): 171 | return not (self == other) 172 | 173 | 174 | class notify_result(object): 175 | """ 176 | Attributes: 177 | - e 178 | """ 179 | 180 | thrift_spec = ( 181 | None, # 0 182 | (1, TType.STRUCT, 'e', (UniversalNotificationServiceException, UniversalNotificationServiceException.thrift_spec), None, ), # 1 183 | ) 184 | 185 | def __init__(self, e=None,): 186 | self.e = e 187 | 188 | def read(self, iprot): 189 | if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: 190 | iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) 191 | return 192 | iprot.readStructBegin() 193 | while True: 194 | (fname, ftype, fid) = iprot.readFieldBegin() 195 | if ftype == TType.STOP: 196 | break 197 | if fid == 1: 198 | if ftype == TType.STRUCT: 199 | self.e = UniversalNotificationServiceException() 200 | self.e.read(iprot) 201 | else: 202 | iprot.skip(ftype) 203 | else: 204 | iprot.skip(ftype) 205 | iprot.readFieldEnd() 206 | iprot.readStructEnd() 207 | 208 | def write(self, oprot): 209 | if oprot._fast_encode is not None and self.thrift_spec is not None: 210 | oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) 211 | return 212 | oprot.writeStructBegin('notify_result') 213 | if self.e is not None: 214 | oprot.writeFieldBegin('e', TType.STRUCT, 1) 215 | self.e.write(oprot) 216 | oprot.writeFieldEnd() 217 | oprot.writeFieldStop() 218 | oprot.writeStructEnd() 219 | 220 | def validate(self): 221 | return 222 | 223 | def __repr__(self): 224 | L = ['%s=%r' % (key, value) 225 | for key, value in self.__dict__.items()] 226 | return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) 227 | 228 | def __eq__(self, other): 229 | return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ 230 | 231 | def __ne__(self, other): 232 | return not (self == other) 233 | -------------------------------------------------------------------------------- /PB/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['ttypes', 'constants', 'AccountSupervisorService', 'AgeCheckService', 'BuddyManagementService', 'BuddyService', 'ChannelApplicationProvidedService', 'ChannelService', 'MessageService', 'ShopService', 'SnsAdaptorService', 'TalkService', 'UniversalNotificationService', 'CallService', 'AuthService', 'SquareService'] 2 | -------------------------------------------------------------------------------- /PB/__pycache__/CallService.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/CallService.cpython-34.pyc -------------------------------------------------------------------------------- /PB/__pycache__/CallService.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/CallService.cpython-35.pyc -------------------------------------------------------------------------------- /PB/__pycache__/CallService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/CallService.cpython-36.pyc -------------------------------------------------------------------------------- /PB/__pycache__/ChannelService.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/ChannelService.cpython-34.pyc -------------------------------------------------------------------------------- /PB/__pycache__/ChannelService.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/ChannelService.cpython-35.pyc -------------------------------------------------------------------------------- /PB/__pycache__/ChannelService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/ChannelService.cpython-36.pyc -------------------------------------------------------------------------------- /PB/__pycache__/TalkService.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/TalkService.cpython-34.pyc -------------------------------------------------------------------------------- /PB/__pycache__/TalkService.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/TalkService.cpython-35.pyc -------------------------------------------------------------------------------- /PB/__pycache__/TalkService.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/TalkService.cpython-36.pyc -------------------------------------------------------------------------------- /PB/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /PB/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /PB/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /PB/__pycache__/ttypes.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/ttypes.cpython-34.pyc -------------------------------------------------------------------------------- /PB/__pycache__/ttypes.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/ttypes.cpython-35.pyc -------------------------------------------------------------------------------- /PB/__pycache__/ttypes.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PB/__pycache__/ttypes.cpython-36.pyc -------------------------------------------------------------------------------- /PB/constants.py: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift Compiler (0.10.0) 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | # options string: py 7 | # 8 | 9 | from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException 10 | from thrift.protocol.TProtocol import TProtocolException 11 | import sys 12 | from .ttypes import * 13 | -------------------------------------------------------------------------------- /PRANKBOTS/__init__.py: -------------------------------------------------------------------------------- 1 | from .client import LineClient 2 | from .channel import LineChannel 3 | from .call import LineCall 4 | from .poll import LinePoll 5 | from .server import LineServer 6 | from PB.ttypes import OpType 7 | 8 | __copyright__ = 'Copyright 2017 by Fadhiil Rachman' 9 | __version__ = '1.8.4' 10 | __license__ = 'BSD-3-Clause' 11 | __author__ = 'Fadhiil Rachman' 12 | __author_email__ = 'fadhiilrachman@gmail.com' 13 | __url__ = 'http://github.com/fadhiilrachman/line-py' 14 | 15 | __all__ = ['LineClient', 'LineChannel', 'LineCall', 'LinePoll', 'LineServer', 'OpType'] -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/Acil: -------------------------------------------------------------------------------- 1 | Crot 2 | -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/api.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/api.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/api.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/api.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/api.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/api.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/api.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/api.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/call.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/call.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/call.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/call.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/call.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/call.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/call.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/call.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/callback.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/callback.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/callback.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/callback.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/callback.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/callback.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/callback.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/callback.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/channel.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/channel.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/channel.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/channel.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/channel.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/channel.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/channel.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/channel.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/client.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/client.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/client.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/client.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/client.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/client.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/client.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/client.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/models.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/models.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/models.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/models.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/models.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/models.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/object.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/object.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/object.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/object.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/object.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/object.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/object.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/object.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/poll.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/poll.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/poll.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/poll.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/poll.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/poll.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/poll.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/poll.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/server.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/server.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/server.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/server.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/server.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/server.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/server.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/server.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/session.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/session.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/session.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/session.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/session.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/session.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/session.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/session.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/timeline.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/timeline.cpython-34.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/timeline.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/timeline.cpython-35.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/timeline.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/timeline.cpython-36.pyc -------------------------------------------------------------------------------- /PRANKBOTS/__pycache__/timeline.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/PRANKBOTS/__pycache__/timeline.cpython-37.pyc -------------------------------------------------------------------------------- /PRANKBOTS/api.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from PB.ttypes import IdentityProvider, LoginResultType 3 | from .server import LineServer 4 | from .session import LineSession 5 | from .callback import LineCallback 6 | 7 | import rsa, os 8 | 9 | class LineApi(object): 10 | isLogin = False 11 | authToken = "" 12 | certificate = "" 13 | 14 | def __init__(self): 15 | self.server = LineServer() 16 | self.callback = LineCallback(self.defaultCallback) 17 | self.server.setHeadersWithDict({ 18 | 'User-Agent': self.server.USER_AGENT, 19 | 'X-Line-Application': self.server.APP_NAME, 20 | 'X-Line-Carrier': self.server.CARRIER 21 | }) 22 | 23 | def loadSession(self): 24 | self._client = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_API_QUERY_PATH_FIR).Talk() 25 | self.poll = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_POLL_QUERY_PATH_FIR).Talk() 26 | self.call = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_CALL_QUERY_PATH).Call() 27 | self.channel = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_CHAN_QUERY_PATH).Channel() 28 | #self.square = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_SQUARE_QUERY_PATH).Square() 29 | 30 | self.revision = self.poll.getLastOpRevision() 31 | self.isLogin = True 32 | 33 | def login(self, _id, passwd, certificate=None, systemName=None, phoneName=None, keepLoggedIn=True): 34 | systemName=self.server.SYSTEM_NAME 35 | if self.server.EMAIL_REGEX.match(_id): 36 | self.provider = IdentityProvider.LINE # LINE 37 | else: 38 | self.provider = IdentityProvider.NAVER_KR # NAVER 39 | 40 | if phoneName is None: 41 | phoneName=self.server.APP_NAME 42 | self.server.setHeaders('X-Line-Application', phoneName) 43 | self._client = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_AUTH_QUERY_PATH).Talk(isopen=False) 44 | 45 | rsaKey = self._client.getRSAKeyInfo(self.provider) 46 | 47 | message = (chr(len(rsaKey.sessionKey)) + rsaKey.sessionKey + 48 | chr(len(_id)) + _id + 49 | chr(len(passwd)) + passwd).encode('utf-8') 50 | pub_key = rsa.PublicKey(int(rsaKey.nvalue, 16), int(rsaKey.evalue, 16)) 51 | try: 52 | # Works with python 2.7 53 | crypto = rsa.encrypt(message, pub_key).encode('hex') 54 | except: 55 | # Works with python 3.x 56 | crypto = rsa.encrypt(message, pub_key).hex() 57 | 58 | try: 59 | with open(_id + '.crt', 'r') as f: 60 | self.certificate = f.read() 61 | except: 62 | if certificate is not None: 63 | self.certificate = certificate 64 | if os.path.exists(certificate): 65 | with open(certificate, 'r') as f: 66 | self.certificate = f.read() 67 | 68 | result = self._client.loginWithIdentityCredentialForCertificate( 69 | self.provider, rsaKey.keynm, crypto, keepLoggedIn, self.server.IP_ADDR, systemName, self.certificate 70 | ) 71 | 72 | if result.type == LoginResultType.REQUIRE_DEVICE_CONFIRM: 73 | self.callback.PinVerified(result.pinCode) 74 | 75 | self.server.setHeaders('X-Line-Access', result.verifier) 76 | getAccessKey = self.server.getJson(self.server.parseUrl(self.server.LINE_CERTIFICATE_PATH), allowHeader=True) 77 | 78 | self._client = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_AUTH_QUERY_PATH).Talk(isopen=False) 79 | try: 80 | result = self._client.loginWithVerifierForCertificate(getAccessKey['result']['verifier']) 81 | except: 82 | raise Exception("Login failed") 83 | 84 | if result.type == LoginResultType.SUCCESS: 85 | if result.certificate is not None: 86 | with open(_id + '.crt', 'w') as f: 87 | f.write(result.certificate) 88 | self.certificate = result.certificate 89 | if result.authToken is not None: 90 | self.tokenLogin(result.authToken, phoneName) 91 | else: 92 | return False 93 | else: 94 | raise Exception("Login failed") 95 | 96 | elif result.type == LoginResultType.REQUIRE_QRCODE: 97 | self.qrLogin(keepLoggedIn, systemName, phoneName) 98 | pass 99 | 100 | elif result.type == LoginResultType.SUCCESS: 101 | self.certificate = result.certificate 102 | self.tokenLogin(result.authToken, phoneName) 103 | 104 | def qrLogin(self, keepLoggedIn=True, systemName=None, appName=None, showQr=False): 105 | systemName=self.server.SYSTEM_NAME 106 | if appName is None: 107 | appName=self.server.APP_NAME 108 | self.server.setHeaders('X-Line-Application', appName) 109 | 110 | self._client = LineSession(self.server.LINE_HOST_DOMAIN, self.server.Headers, self.server.LINE_AUTH_QUERY_PATH).Talk(isopen=False) 111 | qrCode = self._client.getAuthQrcode(keepLoggedIn, systemName) 112 | 113 | self.callback.QrUrl("https://line.me/R/au/q/" + qrCode.verifier, showQr) 114 | self.server.setHeaders('X-Line-Access', qrCode.verifier) 115 | 116 | getAccessKey = self.server.getJson(self.server.parseUrl(self.server.LINE_CERTIFICATE_PATH), allowHeader=True) 117 | result = self._client.loginWithVerifierForCertificate( getAccessKey['result']['verifier'] ) 118 | 119 | self.tokenLogin(result.authToken, appName) 120 | 121 | def tokenLogin(self, authToken=None, appOrPhoneName=None): 122 | if authToken is None: 123 | raise Exception('Please provide Auth Token') 124 | if appOrPhoneName is None: 125 | appOrPhoneName=self.server.APP_NAME 126 | self.server.setHeadersWithDict({ 127 | 'X-Line-Application': appOrPhoneName, 128 | 'X-Line-Access': authToken 129 | }) 130 | self.authToken = authToken 131 | self.loadSession() 132 | 133 | def defaultCallback(self, str): 134 | print(str) 135 | 136 | def logout(self): 137 | self._client.logoutSession(self.authToken) 138 | -------------------------------------------------------------------------------- /PRANKBOTS/call.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .client import LineClient 3 | from PB.ttypes import MediaType 4 | from types import * 5 | 6 | def loggedIn(func): 7 | def checkLogin(*args, **kwargs): 8 | if args[0].isLogin: 9 | return func(*args, **kwargs) 10 | else: 11 | args[0].callback.other("You want to call the function, you must login to LINE") 12 | return checkLogin 13 | 14 | class LineCall(object): 15 | isLogin = False 16 | client = None 17 | 18 | def __init__(self, client): 19 | if type(client) is not LineClient: 20 | raise Exception("You need to set LineClient instance to initialize LineCall") 21 | self.client = client 22 | 23 | def acquireCallRoute(self, to): 24 | return self.client.call.acquireCallRoute(to) 25 | 26 | def acquireGroupCallRoute(self, groupId, mediaType=MediaType.AUDIO): 27 | return self.client.call.acquireGroupCallRoute(groupId, mediaType) 28 | 29 | def getGroupCall(self, ChatMid): 30 | return self.client.call.getGroupCall(ChatMid) 31 | 32 | def inviteIntoGroupCall(self, chatId, contactIds=[], mediaType=MediaType.AUDIO): 33 | return self.client.call.inviteIntoGroupCall(chatId, contactIds, mediaType) 34 | -------------------------------------------------------------------------------- /PRANKBOTS/callback.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | class LineCallback(object): 3 | 4 | def __init__(self, callback): 5 | self.callback = callback 6 | 7 | def PinVerified(self, pin): 8 | self.callback("Masukkan kode pin berikut '" + pin + "' kedalam aplikasi LINE mu dalam 2 menit") 9 | 10 | def QrUrl(self, url, showQr=True): 11 | self.callback("Salin link berikut dan pastekan pada alikasi LINE mu kemudian klik dalam 2 menit \n" + url) 12 | if showQr: 13 | import pyqrcode 14 | url = pyqrcode.create(url) 15 | self.callback(url.terminal('green', 'white', 1)) 16 | 17 | def default(self, str): 18 | self.callback(str) -------------------------------------------------------------------------------- /PRANKBOTS/channel.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .client import LineClient 3 | from .timeline import LineTimeline 4 | from types import * 5 | 6 | class LineChannel(LineTimeline): 7 | isLogin = False 8 | channelId = None 9 | profileDetail = None 10 | 11 | client = None 12 | server = None 13 | 14 | channelAccessToken = None 15 | channelToken = None 16 | obsToken = None 17 | channelRefreshToken = None 18 | channelTokenExpiration = None 19 | 20 | def __init__(self, client, channelId=None): 21 | if type(client) is not LineClient: 22 | raise Exception("You need to set LineClient instance to initialize LineChannel") 23 | self.client = client 24 | self.server = client.server 25 | self.channelId = channelId 26 | self.login() 27 | 28 | def login(self): 29 | if self.channelId is None: 30 | self.channelId=self.server.CHANNEL_ID['LINE_TIMELINE'] 31 | result = self.approveChannelAndIssueChannelToken(self.channelId) 32 | 33 | self.channelAccessToken = result.channelAccessToken 34 | self.channelToken = result.token 35 | self.obsToken = result.obsToken 36 | self.channelRefreshToken = result.refreshToken 37 | self.channelTokenExpiration = result.expiration 38 | self.isLogin = True 39 | 40 | self.createSession() 41 | 42 | def createSession(self): 43 | if self.isLogin: 44 | self.server.setChannelHeadersWithDict({ 45 | 'Content-Type': 'application/json', 46 | 'User-Agent': self.server.USER_AGENT, 47 | 'X-Line-Mid': self.client.profile.mid, 48 | 'X-Line-Carrier': self.server.CARRIER, 49 | 'X-Line-Application': self.server.APP_NAME, 50 | 'X-Line-ChannelToken': self.channelAccessToken 51 | }) 52 | channelInfo = self.getChannelInfo(self.channelId) 53 | if self.channelId == self.server.CHANNEL_ID['LINE_TIMELINE']: 54 | LineTimeline.__init__(self) 55 | self.profileDetail = self.getProfileDetail() 56 | self.client.setChannelToModels(self) 57 | self.client.log('[%s] : Berhasil login ke %s' % (self.client.profile.displayName, channelInfo.name)) 58 | 59 | def approveChannelAndIssueChannelToken(self, channelId): 60 | return self.client.channel.approveChannelAndIssueChannelToken(channelId) 61 | 62 | def issueChannelToken(self, channelId): 63 | return self.client.channel.issueChannelToken(channelId) 64 | 65 | def getChannelInfo(self, channelId, locale='EN'): 66 | return self.client.channel.getChannelInfo(channelId, locale) 67 | 68 | def revokeChannel(self, channelId): 69 | return self.client.channel.revokeChannel(channelId) -------------------------------------------------------------------------------- /PRANKBOTS/client.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from PB.ttypes import Message 3 | from .api import LineApi 4 | from .models import LineModels 5 | from random import randint 6 | 7 | import json, requests, re 8 | 9 | def loggedIn(func): 10 | def checkLogin(*args, **kwargs): 11 | if args[0].isLogin: 12 | return func(*args, **kwargs) 13 | else: 14 | args[0].callback.other("You must login to LINE") 15 | return checkLogin 16 | 17 | class LineClient(LineApi, LineModels): 18 | 19 | def __init__(self, id=None, passwd=None, authToken=None, certificate=None, systemName=None, showQr=False, appName=None, phoneName=None, keepLoggedIn=True): 20 | 21 | LineApi.__init__(self) 22 | 23 | if not (authToken or id and passwd): 24 | self.qrLogin(keepLoggedIn=keepLoggedIn, systemName=systemName, appName=appName, showQr=showQr) 25 | if authToken: 26 | if appName: 27 | appOrPhoneName = appName 28 | elif phoneName: 29 | appOrPhoneName = phoneName 30 | self.tokenLogin(authToken=authToken, appOrPhoneName=appName) 31 | if id and passwd: 32 | self.login(_id=id, passwd=passwd, certificate=certificate, systemName=systemName, phoneName=phoneName, keepLoggedIn=keepLoggedIn) 33 | 34 | self._messageReq = {} 35 | self.profile = self._client.getProfile() 36 | self.groups = self._client.getGroupIdsJoined() 37 | 38 | LineModels.__init__(self) 39 | 40 | """User""" 41 | 42 | @loggedIn 43 | def getProfile(self): 44 | return self._client.getProfile() 45 | 46 | @loggedIn 47 | def getSettings(self): 48 | return self._client.getSettings() 49 | 50 | @loggedIn 51 | def getUserTicket(self): 52 | return self._client.getUserTicket() 53 | 54 | @loggedIn 55 | def updateProfile(self, profileObject): 56 | return self._client.updateProfile(0, profileObject) 57 | 58 | @loggedIn 59 | def updateSettings(self, settingObject): 60 | return self._client.updateSettings(0, settingObject) 61 | 62 | @loggedIn 63 | def updateProfileAttribute(self, attrId, value): 64 | return self._client.updateProfileAttribute(0, attrId, value) 65 | 66 | """Operation""" 67 | 68 | @loggedIn 69 | def fetchOperation(self, revision, count): 70 | return self._client.fetchOperations(revision, count) 71 | 72 | @loggedIn 73 | def getLastOpRevision(self): 74 | return self._client.getLastOpRevision() 75 | 76 | """Message""" 77 | 78 | @loggedIn 79 | def sendMessage(self, to, text, contentMetadata={}, contentType=0): 80 | msg = Message() 81 | msg.to, msg._from = to, self.profile.mid 82 | msg.text = text 83 | msg.contentType, msg.contentMetadata = contentType, contentMetadata 84 | if to not in self._messageReq: 85 | self._messageReq[to] = -1 86 | self._messageReq[to] += 1 87 | try: message = self._client.sendMessage(self._messageReq[to], msg) 88 | except Exception as e: print(e) 89 | return message 90 | 91 | """ Usage: 92 | @to Integer 93 | @text String 94 | @dataMid List of user Mid 95 | """ 96 | @loggedIn 97 | def sendText(self, Tomid, text): 98 | msg = Message() 99 | msg.to = Tomid 100 | msg.text = text 101 | 102 | return self._client.sendMessage(0, msg) 103 | 104 | @loggedIn 105 | def sendMessage1(self, messageObject): 106 | return self._client.sendMessage(0,messageObject) 107 | 108 | @loggedIn 109 | def sendMessageWithMention(self, to, text='', dataMid=[]): 110 | arr = [] 111 | list_text='' 112 | if '[list]' in text: 113 | i=0 114 | for l in dataMid: 115 | list_text+='\n@[list-'+str(i)+']' 116 | i=i+1 117 | text=text.replace('[list]', list_text) 118 | elif '[list-' in text: 119 | text=text 120 | else: 121 | i=0 122 | for l in dataMid: 123 | list_text+=' @[list-'+str(i)+']' 124 | i=i+1 125 | text=text+list_text 126 | i=0 127 | for l in dataMid: 128 | mid=l 129 | name='@[list-'+str(i)+']' 130 | ln_text=text.replace('\n',' ') 131 | if ln_text.find(name): 132 | line_s=int(ln_text.index(name)) 133 | line_e=(int(line_s)+int(len(name))) 134 | arrData={'S': str(line_s), 'E': str(line_e), 'M': mid} 135 | arr.append(arrData) 136 | i=i+1 137 | contentMetadata={'MENTION':str('{"MENTIONEES":' + json.dumps(arr).replace(' ','') + '}')} 138 | return self.sendMessage(to, text, contentMetadata) 139 | @loggedIn 140 | def mention(self, to, nama): 141 | aa = "" 142 | bb = "" 143 | strt = int(0) 144 | akh = int(0) 145 | nm = nama 146 | myid = self.talk.getProfile().mid 147 | if myid in nm: 148 | nm.remove(myid) 149 | for mm in nm: 150 | akh = akh + 6 151 | aa += """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(mm)+"},""" 152 | strt = strt + 7 153 | akh = akh + 1 154 | bb += "@nrik \n" 155 | aa = (aa[:int(len(aa)-1)]) 156 | text = bb 157 | try: 158 | msg = Message() 159 | msg.to = to 160 | msg.text = text 161 | msg.contentMetadata = {'MENTION':'{"MENTIONEES":['+aa+']}'} 162 | msg.contentType = 0 163 | self.talk.sendMessage(0, msg) 164 | except Exception as error: 165 | print(error, 'def Mention') 166 | @loggedIn 167 | def sendSticker(self, to, packageId, stickerId): 168 | contentMetadata = { 169 | 'STKVER': '100', 170 | 'STKPKGID': packageId, 171 | 'STKID': stickerId 172 | } 173 | return self.sendMessage(to, '', contentMetadata, 7) 174 | 175 | @loggedIn 176 | def sendContact(self, to, mid): 177 | contentMetadata = {'mid': mid} 178 | return self.sendMessage(to, '', contentMetadata, 13) 179 | 180 | @loggedIn 181 | def sendGift(self, productId, productType): 182 | if productType not in ['theme','sticker']: 183 | raise Exception('Invalid productType value') 184 | contentMetadata = { 185 | 'MSGTPL': str(randint(0, 12)), 186 | 'PRDTYPE': productType.upper(), 187 | 'STKPKGID' if productType == 'sticker' else 'PRDID': productId 188 | } 189 | return self.sendMessage(to, '', contentMetadata, 9) 190 | 191 | @loggedIn 192 | def removeMessage(self, messageId): 193 | return self._client.removeMessage(messageId) 194 | 195 | @loggedIn 196 | def removeAllMessages(self, lastMessageId): 197 | return self._client.removeAllMessages(0, lastMessageId) 198 | 199 | @loggedIn 200 | def sendChatChecked(self, consumer, messageId): 201 | return self._client.sendChatChecked(0, consumer, messageId) 202 | 203 | @loggedIn 204 | def sendEvent(self, messageObject): 205 | return self._client.sendEvent(0, messageObject) 206 | 207 | @loggedIn 208 | def getLastReadMessageIds(self, chatId): 209 | return self._client.getLastReadMessageIds(0,chatId) 210 | 211 | """Contact""" 212 | 213 | @loggedIn 214 | def blockContact(self, mid): 215 | return self._client.blockContact(0, mid) 216 | 217 | @loggedIn 218 | def unblockContact(self, mid): 219 | return self._client.unblockContact(0, mid) 220 | 221 | @loggedIn 222 | def findAndAddContactsByMid(self, mid): 223 | return self._client.findAndAddContactsByMid(0, mid) 224 | 225 | @loggedIn 226 | def findAndAddContactsByUserid(self, userid): 227 | return self._client.findAndAddContactsByUserid(0, userid) 228 | 229 | @loggedIn 230 | def findContactsByUserid(self, userid): 231 | return self._client.findContactByUserid(userid) 232 | 233 | @loggedIn 234 | def findContactByTicket(self, ticketId): 235 | return self._client.findContactByUserTicket(ticketId) 236 | 237 | @loggedIn 238 | def getAllContactIds(self): 239 | return self._client.getAllContactIds() 240 | 241 | @loggedIn 242 | def getBlockedContactIds(self): 243 | return self._client.getBlockedContactIds() 244 | 245 | @loggedIn 246 | def getContact(self, mid): 247 | return self._client.getContact(mid) 248 | 249 | @loggedIn 250 | def getContacts(self, midlist): 251 | return self._client.getContacts(midlist) 252 | 253 | @loggedIn 254 | def getFavoriteMids(self): 255 | return self._client.getFavoriteMids() 256 | 257 | @loggedIn 258 | def getHiddenContactMids(self): 259 | return self._client.getHiddenContactMids() 260 | 261 | @loggedIn 262 | def reissueUserTicket(self, expirationTime=100, maxUseCount=100): 263 | return self._client.reissueUserTicket(expirationTime, maxUseCount) 264 | 265 | @loggedIn 266 | def cloneContactProfile(self, mid): 267 | contact = self.getContact(mid) 268 | profile = self.profile 269 | profile.displayName = contact.displayName 270 | profile.statusMessage = contact.statusMessage 271 | profile.pictureStatus = contact.pictureStatus 272 | self.updateProfileAttribute(8, profile.pictureStatus) 273 | return self.updateProfile(profile) 274 | 275 | """Group""" 276 | 277 | @loggedIn 278 | def findGroupByTicket(self, ticketId): 279 | return self._client.findGroupByTicket(ticketId) 280 | 281 | @loggedIn 282 | def acceptGroupInvitation(self, groupId): 283 | return self._client.acceptGroupInvitation(0, groupId) 284 | 285 | @loggedIn 286 | def acceptGroupInvitationByTicket(self, groupId, ticketId): 287 | return self._client.acceptGroupInvitationByTicket(0, groupId, ticketId) 288 | 289 | @loggedIn 290 | def cancelGroupInvitation(self, groupId, contactIds): 291 | return self._client.cancelGroupInvitation(0, groupId, contactIds) 292 | 293 | @loggedIn 294 | def createGroup(self, name, midlist): 295 | return self._client.createGroup(0, name, midlist) 296 | 297 | @loggedIn 298 | def getGroup(self, groupId): 299 | return self._client.getGroup(groupId) 300 | 301 | @loggedIn 302 | def getGroups(self, groupIds): 303 | return self._client.getGroups(groupIds) 304 | 305 | @loggedIn 306 | def getGroupIdsInvited(self): 307 | return self._client.getGroupIdsInvited() 308 | 309 | @loggedIn 310 | def getGroupIdsJoined(self): 311 | return self._client.getGroupIdsJoined() 312 | 313 | @loggedIn 314 | def inviteIntoGroup(self, groupId, midlist): 315 | return self._client.inviteIntoGroup(0, groupId, midlist) 316 | 317 | @loggedIn 318 | def kickoutFromGroup(self, groupId, midlist): 319 | return self._client.kickoutFromGroup(0, groupId, midlist) 320 | 321 | @loggedIn 322 | def leaveGroup(self, groupId): 323 | return self._client.leaveGroup(0, groupId) 324 | 325 | @loggedIn 326 | def rejectGroupInvitation(self, groupId): 327 | return self._client.rejectGroupInvitation(0, groupId) 328 | 329 | @loggedIn 330 | def reissueGroupTicket(self, groupId): 331 | return self._client.reissueGroupTicket(groupId) 332 | 333 | @loggedIn 334 | def updateGroup(self, groupObject): 335 | return self._client.updateGroup(0, groupObject) 336 | 337 | """Room""" 338 | 339 | @loggedIn 340 | def createRoom(self, midlist): 341 | return self._client.createRoom(0, midlist) 342 | 343 | @loggedIn 344 | def getRoom(self, roomId): 345 | return self._client.getRoom(roomId) 346 | 347 | @loggedIn 348 | def inviteIntoRoom(self, roomId, midlist): 349 | return self._client.inviteIntoRoom(0, roomId, midlist) 350 | 351 | @loggedIn 352 | def leaveRoom(self, roomId): 353 | return self._client.leaveRoom(0, roomId) 354 | 355 | """Call""" 356 | 357 | @loggedIn 358 | def acquireCallRoute(self, to): 359 | return self._client.acquireCallRoute(to) 360 | 361 | """Manga""" 362 | def getMangaSource(self): 363 | get = requests.get(self.server.MANGA_READER_API_HOST) 364 | sources = get.json() 365 | mangaSource = [] 366 | for source in sources: 367 | ID = str(source["id"]) 368 | name = source["name"] 369 | language = source["lang_name"] 370 | src = { 371 | 'ID':ID, 372 | 'name':name, 373 | 'language':language 374 | } 375 | mangaSource.append(src) 376 | return mangaSource 377 | 378 | def getMangaRank(self, sourceID): 379 | get = requests.get(self.server.MANGA_READER_API_HOST+sourceID) 380 | mangas = get.json() 381 | mangaList = [] 382 | for manga in mangas: 383 | ID = str(manga["id"]) 384 | rank = str(manga["rank"]) 385 | name = manga["name"] 386 | mangaList.append(name+"(#"+rank+") ID: "+ID) 387 | mangaList.sort(key=self.naturalKeys) 388 | return mangaList 389 | 390 | def getMangaRankMatched(self, sourceID, name): 391 | mangaLists = [x.lower() for x in self.getMangaRank(sourceID)] 392 | matching = [s for s in mangaLists if name in s] 393 | return matching 394 | 395 | def getMangaDetailed(self, sourceID, mangaID): 396 | get = requests.get(self.server.MANGA_READER_API_HOST+sourceID+"/"+mangaID) 397 | detail = get.json() 398 | rank = str(detail["rank"]) 399 | categories = str(detail["categories"]) 400 | name = detail["name"] 401 | author = detail["author"] 402 | description = detail["des"] 403 | totalChapters = str(len(detail["chapters"])) 404 | image = detail["image"] 405 | output = "Rank: "+rank+"\nName: "+name+"\nAuthor: "+author+"\nTotal Chapters: "+totalChapters+"\n\nDescription:\n"+description 406 | return {'details':output, 'thumb':image, 'chapters':detail["chapters"]} 407 | 408 | def getMangaImage(self, sourceID, mangaID, chapterID): 409 | get = requests.get(self.server.MANGA_READER_API_HOST+sourceID+"/"+mangaID+"?cid="+chapterID) 410 | chapters = get.json() 411 | return chapters 412 | 413 | """Others""" 414 | def textCheck(self, text): 415 | return int(text) if text.isdigit() else text 416 | 417 | def naturalKeys(self, text): 418 | return [ self.textCheck(c) for c in re.split('(\d+)', text) ] 419 | 420 | def sendMessageV2(self, message): 421 | return self._client.sendMessage(0, message) 422 | -------------------------------------------------------------------------------- /PRANKBOTS/models.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from datetime import datetime 3 | from .object import LineObject 4 | from random import randint 5 | 6 | import json, shutil, time, os, base64, tempfile 7 | 8 | class LineModels(LineObject): 9 | 10 | _channel = None 11 | 12 | def __init__(self): 13 | LineObject.__init__(self) 14 | 15 | def setChannelToModels(self, channel): 16 | self._channel = channel 17 | 18 | """Text""" 19 | 20 | def log(self, text): 21 | print("[%s] %s" % (str(datetime.now()), text)) 22 | 23 | """File""" 24 | 25 | def deleteFile(self, path): 26 | if os.path.exists(path): 27 | os.remove(path) 28 | return True 29 | else: 30 | return False 31 | 32 | def downloadFileURL(self, fileUrl, returnAs='path', saveAs=''): 33 | if returnAs not in ['path','bool','bin']: 34 | raise Exception('Invalid returnAs value') 35 | if saveAs == '': 36 | saveAs = self.genTempFile() 37 | r = self.server.getContent(fileUrl) 38 | if r.status_code == 200: 39 | with open(saveAs, 'wb') as f: 40 | shutil.copyfileobj(r.raw, f) 41 | if returnAs == 'path': 42 | return saveAs 43 | elif returnAs == 'bool': 44 | return True 45 | elif returnAs == 'bin': 46 | return r.raw 47 | else: 48 | raise Exception('Download file failure.') 49 | 50 | """Generator""" 51 | 52 | def genTempFile(self, returnAs='path'): 53 | try: 54 | if returnAs not in ['file','path']: 55 | raise Exception('Invalid returnAs value') 56 | fName, fPath = 'linepy-%s-%i.bin' % (int(time.time()), randint(0, 9)), tempfile.gettempdir() 57 | if returnAs == 'file': 58 | return fName 59 | elif returnAs == 'path': 60 | return '%s/%s' % (fPath, fName) 61 | except: 62 | raise Exception('tempfile is required') 63 | 64 | def genOBSParams(self, newList, returnAs='json'): 65 | oldList = {'name': self.genTempFile('file'),'ver': '1.0'} 66 | if returnAs not in ['json','b64','default']: 67 | raise Exception('Invalid parameter returnAs') 68 | oldList.update(newList) 69 | if 'range' in oldList: 70 | new_range='bytes 0-%s\/%s' % ( str(oldList['range']-1), str(oldList['range']) ) 71 | oldList.update({'range': new_range}) 72 | if returnAs == 'json': 73 | oldList=json.dumps(oldList) 74 | return oldList 75 | elif returnAs == 'b64': 76 | oldList=json.dumps(oldList) 77 | return base64.b64encode(oldList.encode('utf-8')) 78 | elif returnAs == 'default': 79 | return oldList -------------------------------------------------------------------------------- /PRANKBOTS/object.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from datetime import datetime 3 | import json, shutil, time, ntpath 4 | 5 | def loggedIn(func): 6 | def checkLogin(*args, **kwargs): 7 | if args[0].isLogin: 8 | return func(*args, **kwargs) 9 | else: 10 | args[0].callback.other('You must login to LINE') 11 | return checkLogin 12 | 13 | class LineObject(object): 14 | 15 | def __init__(self): 16 | if self.isLogin == True: 17 | self.log("[%s] : Login success" % self.profile.displayName) 18 | 19 | """Group""" 20 | 21 | @loggedIn 22 | def updateGroupPicture(self, groupId, path): 23 | files = {'file': open(path, 'rb')} 24 | data = {'params': self.genOBSParams({'oid': groupId,'type': 'image'})} 25 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/g/upload.nhn', data=data, files=files) 26 | if r.status_code != 201: 27 | raise Exception('Update group picture failure.') 28 | return True 29 | 30 | """Personalize""" 31 | 32 | @loggedIn 33 | def updateProfilePicture(self, path, type='p'): 34 | files = {'file': open(path, 'rb')} 35 | params = {'oid': self.profile.mid,'type': 'image'} 36 | if type == 'vp': 37 | params.update({'ver': '2.0', 'cat': 'vp.mp4'}) 38 | data = {'params': self.genOBSParams(params)} 39 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/p/upload.nhn', data=data, files=files) 40 | if r.status_code != 201: 41 | raise Exception('Update profile picture failure.') 42 | return True 43 | 44 | @loggedIn 45 | def updateProfileVideoPicture(self, path): 46 | try: 47 | from ffmpy import FFmpeg 48 | files = {'file': open(path, 'rb')} 49 | data = {'params': self.genOBSParams({'oid': self.profile.mid,'ver': '2.0','type': 'video','cat': 'vp.mp4'})} 50 | r_vp = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/vp/upload.nhn', data=data, files=files) 51 | if r_vp.status_code != 201: 52 | raise Exception('Update profile video picture failure.') 53 | path_p = self.genTempFile('path') 54 | ff = FFmpeg(inputs={'%s' % path: None}, outputs={'%s' % path_p: ['-ss', '00:00:2', '-vframes', '1']}) 55 | ff.run() 56 | self.updateProfilePicture(path_p, 'vp') 57 | except: 58 | raise Exception('You should install FFmpeg and ffmpy from pypi') 59 | 60 | # These function are still development. It doesn't works. 61 | # If you have a working code please pull it on linepy GitHub Repo 62 | @loggedIn 63 | def updateProfileCover(self, path): 64 | if len(self.server.channelHeaders) < 1: 65 | raise Exception('LineChannel instance is required for acquire this action.') 66 | else: 67 | home = self._channel.getProfileDetail(self.profile.mid) 68 | oldObjId, objId = home["result"]["objectId"], int(time.time()) 69 | file = open(path, 'rb').read() 70 | params = { 71 | 'userid': '%s' % self.profile.mid, 72 | 'oid': '%s' % str(objId), 73 | 'range': len(file), 74 | 'type': 'image' 75 | } 76 | hr = self.server.additionalHeaders(self.server.channelHeaders, { 77 | 'Content-Type': 'image/jpeg', 78 | 'Content-Length': str(len(file)), 79 | 'x-obs-params': self.genOBSParams(params,'b64') 80 | }) 81 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/myhome/c/upload.nhn', headers=hr, data=file) 82 | if r.status_code != 201: 83 | raise Exception('Update profile cover failure.') 84 | return True 85 | 86 | """Object""" 87 | 88 | @loggedIn 89 | def downloadObjectMsg(self, messageId, returnAs='path', saveAs=''): 90 | if saveAs == '': 91 | saveAs = self.genTempFile('path') 92 | if returnAs not in ['path','bool','bin']: 93 | raise Exception('Invalid returnAs value') 94 | params = {'oid': messageId} 95 | url = self.server.urlEncode(self.server.LINE_OBS_DOMAIN, '/talk/m/download.nhn', params) 96 | r = self.server.getContent(url) 97 | if r.status_code == 200: 98 | with open(saveAs, 'wb') as f: 99 | shutil.copyfileobj(r.raw, f) 100 | if returnAs == 'path': 101 | return saveAs 102 | elif returnAs == 'bool': 103 | return True 104 | elif returnAs == 'bin': 105 | return r.raw 106 | else: 107 | raise Exception('Download object failure.') 108 | 109 | @loggedIn 110 | def forwardObjectMsg(self, to, msgId, contentType='image'): 111 | if contentType not in ['image','video','audio']: 112 | raise Exception('Type not valid.') 113 | data = self.genOBSParams({'oid': 'reqseq','reqseq': self.revision,'type': contentType,'copyFrom': '/talk/m/%s' % msgId},'default') 114 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/m/copy.nhn', data=data) 115 | if r.status_code != 200: 116 | raise Exception('Forward object failure.') 117 | return True 118 | 119 | @loggedIn 120 | def sendImage(self, to, path): 121 | objectId = self.sendMessage(to=to, text=None, contentType = 1).id 122 | files = {'file': open(path, 'rb')} 123 | data = {'params': self.genOBSParams({'oid': objectId,'size': len(open(path, 'rb').read()),'type': 'image'})} 124 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/m/upload.nhn', data=data, files=files) 125 | if r.status_code != 201: 126 | raise Exception('Upload image failure.') 127 | return True 128 | 129 | @loggedIn 130 | def sendImageWithURL(self, to, url): 131 | path = self.downloadFileURL(url, 'path') 132 | return self.sendImage(to, path) 133 | 134 | @loggedIn 135 | def sendGIF(self, to, path): 136 | file = open(path, 'rb').read() 137 | params = { 138 | 'oid': 'reqseq', 139 | 'reqseq': '%s' % str(self.revision), 140 | 'tomid': '%s' % str(to), 141 | 'size': '%s' % str(len(file)), 142 | 'range': len(file), 143 | 'type': 'image' 144 | } 145 | hr = self.server.additionalHeaders(self.server.Headers, { 146 | 'Content-Type': 'image/gif', 147 | 'x-obs-params': self.genOBSParams(params,'b64') 148 | }) 149 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/r/talk/m/reqseq', data=file, headers=hr) 150 | if r.status_code != 201: 151 | raise Exception('Upload GIF failure.') 152 | return True 153 | 154 | @loggedIn 155 | def sendGIFWithURL(self, to, url): 156 | path = self.downloadFileURL(url, 'path') 157 | return self.sendGIF(to, path) 158 | 159 | @loggedIn 160 | def sendVideo(self, to, path): 161 | objectId = self.sendMessage(to=to, text=None, contentMetadata={'VIDLEN': '60000','DURATION': '60000'}, contentType = 2).id 162 | files = {'file': open(path, 'rb')} 163 | data = {'params': self.genOBSParams({'oid': objectId,'size': len(open(path, 'rb').read()),'type': 'video'})} 164 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/m/upload.nhn', data=data, files=files) 165 | if r.status_code != 201: 166 | raise Exception('Upload video failure.') 167 | return True 168 | 169 | @loggedIn 170 | def sendVideoWithURL(self, to, url): 171 | path = self.downloadFileURL(url, 'path') 172 | return self.sendVideo(to, path) 173 | 174 | @loggedIn 175 | def sendAudio(self, to, path): 176 | objectId = self.sendMessage(to=to, text=None, contentType = 3).id 177 | files = {'file': open(path, 'rb')} 178 | data = {'params': self.genOBSParams({'oid': objectId,'size': len(open(path, 'rb').read()),'type': 'audio'})} 179 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/m/upload.nhn', data=data, files=files) 180 | if r.status_code != 201: 181 | raise Exception('Upload audio failure.') 182 | return True 183 | 184 | @loggedIn 185 | def sendAudioWithURL(self, to, url): 186 | path = self.downloadFileURL(url, 'path') 187 | return self.sendAudio(to, path) 188 | 189 | @loggedIn 190 | def sendFile(self, to, path, file_name=''): 191 | if file_name == '': 192 | file_name = ntpath.basename(path) 193 | file_size = len(open(path, 'rb').read()) 194 | objectId = self.sendMessage(to=to, text=None, contentMetadata={'FILE_NAME': str(file_name),'FILE_SIZE': str(file_size)}, contentType = 14).id 195 | files = {'file': open(path, 'rb')} 196 | data = {'params': self.genOBSParams({'name': file_name,'oid': objectId,'size': file_size,'type': 'file'})} 197 | r = self.server.postContent(self.server.LINE_OBS_DOMAIN + '/talk/m/upload.nhn', data=data, files=files) 198 | if r.status_code != 201: 199 | raise Exception('Upload file failure.') 200 | return True 201 | 202 | @loggedIn 203 | def sendFileWithURL(self, to, url, fileName=''): 204 | path = self.downloadFileURL(url, 'path') 205 | return self.sendFile(to, path, fileName) -------------------------------------------------------------------------------- /PRANKBOTS/poll.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .client import LineClient 3 | from types import * 4 | 5 | import os, sys, threading 6 | 7 | class LinePoll(object): 8 | OpInterrupt = {} 9 | client = None 10 | 11 | def __init__(self, client): 12 | if type(client) is not LineClient: 13 | raise Exception("You need to set LineClient instance to initialize LinePoll") 14 | self.client = client 15 | 16 | def fetchOperation(self, revision, count=1): 17 | return self.client.poll.fetchOps(revision, count, 0, 0) 18 | # return self.client.poll.fetchOperations(revision, count) 19 | 20 | def addOpInterruptWithDict(self, OpInterruptDict): 21 | self.OpInterrupt.update(OpInterruptDict) 22 | 23 | def addOpInterrupt(self, OperationType, DisposeFunc): 24 | self.OpInterrupt[OperationType] = DisposeFunc 25 | 26 | def execute(self, op, thread): 27 | try: 28 | if thread == True: 29 | _td = threading.Thread(target=self.OpInterrupt[op.type], args=(op,)) 30 | _td.daemon = False 31 | _td.start() 32 | else: 33 | self.OpInterrupt[op.type](op) 34 | except Exception as e: 35 | self.client.log(e) 36 | 37 | def setRevision(self, revision): 38 | self.client.revision = max(revision, self.client.revision) 39 | 40 | def singleTrace(self, count=2): 41 | try: 42 | operations = self.fetchOperation(self.client.revision, count=count) 43 | except KeyboardInterrupt: 44 | exit() 45 | except: 46 | return 47 | 48 | if operations is None: 49 | self.client.log('No operation available now.') 50 | else: 51 | return operations 52 | 53 | def trace(self, thread=False): 54 | try: 55 | operations = self.fetchOperation(self.client.revision) 56 | except KeyboardInterrupt: 57 | exit() 58 | except: 59 | return 60 | 61 | for op in operations: 62 | if op.type in self.OpInterrupt.keys(): 63 | self.execute(op, thread) 64 | self.setRevision(op.revision) -------------------------------------------------------------------------------- /PRANKBOTS/server.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from PB.ttypes import ApplicationType 3 | import re, json, requests, urllib 4 | 5 | class LineServer(object): 6 | LINE_HOST_DOMAIN = 'https://gd2.line.naver.jp' 7 | LINE_OBS_DOMAIN = 'https://obs-sg.line-apps.com' 8 | LINE_TIMELINE_API = 'https://gd2.line.naver.jp/mh/api' 9 | LINE_TIMELINE_MH = 'https://gd2.line.naver.jp/mh' 10 | 11 | LINE_AUTH_QUERY_PATH = '/api/v4/TalkService.do' 12 | 13 | LINE_API_QUERY_PATH_FIR = '/S4' 14 | LINE_POLL_QUERY_PATH_FIR = '/P4' 15 | LINE_CALL_QUERY_PATH = '/V4' 16 | LINE_CERTIFICATE_PATH = '/Q' 17 | LINE_CHAN_QUERY_PATH = '/CH4' 18 | LINE_SQUARE_QUERY_PATH = '/SQS1' 19 | 20 | CHANNEL_ID = { 21 | 'LINE_TIMELINE': '1341209850', 22 | 'LINE_WEBTOON': '1401600689', 23 | 'LINE_TODAY': '1518712866', 24 | 'LINE_STORE': '1376922440', 25 | 'LINE_MUSIC': '1381425814' 26 | } 27 | 28 | USER_AGENT = 'Line/8.0.1' 29 | APP_TYPE = ApplicationType.DESKTOPWIN 30 | APP_NAME = "CHROMEOS\t8.1.1\tPrankBots11.2.5" 31 | PHONE_TYPE = ApplicationType.IOS 32 | PHONE_NAME = 'IOS\t7.14.0\tiPhone OS\t10.12.0' 33 | CARRIER = '51089, 1-0' 34 | SYSTEM_NAME = 'PrankBots' 35 | IP_ADDR = '8.8.8.8' 36 | EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+") 37 | 38 | _session = requests.session() 39 | channelHeaders = {} 40 | Headers = {} 41 | 42 | def __init__(self): 43 | self.Headers = {} 44 | self.channelHeaders = {} 45 | 46 | def parseUrl(self, path): 47 | return self.LINE_HOST_DOMAIN + path 48 | 49 | def urlEncode(self, url, path, params=[]): 50 | try: # Works with python 2.x 51 | return url + path + '?' + urllib.urlencode(params) 52 | except: # Works with python 3.x 53 | return url + path + '?' + urllib.parse.urlencode(params) 54 | 55 | def getJson(self, url, allowHeader=False): 56 | if allowHeader is False: 57 | return json.loads(self._session.get(url).text) 58 | else: 59 | return json.loads(self._session.get(url, headers=self.Headers).text) 60 | 61 | def setHeadersWithDict(self, headersDict): 62 | self.Headers.update(headersDict) 63 | 64 | def setHeaders(self, argument, value): 65 | self.Headers[argument] = value 66 | 67 | def setChannelHeadersWithDict(self, headersDict): 68 | self.channelHeaders.update(headersDict) 69 | 70 | def setChannelHeaders(self, argument, value): 71 | self.channelHeaders[argument] = value 72 | 73 | def additionalHeaders(self, source, newSource): 74 | headerList={} 75 | headerList.update(source) 76 | headerList.update(newSource) 77 | return headerList 78 | 79 | def optionsContent(self, url, data=None, headers=None): 80 | if headers is None: 81 | headers=self.Headers 82 | return self._session.options(url, headers=headers, data=data) 83 | 84 | def postContent(self, url, data=None, files=None, headers=None): 85 | if headers is None: 86 | headers=self.Headers 87 | return self._session.post(url, headers=headers, data=data, files=files) 88 | 89 | def getContent(self, url, headers=None): 90 | if headers is None: 91 | headers=self.Headers 92 | return self._session.get(url, headers=headers, stream=True) 93 | 94 | def deleteContent(self, url, data=None, headers=None): 95 | if headers is None: 96 | headers=self.Headers 97 | return self._session.post(url, headers=headers, data=data) 98 | 99 | def putContent(self, url, data=None, headers=None): 100 | if headers is None: 101 | headers=self.Headers 102 | return self._session.put(url, headers=headers, data=data) 103 | -------------------------------------------------------------------------------- /PRANKBOTS/session.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from thrift.transport import THttpClient 3 | from thrift.protocol import TCompactProtocol 4 | from PB import TalkService, ChannelService, CallService#, SquareService 5 | 6 | class LineSession: 7 | 8 | def __init__(self, url, headers, path=''): 9 | self.host = url + path 10 | self.headers = headers 11 | 12 | def Talk(self, isopen=True): 13 | self.transport = THttpClient.THttpClient(self.host) 14 | self.transport.setCustomHeaders(self.headers) 15 | 16 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 17 | self._talk = TalkService.Client(self.protocol) 18 | 19 | # if isopen: 20 | # self.transport.open() 21 | 22 | return self._talk 23 | 24 | def Channel(self, isopen=True): 25 | self.transport = THttpClient.THttpClient(self.host) 26 | self.transport.setCustomHeaders(self.headers) 27 | 28 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 29 | self._channel = ChannelService.Client(self.protocol) 30 | 31 | # if isopen: 32 | # self.transport.open() 33 | 34 | return self._channel 35 | 36 | def Call(self, isopen=True): 37 | self.transport = THttpClient.THttpClient(self.host) 38 | self.transport.setCustomHeaders(self.headers) 39 | 40 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 41 | self._call = CallService.Client(self.protocol) 42 | 43 | # if isopen: 44 | # self.transport.open() 45 | 46 | return self._call 47 | 48 | def Square(self, isopen=True): 49 | self.transport = THttpClient.THttpClient(self.host) 50 | self.transport.setCustomHeaders(self.headers) 51 | 52 | self.protocol = TCompactProtocol.TCompactProtocol(self.transport) 53 | #self._square = SquareService.Client(self.protocol) 54 | 55 | # if isopen: 56 | # self.transport.open() 57 | 58 | #return self._square 59 | -------------------------------------------------------------------------------- /PRANKBOTS/timeline.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from datetime import datetime 3 | import json, time, base64 4 | 5 | def loggedIn(func): 6 | def checkLogin(*args, **kwargs): 7 | if args[0].isLogin: 8 | return func(*args, **kwargs) 9 | else: 10 | args[0].callback.other('You must login to LINE') 11 | return checkLogin 12 | 13 | class LineTimeline(object): 14 | 15 | def __init__(self): 16 | if self.isLogin == True and self.channelId == self.server.CHANNEL_ID['LINE_TIMELINE']: 17 | self.client.log('[%s] : LineTimeline tercantumkan' % self.client.profile.displayName) 18 | 19 | """Timeline""" 20 | 21 | @loggedIn 22 | def getFeed(self, postLimit=10, commentLimit=1, likeLimit=1, order='TIME'): 23 | params = {'postLimit': postLimit, 'commentLimit': commentLimit, 'likeLimit': likeLimit, 'order': order} 24 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v27/feed/list', params) 25 | r = self.server.getContent(url, headers=self.server.channelHeaders) 26 | return r.json() 27 | 28 | @loggedIn 29 | def getHomeProfile(self, mid=None, postLimit=10, commentLimit=1, likeLimit=1): 30 | if mid is None: 31 | mid = self.client.profile.mid 32 | params = {'homeId': mid, 'postLimit': postLimit, 'commentLimit': commentLimit, 'likeLimit': likeLimit, 'sourceType': 'LINE_PROFILE_COVER'} 33 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v27/post/list', params) 34 | r = self.server.getContent(url, headers=self.server.channelHeaders) 35 | return r.json() 36 | 37 | @loggedIn 38 | def getProfileDetail(self, mid=None): 39 | if mid is None: 40 | mid = self.client.profile.mid 41 | params = {'userMid': mid} 42 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v1/userpopup/getDetail', params) 43 | r = self.server.getContent(url, headers=self.server.channelHeaders) 44 | return r.json() 45 | 46 | """Post""" 47 | 48 | @loggedIn 49 | def createPost(self, text): 50 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 51 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v23/post/create', params) 52 | payload = {'postInfo': {'readPermission': {'type': 'ALL'}}, 'sourceType': 'TIMELINE', 'contents': {'text': text}} 53 | data = json.dumps(payload) 54 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 55 | return r.json() 56 | 57 | @loggedIn 58 | def createComment(self, mid, postId, text): 59 | if mid is None: 60 | mid = self.client.profile.mid 61 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 62 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v23/comment/create', params) 63 | data = {'commentText': text, 'postId': postId, 'actorId': mid} 64 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 65 | return r.json() 66 | 67 | @loggedIn 68 | def deleteComment(self, mid, postId, commentId): 69 | if mid is None: 70 | mid = self.client.profile.mid 71 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 72 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v23/comment/delete', params) 73 | data = {'commentId': commentId, 'postId': postId, 'actorId': mid} 74 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 75 | return r.json() 76 | 77 | @loggedIn 78 | def likePost(self, mid, postId, likeType=1001): 79 | if mid is None: 80 | mid = self.client.profile.mid 81 | if likeType not in [1001,1002,1003,1004,1005,1006]: 82 | raise Exception('Invalid parameter likeType') 83 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 84 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v23/like/create', params) 85 | data = {'likeType': likeType, 'postId': postId, 'actorId': mid} 86 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 87 | return r.json() 88 | 89 | @loggedIn 90 | def unlikePost(self, mid, postId): 91 | if mid is None: 92 | mid = self.client.profile.mid 93 | params = {'homeId': mid, 'sourceType': 'TIMELINE'} 94 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v23/like/cancel', params) 95 | data = {'postId': postId, 'actorId': mid} 96 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 97 | return r.json() 98 | 99 | """Group Post""" 100 | 101 | @loggedIn 102 | def createGroupPost(self, mid, text): 103 | payload = {'postInfo': {'readPermission': {'homeId': mid}}, 'sourceType': 'TIMELINE', 'contents': {'text': text}} 104 | data = json.dumps(payload) 105 | r = self.server.postContent(self.server.LINE_TIMELINE_API + '/v27/post/create', data=data, headers=self.server.channelHeaders) 106 | return r.json() 107 | 108 | @loggedIn 109 | def createGroupAlbum(self, mid, name): 110 | data = json.dumps({'title': name, 'type': 'image'}) 111 | params = {'homeId': mid,'count': '1','auto': '0'} 112 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/album', params) 113 | r = self.server.postContent(url, data=data, headers=self.server.channelHeaders) 114 | if r.status_code != 201: 115 | raise Exception('Create a new album failure.') 116 | return True 117 | 118 | @loggedIn 119 | def deleteGroupAlbum(self, mid, albumId): 120 | params = {'homeId': mid} 121 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/album/%s' % albumId, params) 122 | r = self.server.deleteContent(url, headers=self.server.channelHeaders) 123 | if r.status_code != 201: 124 | raise Exception('Delete album failure.') 125 | return True 126 | 127 | @loggedIn 128 | def getGroupPost(self, mid, postLimit=10, commentLimit=1, likeLimit=1): 129 | params = {'homeId': mid, 'commentLimit': commentLimit, 'likeLimit': likeLimit, 'sourceType': 'TALKROOM'} 130 | url = self.server.urlEncode(self.server.LINE_TIMELINE_API, '/v27/post/list', params) 131 | r = self.server.getContent(url, headers=self.server.channelHeaders) 132 | return r.json() 133 | 134 | """Group Album""" 135 | 136 | @loggedIn 137 | def getGroupAlbum(self, mid): 138 | params = {'homeId': mid, 'type': 'g', 'sourceType': 'TALKROOM'} 139 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/albums', params) 140 | r = self.server.getContent(url, headers=self.server.channelHeaders) 141 | return r.json() 142 | 143 | @loggedIn 144 | def changeGroupAlbumName(self, mid, albumId, name): 145 | data = json.dumps({'title': name}) 146 | params = {'homeId': mid} 147 | url = self.server.urlEncode(self.server.LINE_TIMELINE_MH, '/album/v3/album/%s' % albumId, params) 148 | r = self.server.putContent(url, data=data, headers=self.server.channelHeaders) 149 | if r.status_code != 201: 150 | raise Exception('Change album name failure.') 151 | return True 152 | 153 | @loggedIn 154 | def addImageToAlbum(self, mid, albumId, path): 155 | file = open(path, 'rb').read() 156 | params = { 157 | 'oid': int(time.time()), 158 | 'quality': '90', 159 | 'range': len(file), 160 | 'type': 'image' 161 | } 162 | hr = self.server.additionalHeaders(self.server.channelHeaders, { 163 | 'Content-Type': 'image/jpeg', 164 | 'X-Line-Mid': mid, 165 | 'X-Line-Album': albumId, 166 | 'x-obs-params': self.genOBSParams(params,'b64') 167 | }) 168 | r = self.server.getContent(self.server.LINE_OBS_DOMAIN + '/album/a/upload.nhn', data=file, headers=hr) 169 | if r.status_code != 201: 170 | raise Exception('Add image to album failure.') 171 | return r.json() 172 | 173 | @loggedIn 174 | def getImageGroupAlbum(self, mid, albumId, objId, returnAs='path', saveAs=''): 175 | if saveAs == '': 176 | saveAs = self.genTempFile('path') 177 | if returnAs not in ['path','bool','bin']: 178 | raise Exception('Invalid returnAs value') 179 | hr = self.server.additionalHeaders(self.server.channelHeaders, { 180 | 'Content-Type': 'image/jpeg', 181 | 'X-Line-Mid': mid, 182 | 'X-Line-Album': albumId 183 | }) 184 | params = {'ver': '1.0', 'oid': objId} 185 | url = self.server.urlEncode(self.server.LINE_OBS_DOMAIN, '/album/a/download.nhn', params) 186 | r = self.server.getContent(url, headers=hr) 187 | if r.status_code == 200: 188 | with open(saveAs, 'wb') as f: 189 | shutil.copyfileobj(r.raw, f) 190 | if returnAs == 'path': 191 | return saveAs 192 | elif returnAs == 'bool': 193 | return True 194 | elif returnAs == 'bin': 195 | return r.raw 196 | else: 197 | raise Exception('Download image album failure.') 198 | 199 | """Contact""" 200 | 201 | @loggedIn 202 | def getProfileCoverURL(self, mid=None): 203 | if mid is None: 204 | mid = self.client.profile.mid 205 | home = self.getProfileDetail(mid) 206 | params = {'userid': mid, 'oid': home['result']['objectId']} 207 | return self.server.urlEncode(self.server.LINE_OBS_DOMAIN, '/myhome/c/download.nhn', params) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DONE UPDATE PYTHON3 2 | ### THRIFT 0.10.0 3 | # 1 selfbot 3 pro 4 | V2.1 editor_:: 5 | Prankbots 6 | ## WORKING ON SERVER VPS 7 | ``` 8 | apt-get install python3-pip 9 | apt-get install python3-tz 10 | pip install requests rsa bs4 gtts gooslate googletrans pafy youtube_dl humanfriendly thrift==0.10.0 11 | ``` 12 | # CONTACT OFFICIAL 13 | 14 | Add Friend 15 | 16 | # LINE ME 17 | 18 | [ADD_LINE](http://line.me/ti/p/~adiputra.95) 19 | 20 | # TUTORIAL YOUTUBE 21 | [LIHAT_DISINI](https://youtu.be/j9VqQBZCcec) 22 | 23 | [@SUBCRABE](https://www.youtube.com/channel/UCycBrqSWEHdk-slnhUmGWiQ) 24 | 25 | [BUAT AMBIL TOKKEN](http://101.255.95.249:6969) 26 | 27 | ## THANKS TO. 28 | ``` 29 | ========= 30 | Allah swt 31 | Prankbots 32 | Black of gamer 33 | Dan kawan-Kawan 34 | ``` 35 | ![Prankbots](prankbots.png) 36 | V2.1 last update:: 37 | 24/05/2018 38 | -------------------------------------------------------------------------------- /prankbots.json: -------------------------------------------------------------------------------- 1 | { 2 | "PROTECT": {}, 3 | "blacklist": {}, 4 | "cancelprotect": {}, 5 | "changeGroupPicture": [], 6 | "changePicture": false, 7 | "inviteprotect": {}, 8 | "linkprotect": {}, 9 | "pname": {}, 10 | "pnharfbot": {}, 11 | "pro_name": {}, 12 | "restartPoint": null, 13 | "server": "VPS", 14 | "target": {}, 15 | "timeRestart": "18000", 16 | "userAgent": [ 17 | "Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0", 18 | "Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)", 19 | "Mozilla/5.0 (X11; U; Linux amd64; en-US; rv:5.0) Gecko/20110619 Firefox/5.0", 20 | "Mozilla/5.0 (X11; Linux) Gecko Firefox/5.0", 21 | "Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 FirePHP/0.5", 22 | "Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 Firefox/5.0", 23 | "Mozilla/5.0 (X11; Linux x86_64) Gecko Firefox/5.0", 24 | "Mozilla/5.0 (X11; Linux ppc; rv:5.0) Gecko/20100101 Firefox/5.0", 25 | "Mozilla/5.0 (X11; Linux AMD64) Gecko Firefox/5.0", 26 | "Mozilla/5.0 (X11; FreeBSD amd64; rv:5.0) Gecko/20100101 Firefox/5.0", 27 | "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 28 | "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20110619 Firefox/5.0", 29 | "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:5.0) Gecko/20100101 Firefox/5.0", 30 | "Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/5.0", 31 | "Mozilla/5.0 (Windows NT 6.1.1; rv:5.0) Gecko/20100101 Firefox/5.0", 32 | "Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 33 | "Mozilla/5.0 (Windows NT 5.1; U; rv:5.0) Gecko/20100101 Firefox/5.0", 34 | "Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/5.0", 35 | "Mozilla/5.0 (Windows NT 5.0; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0", 36 | "Mozilla/5.0 (Windows NT 5.0; rv:5.0) Gecko/20100101 Firefox/5.0" 37 | ] 38 | } -------------------------------------------------------------------------------- /prankbots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prankbots/prankpy3/7648972cb2c44e8779a1577f14968bf7e6a4b97b/prankbots.png --------------------------------------------------------------------------------