├── LICENSE ├── MOStodon.py ├── README.md ├── funct.py ├── requirements.txt └── seq └── MOStodon.seq /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 | -------------------------------------------------------------------------------- /MOStodon.py: -------------------------------------------------------------------------------- 1 | from mastodon import Mastodon 2 | import re 3 | from html.parser import HTMLParser 4 | from io import StringIO 5 | import textwrap 6 | from datetime import datetime, timezone, timedelta 7 | import socket 8 | import os 9 | from _thread import * 10 | from funct import * 11 | from anyascii import anyascii 12 | 13 | 14 | #Add MOStodon app access token and Mastodon instance between Quotes !!!!!!!!!!!!!!!!!!!!! 15 | ######################################################################## 16 | 17 | mastodon = Mastodon(access_token = "", 18 | api_base_url = "") 19 | 20 | ######################################################################## 21 | 22 | #DEFINE LISTENING HOST AND PORT 23 | MOStodon = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 24 | MOStodon.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 25 | host = '' # leave empty for Server IP. Does not need to be set. 26 | port = 6502 # you can change the incoming port to any desired 27 | 28 | 29 | # Customize the Client # 30 | 31 | displayname_color = "pink" 32 | time_color = "purple" 33 | text_color = "lightblue" 34 | alt_text_color = "cyan" 35 | main_menu_color = "purple" 36 | secondary_menu_color = "blue" 37 | notification_color = "red" 38 | boosted_displayname_color = "orange" 39 | interaction_color = "red" # Favourites Boosts Replies 40 | 41 | ''' 42 | Colors to choose from. 43 | 44 | white 45 | red 46 | green 47 | blue 48 | orange 49 | black 50 | brown 51 | pink 52 | dark gray 53 | gray 54 | lightgreen 55 | lightblue 56 | lightgrey 57 | purple 58 | yellow 59 | cyan 60 | 61 | ''' 62 | 63 | 64 | 65 | 66 | ######################################################################## 67 | UsersCount = 0 68 | user_id = mastodon.account_verify_credentials() 69 | yourname = "@" + user_id["acct"] 70 | user_id = user_id["id"] 71 | notify_id = datetime.now(timezone.utc) 72 | 73 | tl = "h" 74 | home_tl = "" 75 | local_tl = "" 76 | federated_tl = "" 77 | user_tl = "" 78 | other_tl = "" 79 | account_id="" 80 | return_page_tl="h" 81 | home_x = 0 82 | local_x = 0 83 | federated_x = 0 84 | user_x = 0 85 | other_x = 0 86 | pinned = False 87 | other_page = False 88 | notification_loop = 0 89 | previous_home_tl_old="" 90 | previous_home_tl_temp="" 91 | previous_home_x=0 92 | 93 | previous_local_tl_old="" 94 | previous_local_tl_temp="" 95 | previous_local_x=0 96 | 97 | previous_federated_tl_old="" 98 | previous_federated_tl_temp="" 99 | previous_federated_x=0 100 | 101 | previous_user_tl_old="" 102 | previous_user_tl_temp="" 103 | previous_user_x=0 104 | 105 | previous_other_tl_old="" 106 | previous_other_tl_temp="" 107 | previous_other_x=0 108 | 109 | timeline_h = "" 110 | timeline_l = "" 111 | timeline_f = "" 112 | timeline_y = "" 113 | 114 | class MLStripper(HTMLParser): 115 | def __init__(self): 116 | super().__init__() 117 | self.reset() 118 | self.strict = False 119 | self.convert_charrefs= True 120 | self.text = StringIO() 121 | def handle_data(self, d): 122 | self.text.write(d) 123 | def get_data(self): 124 | return self.text.getvalue() 125 | 126 | def strip_tags(connection, html): 127 | s = MLStripper() 128 | s.feed(html) 129 | return s.get_data() 130 | 131 | def deEmojify(connection, text): 132 | regrex_pattern = re.compile("[" 133 | u"\U0001F600-\U0001F64F" # emoticons 134 | u"\U0001F300-\U0001F5FF" # symbols & pictographs 135 | u"\U0001F680-\U0001F6FF" # transport & map symbols 136 | u"\U0001F1E0-\U0001F1FF" # flags (iOS) 137 | u"\U00002702-\U000027B0" 138 | u"\U000024C2-\U0001F251" 139 | u"\U0001f926-\U0001f937" 140 | u'\U00010000-\U0010ffff' 141 | u"\u200d" 142 | u"\u2640-\u2642" 143 | u"\u2600-\u2B55" 144 | u"\u23cf" 145 | u"\u23e9" 146 | u"\u231a" 147 | u"\u3030" 148 | u"\ufe0f" 149 | "]+", flags=re.UNICODE) 150 | return regrex_pattern.sub(r'\b',text) 151 | 152 | def toot(connection): 153 | global secondary_menu_color 154 | global text_color 155 | global notification_color 156 | global user_id 157 | choice_exit = False 158 | connection.send(b'\x13') #clear 159 | connection.send(b'\x93') #home 160 | send_cr(connection, secondary_menu_color) 161 | send_ln(connection, "Press (") 162 | connection.send(b'\x05') #white 163 | send_ln(connection, "t") 164 | send_cr(connection, secondary_menu_color) 165 | send_ln(connection, ") for a normal Toot.\n\n") 166 | send_ln(connection, "Press (") 167 | connection.send(b'\x05') #white 168 | send_ln(connection, "p") 169 | send_cr(connection, secondary_menu_color) 170 | send_ln(connection, ") for a private direct message.\nIf you already know their\n") 171 | connection.send(b'\x05') #white 172 | send_ln(connection, "@username") 173 | send_cr(connection, "pink") 174 | send_ln(connection, "@server.com\n\n") 175 | send_cr(connection, secondary_menu_color) 176 | send_ln(connection, "Press (") 177 | connection.send(b'\x05') #white 178 | send_ln(connection, "1") 179 | send_cr(connection, secondary_menu_color) 180 | send_ln(connection, ") to search people you follow.\nThen send a Direct Message.\n\n") 181 | send_ln(connection, "Press (") 182 | connection.send(b'\x05') #white 183 | send_ln(connection, "2") 184 | send_cr(connection, secondary_menu_color) 185 | send_ln(connection, ") to search people who follow \nyou. Then send a Direct Message.\n\n") 186 | send_ln(connection, "Press (") 187 | connection.send(b'\x05') #white 188 | send_ln(connection, "x") 189 | send_cr(connection, secondary_menu_color) 190 | send_ln(connection, ") to exit.\n\n") 191 | send_cr(connection, "black") 192 | choice = get_char(connection) 193 | 194 | if choice == "t": 195 | connection.send(b'\x13') #clear 196 | connection.send(b'\x93') #home 197 | send_cr(connection, secondary_menu_color) 198 | send_ln(connection,"Don't forget to add any usernames.\n") 199 | send_ln(connection,"e.g. @somebody@instance.com\n") 200 | send_ln(connection,"You should only need @somebody if they\n") 201 | send_ln(connection,"are on the same instance as you.\n\n") 202 | send_cr(connection, notification_color) 203 | send_ln(connection,"Enter Toot..\n\n") 204 | send_cr(connection, text_color) 205 | toot = input_line(connection) 206 | try: #in case message was left blank.. 207 | mastodon.status_post(toot) 208 | except: 209 | return 210 | 211 | 212 | if choice == "p": 213 | connection.send(b'\x13') #clear 214 | connection.send(b'\x93') #home 215 | send_cr(connection, secondary_menu_color) 216 | send_ln(connection, "Add the full username of the person\n") 217 | send_ln(connection, "you are messaging.\n\n") 218 | send_ln(connection, "e.g. @somebody@instance.com \n") 219 | send_ln(connection, "You should only need @somebody if they\n") 220 | send_ln(connection, "are on the same instance as you.\n\n") 221 | send_cr(connection, notification_color) 222 | send_ln(connection,"Enter Direct Message..\n\n") 223 | send_cr(connection, text_color) 224 | toot = input_line(connection) 225 | try: 226 | mastodon.status_post(toot,visibility="direct") 227 | except: 228 | return 229 | 230 | 231 | if choice == "1": #following 232 | choice_exit = False 233 | connection.send(b'\x13') #clear 234 | connection.send(b'\x93') #home 235 | send_cr(connection, "white") 236 | send_ln(connection, "Remember the Followers Number!\n") 237 | following = mastodon.account_following(user_id,limit=80) #Loads up to 80. Most instances default to 80 per api page. 238 | x=0 239 | y=0 240 | for follow in following: 241 | print(str(x+1) + " " + following[x]["display_name"]) 242 | connection.send(b'\x05') #white 243 | send_ln(connection, str(x+1) + " ") 244 | displayname= following[x]["display_name"] 245 | displayname = re.sub(r':.*:','',displayname) 246 | displayname = deEmojify(connection ,displayname) 247 | displayname = anyascii(str(displayname)) 248 | if len(displayname) == 1 or len(displayname) == 0 : 249 | displayname = following[x]["username"] 250 | username = "@" + following[x]["acct"] 251 | send_cr(connection, "pink") 252 | send_ln(connection, displayname + " ") 253 | send_cr(connection, text_color) 254 | send_ln(connection, username + "\n") 255 | if y==12: 256 | send_cr(connection, text_color) 257 | send_ln(connection, "\nPress ") 258 | connection.send(b'\x05') #white 259 | send_ln(connection, "Space ") 260 | send_cr(connection, text_color) 261 | send_ln(connection, "for next..\n(") 262 | connection.send(b'\x05') #white 263 | send_ln(connection, "e") 264 | send_cr(connection, text_color) 265 | send_ln(connection, ") to Enter choice. (") 266 | connection.send(b'\x05') #white 267 | send_ln(connection, "x") 268 | send_cr(connection, text_color) 269 | send_ln(connection, ") to Return.\n") 270 | send_cr(connection, "black") 271 | choice = get_char(connection) 272 | if choice == "x": 273 | return 274 | if choice == "e": 275 | choice_exit = True 276 | break 277 | connection.send(b'\x13') #clear 278 | connection.send(b'\x93') #home 279 | y=0 280 | x+=1 281 | else: 282 | x+=1 283 | y+=1 284 | #end of first page.. 285 | if choice_exit == True: 286 | pass 287 | elif choice_exit == False: 288 | send_cr(connection, text_color) 289 | send_ln(connection, "\nPress ") 290 | connection.send(b'\x05') #white 291 | send_ln(connection, "Space ") 292 | send_cr(connection, text_color) 293 | send_ln(connection, "for next..\n(") 294 | connection.send(b'\x05') #white 295 | send_ln(connection, "e") 296 | send_cr(connection, text_color) 297 | send_ln(connection, ") to Enter choice. (") 298 | connection.send(b'\x05') #white 299 | send_ln(connection, "x") 300 | send_cr(connection, text_color) 301 | send_ln(connection, ") to Return.\n") 302 | send_cr(connection, "black") 303 | choice = get_char(connection) 304 | if choice == "x": 305 | return 306 | if choice == "e": 307 | choice_exit = True 308 | if choice_exit == True: 309 | 310 | connection.send(b'\x13') #clear 311 | connection.send(b'\x93') #home 312 | connection.send(b'\x05') #white 313 | send_ln(connection, "Enter User's Number.\n\n") 314 | try: #prevents crash if invalid nubmer was entered. 315 | choice = int(input_line(connection))-1 316 | follower_username = following[choice]["acct"] 317 | follower_username = "@"+ follower_username 318 | send_cr(connection, secondary_menu_color) 319 | send_ln(connection, "Enter Direct Message.\nUsername automatically added.\n\n") 320 | send_cr(connection, text_color) 321 | message = input_line(connection) 322 | message = follower_username + " " + message 323 | mastodon.status_post(message,visibility="direct") 324 | return 325 | except: 326 | connection.send(b'\x13') #clear 327 | connection.send(b'\x93') #home 328 | connection.send(b'\x05') #white 329 | send_ln(connection, "Error.\nPress any key to Return.") 330 | get_char(connection) 331 | return 332 | 333 | #next page. If more than 80 it will load and continue to load the next pages. 334 | while True: 335 | connection.send(b'\x13') #clear 336 | connection.send(b'\x93') #home 337 | print("Next Page") 338 | if choice_exit == True: 339 | break 340 | try: 341 | x=0 342 | y=0 343 | following = mastodon.fetch_next(following) 344 | for follow in following: 345 | print(str(x+1) + " " + following[x]["display_name"]) 346 | connection.send(b'\x05') #white 347 | send_ln(connection, str(x+1) + " ") 348 | displayname= following[x]["display_name"] 349 | displayname = re.sub(r':.*:','',displayname) 350 | displayname = deEmojify(connection ,displayname) 351 | displayname = anyascii(str(displayname)) 352 | if len(displayname) == 1 or len(displayname) == 0 : 353 | displayname = following[x]["username"] 354 | username = "@" + following[x]["acct"] 355 | send_cr(connection, "pink") 356 | send_ln(connection, displayname + " ") 357 | send_cr(connection, text_color) 358 | send_ln(connection, username + "\n") 359 | 360 | if y==10: 361 | send_cr(connection, text_color) 362 | send_ln(connection, "\nPress ") 363 | connection.send(b'\x05') #white 364 | send_ln(connection, "Space ") 365 | send_cr(connection, text_color) 366 | send_ln(connection, "for next..\n(") 367 | connection.send(b'\x05') #white 368 | send_ln(connection, "e") 369 | send_cr(connection, text_color) 370 | send_ln(connection, ") to Enter choice. (") 371 | connection.send(b'\x05') #white 372 | send_ln(connection, "x") 373 | send_cr(connection, text_color) 374 | send_ln(connection, ") to Return.\n") 375 | send_cr(connection, "black") 376 | choice = get_char(connection) 377 | if choice == "x": 378 | return 379 | if choice == "e": 380 | choice_exit = True 381 | break 382 | connection.send(b'\x13') #clear 383 | connection.send(b'\x93') #home 384 | y=0 385 | x+=1 386 | else: 387 | x+=1 388 | y+=1 389 | 390 | if choice_exit == True: 391 | pass 392 | elif choice_exit == False: 393 | send_cr(connection, text_color) 394 | send_ln(connection, "\nPress ") 395 | connection.send(b'\x05') #white 396 | send_ln(connection, "Space ") 397 | send_cr(connection, text_color) 398 | send_ln(connection, "for next..\n(") 399 | connection.send(b'\x05') #white 400 | send_ln(connection, "e") 401 | send_cr(connection, text_color) 402 | send_ln(connection, ") to Enter choice. (") 403 | connection.send(b'\x05') #white 404 | send_ln(connection, "x") 405 | send_cr(connection, text_color) 406 | send_ln(connection, ") to Return.\n") 407 | send_cr(connection, "black") 408 | choice = get_char(connection) 409 | if choice == "x": 410 | return 411 | if choice == "e": 412 | choice_exit = True 413 | 414 | if choice_exit == True: 415 | 416 | connection.send(b'\x13') #clear 417 | connection.send(b'\x93') #home 418 | connection.send(b'\x05') #white 419 | send_ln(connection, "Enter User's Number.\n\n") 420 | try: 421 | choice = int(input_line(connection))-1 422 | follower_username = following[choice]["acct"] 423 | follower_username = "@"+ follower_username 424 | send_cr(connection, secondary_menu_color) 425 | send_ln(connection, "Enter Direct Message.\nUsername automatically added.\n\n") 426 | send_cr(connection, text_color) 427 | message = input_line(connection) 428 | message = follower_username + " " + message 429 | mastodon.status_post(message,visibility="direct") 430 | return 431 | except: 432 | connection.send(b'\x13') #clear 433 | connection.send(b'\x93') #home 434 | connection.send(b'\x05') #white 435 | send_ln(connection, "Error.\nPress any key to Return.") 436 | get_char(connection) 437 | return 438 | 439 | except: 440 | return 441 | 442 | connection.send(b'\x13') #clear 443 | connection.send(b'\x93') #home 444 | connection.send(b'\x05') #white 445 | send_ln(connection, "End of list.\nPress any key to Return.") 446 | get_char(connection) 447 | return 448 | 449 | 450 | 451 | if choice == "2": #following 452 | choice_exit = False 453 | connection.send(b'\x13') #clear 454 | connection.send(b'\x93') #home 455 | send_cr(connection, "white") 456 | send_ln(connection, "Remember the Followers Number!\n") 457 | followers = mastodon.account_followers(user_id,limit=80) 458 | x=0 459 | y=0 460 | for follow in followers: 461 | print(str(x+1) + " " + followers[x]["display_name"]) 462 | connection.send(b'\x05') #white 463 | send_ln(connection, str(x+1) + " ") 464 | displayname= followers[x]["display_name"] 465 | displayname = re.sub(r':.*:','',displayname) 466 | displayname = deEmojify(connection ,displayname) 467 | displayname = anyascii(str(displayname)) 468 | if len(displayname) == 1 or len(displayname) == 0 : 469 | displayname = followers[x]["username"] 470 | username = "@" + followers[x]["acct"] 471 | send_cr(connection, "pink") 472 | send_ln(connection, displayname + " ") 473 | send_cr(connection, text_color) 474 | send_ln(connection, username + "\n") 475 | if y==12: 476 | send_cr(connection, text_color) 477 | send_ln(connection, "\nPress ") 478 | connection.send(b'\x05') #white 479 | send_ln(connection, "Space ") 480 | send_cr(connection, text_color) 481 | send_ln(connection, "for next..\n(") 482 | connection.send(b'\x05') #white 483 | send_ln(connection, "e") 484 | send_cr(connection, text_color) 485 | send_ln(connection, ") to Enter choice. (") 486 | connection.send(b'\x05') #white 487 | send_ln(connection, "x") 488 | send_cr(connection, text_color) 489 | send_ln(connection, ") to Return.\n") 490 | send_cr(connection, "black") 491 | choice = get_char(connection) 492 | if choice == "x": 493 | return 494 | if choice == "e": 495 | choice_exit = True 496 | break 497 | connection.send(b'\x13') #clear 498 | connection.send(b'\x93') #home 499 | y=0 500 | x+=1 501 | else: 502 | x+=1 503 | y+=1 504 | #end of first page.. 505 | if choice_exit == True: 506 | pass 507 | 508 | elif choice_exit == False: 509 | send_cr(connection, text_color) 510 | send_ln(connection, "\nPress ") 511 | connection.send(b'\x05') #white 512 | send_ln(connection, "Space ") 513 | send_cr(connection, text_color) 514 | send_ln(connection, "for next..\n(") 515 | connection.send(b'\x05') #white 516 | send_ln(connection, "e") 517 | send_cr(connection, text_color) 518 | send_ln(connection, ") to Enter choice. (") 519 | connection.send(b'\x05') #white 520 | send_ln(connection, "x") 521 | send_cr(connection, text_color) 522 | send_ln(connection, ") to Return.\n") 523 | send_cr(connection, "black") 524 | choice = get_char(connection) 525 | 526 | if choice == "x": 527 | return 528 | if choice == "e": 529 | choice_exit = True 530 | 531 | if choice_exit == True: 532 | 533 | connection.send(b'\x13') #clear 534 | connection.send(b'\x93') #home 535 | connection.send(b'\x05') #white 536 | send_ln(connection, "Enter User's Number.\n\n") 537 | try: #prevents crash if invalid nubmer was entered. 538 | choice = int(input_line(connection))-1 539 | follower_username = followers[choice]["acct"] 540 | follower_username = "@"+ follower_username 541 | send_cr(connection, secondary_menu_color) 542 | send_ln(connection, "Enter Direct Message.\nUsername automatically added.\n\n") 543 | send_cr(connection, text_color) 544 | message = input_line(connection) 545 | message = follower_username + " " + message 546 | mastodon.status_post(message,visibility="direct") 547 | return 548 | except: 549 | connection.send(b'\x13') #clear 550 | connection.send(b'\x93') #home 551 | connection.send(b'\x05') #white 552 | send_ln(connection, "Error.\nPress any key to Return.") 553 | get_char(connection) 554 | return 555 | 556 | #next page 557 | while True: 558 | connection.send(b'\x13') #clear 559 | connection.send(b'\x93') #home 560 | print("Next Page") 561 | if choice_exit == True: 562 | break 563 | try: 564 | x=0 565 | y=0 566 | followers = mastodon.fetch_next(followers) 567 | for follow in followers: 568 | print(str(x+1) + " " + followers[x]["display_name"]) 569 | connection.send(b'\x05') #white 570 | send_ln(connection, str(x+1) + " ") 571 | displayname= followers[x]["display_name"] 572 | displayname = re.sub(r':.*:','',displayname) 573 | displayname = deEmojify(connection ,displayname) 574 | displayname = anyascii(str(displayname)) 575 | if len(displayname) == 1 or len(displayname) == 0 : 576 | displayname = followers[x]["username"] 577 | username = "@" + followers[x]["acct"] 578 | send_cr(connection, "pink") 579 | send_ln(connection, displayname + " ") 580 | send_cr(connection, text_color) 581 | send_ln(connection, username + "\n") 582 | 583 | if y==10: 584 | send_cr(connection, text_color) 585 | send_ln(connection, "\nPress ") 586 | connection.send(b'\x05') #white 587 | send_ln(connection, "Space ") 588 | send_cr(connection, text_color) 589 | send_ln(connection, "for next..\n(") 590 | connection.send(b'\x05') #white 591 | send_ln(connection, "e") 592 | send_cr(connection, text_color) 593 | send_ln(connection, ") to Enter choice. (") 594 | connection.send(b'\x05') #white 595 | send_ln(connection, "x") 596 | send_cr(connection, text_color) 597 | send_ln(connection, ") to Return.\n") 598 | send_cr(connection, "black") 599 | choice = get_char(connection) 600 | if choice == "x": 601 | return 602 | if choice == "e": 603 | choice_exit = True 604 | break 605 | connection.send(b'\x13') #clear 606 | connection.send(b'\x93') #home 607 | y=0 608 | x+=1 609 | else: 610 | x+=1 611 | y+=1 612 | 613 | if choice_exit == True: 614 | pass 615 | elif choice_exit == False: 616 | send_cr(connection, text_color) 617 | send_ln(connection, "\nPress ") 618 | connection.send(b'\x05') #white 619 | send_ln(connection, "Space ") 620 | send_cr(connection, text_color) 621 | send_ln(connection, "for next..\n(") 622 | connection.send(b'\x05') #white 623 | send_ln(connection, "e") 624 | send_cr(connection, text_color) 625 | send_ln(connection, ") to Enter choice. (") 626 | connection.send(b'\x05') #white 627 | send_ln(connection, "x") 628 | send_cr(connection, text_color) 629 | send_ln(connection, ") to Return.\n") 630 | send_cr(connection, "black") 631 | choice = get_char(connection) 632 | if choice == "x": 633 | return 634 | if choice == "e": 635 | choice_exit = True 636 | 637 | if choice_exit == True: 638 | 639 | connection.send(b'\x13') #clear 640 | connection.send(b'\x93') #home 641 | connection.send(b'\x05') #white 642 | send_ln(connection, "Enter User's Number.\n\n") 643 | try: 644 | choice = int(input_line(connection))-1 645 | follower_username = followers[choice]["acct"] 646 | follower_username = "@"+ follower_username 647 | send_cr(connection, secondary_menu_color) 648 | send_ln(connection, "Enter Direct Message.\nUsername automatically added.\n\n") 649 | send_cr(connection, text_color) 650 | message = input_line(connection) 651 | message = follower_username + " " + message 652 | mastodon.status_post(message,visibility="direct") 653 | return 654 | except: 655 | connection.send(b'\x13') #clear 656 | connection.send(b'\x93') #home 657 | connection.send(b'\x05') #white 658 | send_ln(connection, "Error.\nPress any key to Return.") 659 | get_char(connection) 660 | return 661 | 662 | except: 663 | return 664 | 665 | connection.send(b'\x13') #clear 666 | connection.send(b'\x93') #home 667 | connection.send(b'\x05') #white 668 | send_ln(connection, "End of list.\nPress any key to Return.") 669 | get_char(connection) 670 | return 671 | 672 | 673 | 674 | 675 | def search(connection): 676 | global secondary_menu_color 677 | global text_color 678 | global notification_color 679 | global tl 680 | global other_tl 681 | global return_page_tl 682 | global user_id 683 | choice_exit = False 684 | other_tl = "" 685 | return_page_tl = tl 686 | connection.send(b'\x13') #clear 687 | connection.send(b'\x93') #home 688 | send_cr(connection, secondary_menu_color) 689 | send_ln(connection, "Press (") 690 | connection.send(b'\x05') #white 691 | send_ln(connection, "1") 692 | send_cr(connection, secondary_menu_color) 693 | send_ln(connection, ") to search people you follow.\n\n") 694 | send_ln(connection, "Press (") 695 | connection.send(b'\x05') #white 696 | send_ln(connection, "2") 697 | send_cr(connection, secondary_menu_color) 698 | send_ln(connection, ") to search people who follow \nyou.\n\n") 699 | send_ln(connection, "Press (") 700 | connection.send(b'\x05') #white 701 | send_ln(connection, "3") 702 | send_cr(connection, secondary_menu_color) 703 | send_ln(connection, ") to search for people using\ntheir username.\n\n") 704 | send_ln(connection, "Press (") 705 | connection.send(b'\x05') #white 706 | send_ln(connection, "x") 707 | send_cr(connection, secondary_menu_color) 708 | send_ln(connection, ") to exit.\n\n") 709 | send_cr(connection, "black") 710 | choice = get_char(connection) 711 | 712 | 713 | if choice == "1": #following 714 | choice_exit = False 715 | connection.send(b'\x13') #clear 716 | connection.send(b'\x93') #home 717 | send_cr(connection, "white") 718 | send_ln(connection, "Remember the Followers Number!\n") 719 | following = mastodon.account_following(user_id,limit=80) 720 | x=0 721 | y=0 722 | for follow in following: 723 | print(str(x+1) + " " + following[x]["display_name"]) 724 | connection.send(b'\x05') #white 725 | send_ln(connection, str(x+1) + " ") 726 | displayname= following[x]["display_name"] 727 | displayname = re.sub(r':.*:','',displayname) 728 | displayname = deEmojify(connection ,displayname) 729 | displayname = anyascii(str(displayname)) 730 | if len(displayname) == 1 or len(displayname) == 0: 731 | displayname = following[x]["username"] 732 | username = "@" + following[x]["acct"] 733 | send_cr(connection, "pink") 734 | send_ln(connection, displayname + " ") 735 | send_cr(connection, text_color) 736 | send_ln(connection, username + "\n") 737 | if y==10: 738 | send_cr(connection, text_color) 739 | send_ln(connection, "\nPress ") 740 | connection.send(b'\x05') #white 741 | send_ln(connection, "Space ") 742 | send_cr(connection, text_color) 743 | send_ln(connection, "for next..\n(") 744 | connection.send(b'\x05') #white 745 | send_ln(connection, "e") 746 | send_cr(connection, text_color) 747 | send_ln(connection, ") to Enter choice. (") 748 | connection.send(b'\x05') #white 749 | send_ln(connection, "x") 750 | send_cr(connection, text_color) 751 | send_ln(connection, ") to Return.\n") 752 | send_cr(connection, "black") 753 | choice = get_char(connection) 754 | if choice == "x": 755 | return 756 | if choice == "e": 757 | choice_exit = True 758 | break 759 | connection.send(b'\x13') #clear 760 | connection.send(b'\x93') #home 761 | y=0 762 | x+=1 763 | else: 764 | x+=1 765 | y+=1 766 | if choice_exit == True: 767 | pass 768 | elif choice_exit == False: 769 | send_cr(connection, text_color) 770 | send_ln(connection, "\nPress ") 771 | connection.send(b'\x05') #white 772 | send_ln(connection, "Space ") 773 | send_cr(connection, text_color) 774 | send_ln(connection, "for next..\n(") 775 | connection.send(b'\x05') #white 776 | send_ln(connection, "e") 777 | send_cr(connection, text_color) 778 | send_ln(connection, ") to Enter choice. (") 779 | connection.send(b'\x05') #white 780 | send_ln(connection, "x") 781 | send_cr(connection, text_color) 782 | send_ln(connection, ") to Return.\n") 783 | send_cr(connection, "black") 784 | choice = get_char(connection) 785 | if choice == "x": 786 | return 787 | if choice == "e": 788 | choice_exit = True 789 | if choice_exit == True: 790 | connection.send(b'\x13') #clear 791 | connection.send(b'\x93') #home 792 | connection.send(b'\x05') #white 793 | send_ln(connection, "Enter User's Number.\n\n") 794 | try: 795 | choice = int(input_line(connection))-1 796 | account_id = following[choice]["id"] 797 | timeline = mastodon.account_statuses(account_id,exclude_reblogs=True,limit=1,max_id=datetime.now(timezone.utc)) 798 | user_page(connection,timeline[0]) 799 | return 800 | except: 801 | connection.send(b'\x13') #clear 802 | connection.send(b'\x93') #home 803 | connection.send(b'\x05') #white 804 | send_ln(connection, "Error.\nPress any key to Return.") 805 | get_char(connection) 806 | return 807 | 808 | while True: 809 | connection.send(b'\x13') #clear 810 | connection.send(b'\x93') #home 811 | print("Next Page") 812 | if choice_exit == True: 813 | break 814 | try: 815 | x=0 816 | y=0 817 | following = mastodon.fetch_next(following) 818 | for follow in following: 819 | print(str(x+1) + " " + following[x]["display_name"]) 820 | connection.send(b'\x05') #white 821 | send_ln(connection, str(x+1) + " ") 822 | displayname= following[x]["display_name"] 823 | displayname = re.sub(r':.*:','',displayname) 824 | displayname = deEmojify(connection ,displayname) 825 | displayname = anyascii(str(displayname)) 826 | if len(displayname) == 1 or len(displayname) == 0 : 827 | displayname = following[x]["username"] 828 | username = "@" + following[x]["acct"] 829 | send_cr(connection, "pink") 830 | send_ln(connection, displayname + " ") 831 | send_cr(connection, text_color) 832 | send_ln(connection, username + "\n") 833 | 834 | if y==10: 835 | send_cr(connection, text_color) 836 | send_ln(connection, "\nPress ") 837 | connection.send(b'\x05') #white 838 | send_ln(connection, "Space ") 839 | send_cr(connection, text_color) 840 | send_ln(connection, "for next..\n(") 841 | connection.send(b'\x05') #white 842 | send_ln(connection, "e") 843 | send_cr(connection, text_color) 844 | send_ln(connection, ") to Enter choice. (") 845 | connection.send(b'\x05') #white 846 | send_ln(connection, "x") 847 | send_cr(connection, text_color) 848 | send_ln(connection, ") to Return.\n") 849 | send_cr(connection, "black") 850 | choice = get_char(connection) 851 | if choice == "x": 852 | return 853 | if choice == "e": 854 | choice_exit = True 855 | break 856 | connection.send(b'\x13') #clear 857 | connection.send(b'\x93') #home 858 | y=0 859 | x+=1 860 | else: 861 | x+=1 862 | y+=1 863 | if choice_exit == True: 864 | pass 865 | elif choice_exit == False: 866 | send_cr(connection, text_color) 867 | send_ln(connection, "\nPress ") 868 | connection.send(b'\x05') #white 869 | send_ln(connection, "Space ") 870 | send_cr(connection, text_color) 871 | send_ln(connection, "for next..\n(") 872 | connection.send(b'\x05') #white 873 | send_ln(connection, "e") 874 | send_cr(connection, text_color) 875 | send_ln(connection, ") to Enter choice. (") 876 | connection.send(b'\x05') #white 877 | send_ln(connection, "x") 878 | send_cr(connection, text_color) 879 | send_ln(connection, ") to Return.\n") 880 | send_cr(connection, "black") 881 | choice = get_char(connection) 882 | if choice == "x": 883 | return 884 | if choice == "e": 885 | choice_exit = True 886 | 887 | if choice_exit == True: 888 | 889 | connection.send(b'\x13') #clear 890 | connection.send(b'\x93') #home 891 | connection.send(b'\x05') #white 892 | send_ln(connection, "Enter User's Number.\n\n") 893 | try: 894 | choice = int(input_line(connection))-1 895 | account_id = following[choice]["id"] 896 | timeline = mastodon.account_statuses(account_id,exclude_reblogs=True,limit=1,max_id=datetime.now(timezone.utc)) 897 | user_page(connection,timeline[0]) 898 | return 899 | except: 900 | connection.send(b'\x13') #clear 901 | connection.send(b'\x93') #home 902 | connection.send(b'\x05') #white 903 | send_ln(connection, "Error.\nPress any key to Return.") 904 | get_char(connection) 905 | return 906 | 907 | except: 908 | return 909 | 910 | connection.send(b'\x13') #clear 911 | connection.send(b'\x93') #home 912 | connection.send(b'\x05') #white 913 | send_ln(connection, "End of list.\nPress any key to Return.") 914 | get_char(connection) 915 | return 916 | 917 | 918 | if choice == "2": #following 919 | choice_exit = False 920 | connection.send(b'\x13') #clear 921 | connection.send(b'\x93') #home 922 | send_cr(connection, "white") 923 | send_ln(connection, "Remember the Followers Number!\n") 924 | followers = mastodon.account_followers(user_id,limit=80) 925 | x=0 926 | y=0 927 | for follow in followers: 928 | print(str(x+1) + " " + followers[x]["display_name"]) 929 | connection.send(b'\x05') #white 930 | send_ln(connection, str(x+1) + " ") 931 | displayname= followers[x]["display_name"] 932 | displayname = re.sub(r':.*:','',displayname) 933 | displayname = deEmojify(connection ,displayname) 934 | displayname = anyascii(str(displayname)) 935 | if len(displayname) == 1 or len(displayname) == 0 : 936 | displayname = followers[x]["username"] 937 | username = "@" + followers[x]["acct"] 938 | send_cr(connection, "pink") 939 | send_ln(connection, displayname + " ") 940 | send_cr(connection, text_color) 941 | send_ln(connection, username + "\n") 942 | if y==10: 943 | send_cr(connection, text_color) 944 | send_ln(connection, "\nPress ") 945 | connection.send(b'\x05') #white 946 | send_ln(connection, "Space ") 947 | send_cr(connection, text_color) 948 | send_ln(connection, "for next..\n(") 949 | connection.send(b'\x05') #white 950 | send_ln(connection, "e") 951 | send_cr(connection, text_color) 952 | send_ln(connection, ") to Enter choice. (") 953 | connection.send(b'\x05') #white 954 | send_ln(connection, "x") 955 | send_cr(connection, text_color) 956 | send_ln(connection, ") to Return.\n") 957 | send_cr(connection, "black") 958 | choice = get_char(connection) 959 | if choice == "x": 960 | return 961 | if choice == "e": 962 | choice_exit = True 963 | break 964 | connection.send(b'\x13') #clear 965 | connection.send(b'\x93') #home 966 | y=0 967 | x+=1 968 | else: 969 | x+=1 970 | y+=1 971 | 972 | if choice_exit == True: 973 | pass 974 | elif choice_exit == False: 975 | send_cr(connection, text_color) 976 | send_ln(connection, "\nPress ") 977 | connection.send(b'\x05') #white 978 | send_ln(connection, "Space ") 979 | send_cr(connection, text_color) 980 | send_ln(connection, "for next..\n(") 981 | connection.send(b'\x05') #white 982 | send_ln(connection, "e") 983 | send_cr(connection, text_color) 984 | send_ln(connection, ") to Enter choice. (") 985 | connection.send(b'\x05') #white 986 | send_ln(connection, "x") 987 | send_cr(connection, text_color) 988 | send_ln(connection, ") to Return.\n") 989 | send_cr(connection, "black") 990 | choice = get_char(connection) 991 | if choice == "x": 992 | return 993 | if choice == "e": 994 | choice_exit = True 995 | if choice_exit == True: 996 | connection.send(b'\x13') #clear 997 | connection.send(b'\x93') #home 998 | connection.send(b'\x05') #white 999 | send_ln(connection, "Enter User's Number.\n\n") 1000 | try: 1001 | choice = int(input_line(connection))-1 1002 | account_id = followers[choice]["id"] 1003 | timeline = mastodon.account_statuses(account_id,exclude_reblogs=True,limit=1,max_id=datetime.now(timezone.utc)) 1004 | user_page(connection,timeline[0]) 1005 | return 1006 | except: 1007 | connection.send(b'\x13') #clear 1008 | connection.send(b'\x93') #home 1009 | connection.send(b'\x05') #white 1010 | send_ln(connection, "Error.\nPress any key to Return.") 1011 | get_char(connection) 1012 | return 1013 | 1014 | 1015 | while True: 1016 | connection.send(b'\x13') #clear 1017 | connection.send(b'\x93') #home 1018 | print("Next Page") 1019 | if choice_exit == True: 1020 | break 1021 | try: 1022 | x=0 1023 | y=0 1024 | followers = mastodon.fetch_next(followers) 1025 | for follow in followers: 1026 | print(str(x+1) + " " + followers[x]["display_name"]) 1027 | connection.send(b'\x05') #white 1028 | send_ln(connection, str(x+1) + " ") 1029 | displayname= followers[x]["display_name"] 1030 | displayname = re.sub(r':.*:','',displayname) 1031 | displayname = deEmojify(connection ,displayname) 1032 | displayname = anyascii(str(displayname)) 1033 | if len(displayname) == 1 or len(displayname) == 0 : 1034 | displayname = followers[x]["username"] 1035 | username = "@" + followers[x]["acct"] 1036 | send_cr(connection, "pink") 1037 | send_ln(connection, displayname + " ") 1038 | send_cr(connection, text_color) 1039 | send_ln(connection, username + "\n") 1040 | 1041 | if y==10: 1042 | send_cr(connection, text_color) 1043 | send_ln(connection, "\nPress ") 1044 | connection.send(b'\x05') #white 1045 | send_ln(connection, "Space ") 1046 | send_cr(connection, text_color) 1047 | send_ln(connection, "for next..\n(") 1048 | connection.send(b'\x05') #white 1049 | send_ln(connection, "e") 1050 | send_cr(connection, text_color) 1051 | send_ln(connection, ") to Enter choice. (") 1052 | connection.send(b'\x05') #white 1053 | send_ln(connection, "x") 1054 | send_cr(connection, text_color) 1055 | send_ln(connection, ") to Return.\n") 1056 | send_cr(connection, "black") 1057 | choice = get_char(connection) 1058 | if choice == "x": 1059 | return 1060 | if choice == "e": 1061 | choice_exit = True 1062 | break 1063 | connection.send(b'\x13') #clear 1064 | connection.send(b'\x93') #home 1065 | y=0 1066 | x+=1 1067 | else: 1068 | x+=1 1069 | y+=1 1070 | 1071 | if choice_exit == True: 1072 | pass 1073 | elif choice_exit == False: 1074 | send_cr(connection, text_color) 1075 | send_ln(connection, "\nPress ") 1076 | connection.send(b'\x05') #white 1077 | send_ln(connection, "Space ") 1078 | send_cr(connection, text_color) 1079 | send_ln(connection, "for next..\n(") 1080 | connection.send(b'\x05') #white 1081 | send_ln(connection, "e") 1082 | send_cr(connection, text_color) 1083 | send_ln(connection, ") to Enter choice. (") 1084 | connection.send(b'\x05') #white 1085 | send_ln(connection, "x") 1086 | send_cr(connection, text_color) 1087 | send_ln(connection, ") to Return.\n") 1088 | send_cr(connection, "black") 1089 | choice = get_char(connection) 1090 | 1091 | if choice == "x": 1092 | return 1093 | if choice == "e": 1094 | choice_exit = True 1095 | 1096 | if choice_exit == True: 1097 | 1098 | connection.send(b'\x13') #clear 1099 | connection.send(b'\x93') #home 1100 | connection.send(b'\x05') #white 1101 | send_ln(connection, "Enter User's Number.\n\n") 1102 | try: 1103 | choice = int(input_line(connection))-1 1104 | account_id = followers[choice]["id"] 1105 | timeline = mastodon.account_statuses(account_id,exclude_reblogs=True,limit=1,max_id=datetime.now(timezone.utc)) 1106 | user_page(connection,timeline[0]) 1107 | return 1108 | except: 1109 | connection.send(b'\x13') #clear 1110 | connection.send(b'\x93') #home 1111 | connection.send(b'\x05') #white 1112 | send_ln(connection, "Error.\nPress any key to Return.") 1113 | get_char(connection) 1114 | return 1115 | 1116 | except: 1117 | return 1118 | connection.send(b'\x13') #clear 1119 | connection.send(b'\x93') #home 1120 | connection.send(b'\x05') #white 1121 | send_ln(connection, "End of list.\nPress any key to Return.") 1122 | get_char(connection) 1123 | return 1124 | 1125 | 1126 | 1127 | if choice == "3": 1128 | connection.send(b'\x13') #clear 1129 | connection.send(b'\x93') #home 1130 | send_cr(connection, secondary_menu_color) 1131 | send_ln(connection, "Enter username. ") 1132 | connection.send(b'\x05') #white 1133 | send_ln(connection, "someone") 1134 | send_cr(connection, "pink") 1135 | send_ln(connection, "@someserver.com\n") 1136 | send_cr(connection, secondary_menu_color) 1137 | send_ln(connection, "Or just ") 1138 | connection.send(b'\x05') #white 1139 | send_ln(connection, "someone\n\n") 1140 | connection.send(b'\x05') #white 1141 | send_ln(connection, "Rembember user number!!\n") 1142 | send_cr(connection, secondary_menu_color) 1143 | send_ln(connection, "Enter (") 1144 | connection.send(b'\x05') #white 1145 | send_ln(connection, "x") 1146 | send_cr(connection, secondary_menu_color) 1147 | send_ln(connection, ") to exit.\n\n") 1148 | while True: 1149 | connection.send(b'\x05') #white 1150 | choice = input_line(connection) 1151 | if choice == "x": 1152 | return 1153 | else: 1154 | user_id = mastodon.account_search(choice) 1155 | if user_id: 1156 | x=0 1157 | y=0 1158 | for s in user_id: 1159 | print(str(x+1) + " " + user_id[x]["display_name"]) 1160 | connection.send(b'\x05') #white 1161 | send_ln(connection, str(x+1) + " ") 1162 | account_id = user_id[x]["id"] 1163 | displayname= user_id[x]["display_name"] 1164 | displayname = re.sub(r':.*:','',displayname) 1165 | displayname = deEmojify(connection ,displayname) 1166 | displayname = anyascii(str(displayname)) 1167 | username = "@" + user_id[x]["acct"] 1168 | send_cr(connection, "pink") 1169 | send_ln(connection, displayname + " ") 1170 | send_cr(connection, text_color) 1171 | send_ln(connection, username + "\n") 1172 | 1173 | if y==10: 1174 | connection.send(b'\x05') #white 1175 | send_ln(connection, "\nPress any key..") 1176 | send_cr(connection, "black") 1177 | choice = get_char(connection) 1178 | connection.send(b'\x13') #clear 1179 | connection.send(b'\x93') #home 1180 | if choice == "x": 1181 | return 1182 | if choice == "e": 1183 | choice_exit = True 1184 | break 1185 | y=0 1186 | x+=1 1187 | else: 1188 | x+=1 1189 | y+=1 1190 | if choice_exit == True: 1191 | break 1192 | else: 1193 | send_cr(connection, secondary_menu_color) 1194 | send_ln(connection, "No user found.\n") 1195 | connection.send(b'\x05') #white 1196 | send_ln(connection, "Press any key to Return.") 1197 | get_char(connection) 1198 | return 1199 | 1200 | 1201 | connection.send(b'\x13') #clear 1202 | connection.send(b'\x93') #home 1203 | connection.send(b'\x05') #white 1204 | send_ln(connection, "Enter User's Number.\n\n") 1205 | try: 1206 | choice = int(input_line(connection))-1 1207 | account_id = user_id[choice]["id"] 1208 | timeline = mastodon.account_statuses(account_id,exclude_reblogs=True,limit=1,max_id=datetime.now(timezone.utc)) 1209 | user_page(connection,timeline[0]) 1210 | return 1211 | except: 1212 | connection.send(b'\x13') #clear 1213 | connection.send(b'\x93') #home 1214 | connection.send(b'\x05') #white 1215 | send_ln(connection, "Error.\nPress any key to Return.") 1216 | get_char(connection) 1217 | return 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | def time_posted(connection, view_time): 1224 | global time_color 1225 | sec = int(view_time.total_seconds()) 1226 | minute = int(sec / 60) 1227 | hour = int(sec / (60 * 60)) 1228 | days= int(view_time.days) 1229 | weeks = int(days / 7) 1230 | months = int(weeks / 4) 1231 | if sec < 60: 1232 | Time = str(sec) + " Secs " 1233 | print(Time) 1234 | connection.send(b'\x05') #white 1235 | send_ln(connection," " + str(sec)) 1236 | send_cr(connection, time_color) 1237 | send_ln(connection, " Secs") 1238 | return 1239 | if sec >= 60 and minute < 2: 1240 | Time = "1 Min " 1241 | print(Time) 1242 | connection.send(b'\x05') #white 1243 | send_ln(connection, " 1 ") 1244 | send_cr(connection, time_color) 1245 | send_ln(connection, " Min") 1246 | return 1247 | 1248 | if minute > 1 and minute < 60: 1249 | Time = str(minute) + " Mins " 1250 | print(Time) 1251 | connection.send(b'\x05') #white 1252 | send_ln(connection, " " + str(minute)) 1253 | send_cr(connection, time_color) 1254 | send_ln(connection, " Mins") 1255 | return #time 1256 | 1257 | if minute > 60 and minute < 120: 1258 | Time = str(hour) + " Hour " 1259 | print(Time) 1260 | connection.send(b'\x05') #white 1261 | send_ln(connection, " " + str(hour)) 1262 | send_cr(connection, time_color) 1263 | send_ln(connection, " Hour") 1264 | return 1265 | 1266 | if hour > 1 and hour < 24: 1267 | Time = str(hour) + " Hours " 1268 | print(Time) 1269 | connection.send(b'\x05') #white 1270 | send_ln(connection, " " + str(hour)) 1271 | send_cr(connection, time_color) 1272 | send_ln(connection, " Hours") 1273 | return 1274 | 1275 | if days < 2 : 1276 | Time = str(days) + " Day " 1277 | print(Time) 1278 | connection.send(b'\x05') #white 1279 | send_ln(connection, " 1") 1280 | send_cr(connection, time_color) 1281 | send_ln(connection, " Day") 1282 | return 1283 | 1284 | if days < 7: 1285 | Time = str(days) + " Days " 1286 | print(Time) 1287 | connection.send(b'\x05') #white 1288 | send_ln(connection, " " + str(days)) 1289 | send_cr(connection, time_color) 1290 | send_ln(connection, " Days") 1291 | return 1292 | 1293 | if days < 14: 1294 | Time = " 1 Week " 1295 | print(Time) 1296 | connection.send(b'\x05') #white 1297 | send_ln(connection, " 1") 1298 | send_cr(connection, time_color) 1299 | send_ln(connection, " Week") 1300 | return 1301 | 1302 | if weeks < 5: 1303 | Time = str(weeks) + " Weeks " 1304 | print(Time) 1305 | connection.send(b'\x05') #white 1306 | send_ln(connection, " " + str(weeks)) 1307 | send_cr(connection, time_color) 1308 | send_ln(connection, " Weeks") 1309 | return 1310 | 1311 | if weeks <9: 1312 | Time = "1 Month " 1313 | print(Time) 1314 | connection.send(b'\x05') #white 1315 | send_ln(connection, " 1 ") 1316 | send_cr(connection, time_color) 1317 | send_ln(connection, "Month") 1318 | return 1319 | 1320 | if months < 12: 1321 | Time = str(months) + " Months " 1322 | print(Time) 1323 | connection.send(b'\x05') #white 1324 | send_ln(connection, " " + str(months)) 1325 | send_cr(connection, time_color) 1326 | send_ln(connection, " Months") 1327 | return 1328 | 1329 | if months >= 12 and months < 24: 1330 | Time = "1 Year " 1331 | print(Time) 1332 | connection.send(b'\x05') #white 1333 | send_ln(connection, " 1") 1334 | send_cr(connection, time_color) 1335 | send_ln(connection, " Year") 1336 | return 1337 | 1338 | if months >24: 1339 | year = int(days/365) 1340 | Time = str(year) + " Years " 1341 | print(Time) 1342 | connection.send(b'\x05') #white 1343 | send_ln(connection, " " + str(year)) 1344 | send_cr(connection, time_color) 1345 | send_ln(connection, " Years") 1346 | return 1347 | 1348 | 1349 | def parse_contentNotifications(connection, notify): 1350 | content = notify['status']["content"] 1351 | content = re.sub(r'
', '\n', content) 1352 | content = re.sub(r'
', '\n', content) 1353 | content = re.sub(r'

', '\n', content) 1354 | content = re.sub(r"£","lll" ,content) 1355 | content = re.sub(r"lll","£" ,content) 1356 | content = strip_tags(connection, content) 1357 | content = deEmojify(connection, content) 1358 | content = anyascii(str(content)) 1359 | favourites = notify["status"]["favourites_count"] 1360 | replies = notify["status"]["replies_count"] 1361 | boosts = notify["status"]["reblogs_count"] 1362 | 1363 | if notify["status"]["media_attachments"]: 1364 | media = notify["status"]["media_attachments"] 1365 | alt_text = media[0]["description"] 1366 | media_type = media[0]["type"] 1367 | if media_type == "image": 1368 | media_type = "\nPosted a Picture\n" 1369 | if media_type == "video": 1370 | media_type = "\nPosted a Video\n" 1371 | if media_type == "gifv": 1372 | media_type = "\nPosted a GIF\n" 1373 | if media_type == "audio": 1374 | media_type = "\nPosted Audio\n" 1375 | if media_type == "unknown": 1376 | media_type = "\nPosted Unknown\n" 1377 | if alt_text == None: 1378 | pass 1379 | else: 1380 | alt_text = "Alt Text - \n" + alt_text 1381 | alt_text = strip_tags(connection, alt_text) 1382 | alt_text = deEmojify(connection, alt_text) 1383 | alt_text = anyascii(str(alt_text)) 1384 | else: 1385 | media_type = None 1386 | alt_text = None 1387 | 1388 | if media_type: 1389 | if content == None: 1390 | content = media_type 1391 | else: 1392 | content = content + "\n" + media_type 1393 | 1394 | if alt_text: 1395 | content = content + alt_text 1396 | 1397 | return content, favourites, replies, boosts, media_type 1398 | 1399 | def parse_content(connection, text): 1400 | content = re.sub(r'
', '\n', text) 1401 | content = re.sub(r'
', '\n', content) 1402 | content = re.sub(r'

', '\n', content) 1403 | content = re.sub(r"£","lll" ,content) 1404 | content = re.sub(r"lll","£" ,content) 1405 | content = strip_tags(connection, content) 1406 | content = deEmojify(connection, content) 1407 | content = anyascii(str(content)) 1408 | return content 1409 | 1410 | def new_notifications(connection): 1411 | global notify_id 1412 | global notification_color 1413 | notify = mastodon.notifications(limit = 1) 1414 | last_notify = notify[0]['created_at'] 1415 | if last_notify > notify_id: 1416 | print("New notification !!! ") 1417 | connection.send(b'\x07') 1418 | send_cr(connection, notification_color) 1419 | cursorxy(connection,1,21) 1420 | new_notification = " New Notification !!! " 1421 | send_cr(connection, "revon") 1422 | send_ln(connection, new_notification) 1423 | send_cr(connection, "revoff") 1424 | send_cr(connection, "black") 1425 | 1426 | 1427 | def notifications(connection): 1428 | global notify_id 1429 | global displayname_color 1430 | global text_color 1431 | global secondary_menu_color 1432 | global other_page 1433 | global tl 1434 | global return_page_tl 1435 | time_now = datetime.now(timezone.utc) 1436 | notify_id = time_now #Clears the new notification alert 1437 | notify = mastodon.notifications(limit = 40) 1438 | length = len(notify) 1439 | y = 0 1440 | exit_from = False 1441 | while True: 1442 | if y == length: 1443 | break 1444 | notify_time = notify[y]['created_at'] 1445 | view_time = time_now - notify_time 1446 | account_id = notify[y]["account"]["id"] 1447 | displayname = notify[y]['account']['display_name'] 1448 | displayname = re.sub(r':.*:','',displayname) 1449 | displayname = deEmojify(connection, displayname) 1450 | displayname = anyascii(str(displayname)) 1451 | username = "@" + notify[y]['account']['acct'] 1452 | if len(displayname) == 1 or len(displayname) == 0 : 1453 | displayname = timeline["account"]["username"] 1454 | 1455 | 1456 | if notify[y]['type'] == 'favourite': 1457 | print("----------------------------------------------------\n") 1458 | print(displayname + " Favourited " ) 1459 | content,favourites,replies, boosts, media_type = parse_contentNotifications(connection, notify[y]) 1460 | is_boosted=False 1461 | connection.send(b'\x13') #clear 1462 | connection.send(b'\x93') #home 1463 | send_cr(connection, displayname_color) 1464 | send_ln(connection, displayname) 1465 | time_posted(connection, view_time) 1466 | send_cr(connection, displayname_color) 1467 | send_ln(connection, "\n" + username) 1468 | send_cr(connection, "white") 1469 | send_ln(connection, "\n\nFavourited your Toot\n\n") 1470 | send_cr(connection, text_color) 1471 | do_print(connection,content,is_boosted) 1472 | interaction = interactions(connection, favourites,replies,boosts) 1473 | cursorxy(connection,1,23) 1474 | send_cr(connection, secondary_menu_color) 1475 | send_ln(connection, " (") 1476 | send_cr(connection, "white") 1477 | send_ln(connection, "i") 1478 | send_cr(connection, secondary_menu_color) 1479 | send_ln(connection, ")nteract") 1480 | send_cr(connection, "black") 1481 | 1482 | 1483 | if notify[y]['type'] == 'mention': 1484 | print(displayname + " Mentioned " ) 1485 | content,favourites,replies, boosts, media_type = parse_contentNotifications(connection, notify[y]) 1486 | is_boosted=False 1487 | connection.send(b'\x13') #clear 1488 | connection.send(b'\x93') #home 1489 | send_cr(connection, displayname_color) 1490 | send_ln(connection, displayname) 1491 | time_posted(connection, view_time) 1492 | send_cr(connection, displayname_color) 1493 | send_ln(connection, "\n" + username) 1494 | send_cr(connection, "white") 1495 | send_ln(connection, "\n\nMentioned you\n\n") 1496 | send_cr(connection, text_color) 1497 | do_print(connection, content,is_boosted) 1498 | interaction = interactions(connection, favourites,replies,boosts) 1499 | send_cr(connection, secondary_menu_color) 1500 | cursorxy(connection,1,23) 1501 | send_ln(connection, " Fa(") 1502 | connection.send(b'\x05') #white 1503 | send_ln(connection, "v") 1504 | send_cr(connection, secondary_menu_color) 1505 | send_ln(connection, ") (") 1506 | connection.send(b'\x05') #white 1507 | send_ln(connection, "r") 1508 | send_cr(connection, secondary_menu_color) 1509 | send_ln(connection, ")eply (") 1510 | connection.send(b'\x05') #white 1511 | send_ln(connection,"i") 1512 | send_cr(connection, secondary_menu_color) 1513 | send_ln(connection, ")nteract") 1514 | send_cr(connection, "black") 1515 | 1516 | if notify[y]['type'] == 'reblog': 1517 | print(displayname + " Boosted " ) 1518 | content,favourites,replies, boosts, media_type = parse_contentNotifications(connection, notify[y]) 1519 | connection.send(b'\x13') #clear 1520 | connection.send(b'\x93') #home 1521 | send_cr(connection, displayname_color) 1522 | send_ln(connection, displayname) 1523 | time_posted(connection, view_time) 1524 | send_cr(connection, displayname_color) 1525 | send_ln(connection, "\n" + username) 1526 | send_cr(connection, "white") 1527 | send_ln(connection, "\n\nBoosted your Toot\n\n") 1528 | send_cr(connection, text_color) 1529 | do_print(connection, content,is_boosted=False) 1530 | interaction = interactions(connection, favourites,replies,boosts) 1531 | cursorxy(connection,1,23) 1532 | send_cr(connection, secondary_menu_color) 1533 | send_ln(connection, " (") 1534 | send_cr(connection, "white") 1535 | send_ln(connection, "i") 1536 | send_cr(connection, secondary_menu_color) 1537 | send_ln(connection, ")nteract") 1538 | send_cr(connection, "black") 1539 | 1540 | if notify[y]['type'] == 'follow': 1541 | print(displayname + " Followed you") 1542 | connection.send(b'\x13') #clear 1543 | connection.send(b'\x93') #home 1544 | send_cr(connection, displayname_color) 1545 | send_ln(connection, displayname) 1546 | time_posted(connection, view_time) 1547 | send_cr(connection, displayname_color) 1548 | send_ln(connection, "\n" + username) 1549 | send_cr(connection, "white") 1550 | send_ln(connection, "\n\nFollowed You") 1551 | cursorxy(connection,1,23) 1552 | send_cr(connection, secondary_menu_color) 1553 | send_ln(connection, " (") 1554 | send_cr(connection, "white") 1555 | send_ln(connection, "i") 1556 | send_cr(connection, secondary_menu_color) 1557 | send_ln(connection, ")nteract") 1558 | send_cr(connection, "black") 1559 | 1560 | if notify[y]['type'] == 'follow_request': 1561 | print(displayname + " Wants to follow you ") 1562 | connection.send(b'\x13') #clear 1563 | connection.send(b'\x93') #home 1564 | send_cr(connection, displayname_color) 1565 | send_ln(connection, displayname) 1566 | time_posted(connection, view_time) 1567 | send_cr(connection, displayname_color) 1568 | send_ln(connection, "\n" + username) 1569 | send_cr(connection, "white") 1570 | send_ln(connection, "\n\nWant's to Follow you.") 1571 | cursorxy(connection,1,23) 1572 | send_cr(connection, secondary_menu_color) 1573 | send_ln(connection, " (") 1574 | send_cr(connection, "white") 1575 | send_ln(connection, "i") 1576 | send_cr(connection, secondary_menu_color) 1577 | send_ln(connection, ")nteract (") 1578 | send_cr(connection, "white") 1579 | send_ln(connection, "a") 1580 | send_cr(connection, secondary_menu_color) 1581 | send_ln(connection, ")uthorize request") 1582 | send_cr(connection, "black") 1583 | 1584 | send_cr(connection, secondary_menu_color) 1585 | cursorxy(connection,1,24) 1586 | connection.send(b'\x05') #white 1587 | send_ln(connection, " Space ") 1588 | send_cr(connection, secondary_menu_color) 1589 | send_ln(connection, "for next notification.\n") 1590 | send_ln(connection, " (") 1591 | connection.send(b'\x05') #white 1592 | send_ln(connection, "x") 1593 | send_cr(connection, secondary_menu_color) 1594 | send_ln(connection, ") to exit back to timeline.") 1595 | send_cr(connection, "black") 1596 | 1597 | while True: 1598 | 1599 | choice = get_char(connection) 1600 | if choice == "a" and notify[y]['type'] == 'follow_request': 1601 | try: 1602 | mastodon.follow_request_authorize(account_id) 1603 | cursorxy(connection,1,22) 1604 | connection.send(b'\x05') #white 1605 | send_ln(connection, "Follow request approved...") 1606 | send_cr(connection, "black") 1607 | connection.send(b'\x07') 1608 | except: 1609 | pass 1610 | 1611 | if choice == "i": 1612 | if other_page == False: 1613 | return_page_tl = tl 1614 | 1615 | timeline = mastodon.account_statuses(account_id,exclude_reblogs=True,limit=1,max_id=datetime.now(timezone.utc)) 1616 | user_page(connection,timeline[0]) 1617 | if other_page == True: 1618 | return 1619 | else: 1620 | y-=1 1621 | break 1622 | 1623 | if choice == "x": 1624 | exit_from = True 1625 | break 1626 | 1627 | if choice == "v" and notify[y]['type'] == 'mention': 1628 | try: 1629 | mastodon.status_favourite(notify[y]["status"]["id"]) 1630 | cursorxy(connection,1,22) 1631 | connection.send(b'\x05') #white 1632 | send_ln(connection, "You Favourited this Toot ! ") 1633 | send_cr(connection, "black") 1634 | connection.send(b'\x07') 1635 | except: 1636 | pass 1637 | 1638 | if choice == "r" and notify[y]['type'] == 'mention': 1639 | connection.send(b'\x13') #home 1640 | connection.send(b'\x93') #clear 1641 | connection.send(b'\x05') #white 1642 | send_ln(connection, "Usernames are automatically added to\n") 1643 | send_ln(connection, "reply..\n\n") 1644 | send_ln(connection, "Enter Reply...\n") 1645 | send_cr(connection, text_color) 1646 | reply = input_line(connection) 1647 | try: 1648 | mastodon.status_reply(notify[y]["status"],reply,in_reply_to_id=notify[y]["status"]["id"]) 1649 | except: 1650 | pass 1651 | y-=1 1652 | break 1653 | if choice == " ": 1654 | break 1655 | if exit_from == True: 1656 | return 1657 | else: 1658 | y+=1 1659 | 1660 | 1661 | connection.send(b'\x13') #clear 1662 | connection.send(b'\x93') #home 1663 | send_cr(connection, "white") 1664 | send_ln(connection, " End of retrieved Notifications.\n") 1665 | send_ln(connection, " Press any key to return to timeline.") 1666 | send_cr(connection, "black") 1667 | get_char(connection) 1668 | print("\n\n---------------------------------------------------------") 1669 | return 1670 | 1671 | 1672 | def interactions(connection, favourites,replies,boosts): 1673 | global interaction_color 1674 | if interactions: 1675 | send_ln(connection, "\n") 1676 | if favourites == 0: 1677 | favourites_out = "" 1678 | elif favourites == 1: 1679 | favourites_out = "1 Favourite " 1680 | send_cr(connection, "white") 1681 | send_ln(connection, "1 ") 1682 | send_cr(connection, interaction_color) 1683 | send_ln(connection, "Favourite ") 1684 | else: 1685 | favourites_out = str(favourites) + " Favourites " 1686 | send_cr(connection, "white") 1687 | send_ln(connection, str(favourites)) 1688 | send_cr(connection, interaction_color) 1689 | send_ln(connection, " Favourites ") 1690 | 1691 | if replies == 0: 1692 | replies_out = "" 1693 | elif replies == 1: 1694 | replies_out = "1 Reply " 1695 | send_cr(connection, "white") 1696 | send_ln(connection, "1 ") 1697 | send_cr(connection, interaction_color) 1698 | send_ln(connection, "Reply ") 1699 | else: 1700 | print(str(replies) + " Replies ") 1701 | replies_out = str(replies) + " Replies " 1702 | send_cr(connection, "white") 1703 | send_ln(connection, str(replies)) 1704 | send_cr(connection, interaction_color) 1705 | send_ln(connection, " Replies ") 1706 | 1707 | if boosts == 0: 1708 | boosts_out = "" 1709 | elif boosts == 1: 1710 | boosts_out = "1 Boost" 1711 | send_cr(connection, "white") 1712 | send_ln(connection, "1 ") 1713 | send_cr(connection, interaction_color) 1714 | send_ln(connection, "Boost ") 1715 | 1716 | else: 1717 | boosts_out = str(boosts) + " Boosts" 1718 | send_cr(connection, "white") 1719 | send_ln(connection, str(boosts)) 1720 | send_cr(connection, interaction_color) 1721 | send_ln(connection, " Boosts ") 1722 | 1723 | 1724 | def get_content(connection, timeline): 1725 | time_now = datetime.now(timezone.utc) 1726 | created_at= timeline["created_at"] 1727 | view_time = time_now - created_at 1728 | displayname = timeline["account"]["display_name"] 1729 | displayname = re.sub(r':.*:','',displayname) 1730 | displayname = deEmojify(connection, displayname) 1731 | displayname = anyascii(str(displayname)) 1732 | username = "@" + timeline["account"]["acct"] 1733 | if len(displayname) == 1 or len(displayname) == 0 : 1734 | displayname = timeline["account"]["username"] 1735 | 1736 | favourites = timeline["favourites_count"] 1737 | replies = timeline["replies_count"] 1738 | boosts = timeline["reblogs_count"] 1739 | content = timeline["content"] 1740 | content = re.sub(r'
', '\n', content) 1741 | content = re.sub(r'
', '\n', content) 1742 | content = re.sub(r'

', '\n', content) 1743 | content = re.sub(r"£","lll" ,content) 1744 | content = strip_tags(connection, content) 1745 | content = deEmojify(connection, content) 1746 | content = anyascii(str(content)) 1747 | content = re.sub(r"lll","£" ,content) 1748 | boosted = timeline["reblog"] 1749 | 1750 | if timeline["media_attachments"]: 1751 | media = timeline["media_attachments"] 1752 | alt_text = media[0]["description"] 1753 | media_type = media[0]["type"] 1754 | if media_type == "image": 1755 | media_type = "Posted a Picture" 1756 | if media_type == "video": 1757 | media_type = "Posted a Video" 1758 | if media_type == "gifv": 1759 | media_type = "Posted a GIF" 1760 | if media_type == "audio": 1761 | media_type = "Posted Audio" 1762 | if media_type == "unknown": 1763 | media_type = "Posted Unknown" 1764 | 1765 | if alt_text == None: 1766 | pass 1767 | else: 1768 | alt_text = "Alt Text - \n" + alt_text 1769 | alt_text = strip_tags(connection, alt_text) 1770 | alt_text = deEmojify(connection, alt_text) 1771 | alt_text = anyascii(str(alt_text)) 1772 | 1773 | else: 1774 | alt_text = None 1775 | media_type = None 1776 | 1777 | return view_time,displayname,username,favourites,replies,boosts,content,boosted,alt_text,media_type 1778 | 1779 | 1780 | def do_print(connection,content,is_boosted): 1781 | global text_color 1782 | global alt_text_color 1783 | global pinned 1784 | x=0 1785 | if is_boosted == True: 1786 | x = 3 1787 | elif pinned == True: 1788 | x+=2 1789 | 1790 | alt=False 1791 | lines = content.split("\n") 1792 | lists = (textwrap.TextWrapper(width=38).wrap(line) for line in lines) 1793 | body = "\n".join("\n".join(list) for list in lists) 1794 | print(body) 1795 | lines = body.splitlines() 1796 | for line in lines: 1797 | if line.startswith("Posted a Picture") or line.startswith("Posted a Video") or line.startswith("Posted a GIF") or line.startswith("Posted Unknown"): 1798 | send_cr(connection, "cyan") 1799 | x+=2 1800 | length = len(line) 1801 | for loop in range(1): 1802 | for i in range(length): 1803 | send_ln(connection, line[i]) 1804 | send_ln(connection, "\n") 1805 | 1806 | elif line.startswith("Alt Text -"): 1807 | x+=2 1808 | alt= True 1809 | send_ln(connection, "\n") 1810 | send_cr(connection, "yellow") 1811 | for loop in range(1): 1812 | send_ln(connection, line + "\n") 1813 | 1814 | send_ln(connection, "\n") 1815 | send_cr(connection, alt_text_color) 1816 | 1817 | else: 1818 | words = line.split(" ") 1819 | for word in words: 1820 | if re.findall(r'^#', word) or re.findall(r'^@', word): 1821 | send_cr(connection, "red") 1822 | send_ln(connection, word + " ") 1823 | 1824 | else: 1825 | if alt==False: 1826 | send_cr(connection, text_color) 1827 | send_ln(connection, word + " ") 1828 | else: 1829 | send_cr(connection, alt_text_color) 1830 | send_ln(connection, word + " ") 1831 | 1832 | send_ln(connection, "\n") 1833 | 1834 | if x >= 17: 1835 | send_cr(connection, "white") 1836 | send_ln(connection, "\nPress any key for next page") 1837 | send_cr(connection, "black") 1838 | get_char(connection) 1839 | if alt==True: 1840 | send_cr(connection, alt_text_color) 1841 | else: 1842 | send_cr(connection, text_color) 1843 | 1844 | connection.send(b'\x13') #clear 1845 | connection.send(b'\x93') #home 1846 | x=0 1847 | x+=1 1848 | 1849 | 1850 | def messages(connection): 1851 | global notification_color 1852 | global text_color 1853 | global displayname_color 1854 | global text_color 1855 | global main_menu_color 1856 | global secondary_menu_color 1857 | global other_page 1858 | global tl 1859 | global return_page_tl 1860 | time_now = datetime.now(timezone.utc) 1861 | conv = mastodon.conversations(limit=40) 1862 | length = len(conv) 1863 | y=0 1864 | z=1 1865 | favourited = False 1866 | replied = False 1867 | while True: 1868 | if y == length: 1869 | break 1870 | id = conv[y]["last_status"]["id"] #id of message 1871 | connection.send(b'\x13') #clear 1872 | connection.send(b'\x93') #home 1873 | message_num = str(z) 1874 | conv_id = conv[y]["id"] 1875 | unread = conv[y]["unread"] 1876 | if unread == True: 1877 | print("Unread Message") 1878 | send_cr(connection, notification_color) 1879 | send_cr(connection, "revon") 1880 | send_ln(connection, "Unread Message\n") 1881 | send_cr(connection, "revoff") 1882 | mastodon.conversations_read(conv_id) 1883 | 1884 | accounts = conv[y]["last_status"]["account"] #id of message sender 1885 | accounts_id = conv[y]["last_status"] 1886 | account_id = conv[y]["accounts"][0]["id"] #id of people in the message? 1887 | displayname = accounts["display_name"] 1888 | username = "@" + accounts["acct"] 1889 | 1890 | if len(displayname) == 1 or len(displayname) == 0 : 1891 | displayname = timeline["account"]["username"] 1892 | 1893 | print("---------------------------------------------------------\n") 1894 | print(displayname) 1895 | print(username) 1896 | displayname = re.sub(r':.*:','',displayname) 1897 | displayname = deEmojify(connection, displayname) 1898 | displayname = anyascii(str(displayname)) 1899 | created_at = conv[y]["last_status"]["created_at"] 1900 | view_time = time_now - created_at 1901 | last_status= conv[y]["last_status"] 1902 | content = last_status["content"] 1903 | content = parse_content(connection,content) 1904 | send_cr(connection, displayname_color) 1905 | send_ln(connection, displayname) 1906 | time_posted(connection,view_time ) 1907 | send_cr(connection, displayname_color) 1908 | send_ln(connection, "\n" + username) 1909 | send_ln(connection, "\n\n") 1910 | send_cr(connection, text_color) 1911 | do_print(connection, content,is_boosted=False) 1912 | 1913 | if favourited == True: 1914 | cursorxy(connection,1,20) 1915 | send_cr(connection, notification_color) 1916 | send_ln(connection, "You Favourited this Message!") 1917 | favourited = False 1918 | connection.send(b'\x07') 1919 | 1920 | if replied == True: 1921 | cursorxy(connection,1,20) 1922 | send_cr(connection, notification_color) 1923 | send_ln(connection, "You replied to this Message!") 1924 | replied = False 1925 | connection.send(b'\x07') 1926 | 1927 | cursorxy(connection,1,21) 1928 | send_cr(connection, notification_color) 1929 | send_ln(connection, "Message ") 1930 | connection.send(b'\x05') #white 1931 | send_ln(connection, message_num) 1932 | send_ln(connection,"\n") 1933 | send_cr(connection, secondary_menu_color) 1934 | send_ln(connection, "(") 1935 | connection.send(b'\x05') #white 1936 | send_ln(connection, "r") 1937 | send_cr(connection, secondary_menu_color) 1938 | send_ln(connection, ")eply to message fa(") 1939 | connection.send(b'\x05') #white 1940 | send_ln(connection, "v") 1941 | send_cr(connection, secondary_menu_color) 1942 | send_ln(connection, ")ourite message\n") 1943 | send_ln(connection, "(") 1944 | connection.send(b'\x05') #white 1945 | send_ln(connection, "s") 1946 | send_cr(connection, secondary_menu_color) 1947 | send_ln(connection, ")how previous replies (") 1948 | connection.send(b'\x05') #white 1949 | send_ln(connection, "i") 1950 | send_cr(connection, secondary_menu_color) 1951 | send_ln(connection, ")nteract\n") 1952 | send_ln(connection, "(") 1953 | connection.send(b'\x05') #white 1954 | send_ln(connection, "x") 1955 | send_cr(connection, secondary_menu_color) 1956 | send_ln(connection, ") to exit back to Timeline\n") 1957 | send_ln(connection, " Press ") 1958 | connection.send(b'\x05') #white 1959 | send_ln(connection, "Space ") 1960 | send_cr(connection, secondary_menu_color) 1961 | send_ln(connection, "for next Message") 1962 | send_cr(connection, "black") 1963 | 1964 | choice = get_char(connection) 1965 | if choice == "i": 1966 | if other_page == False: 1967 | return_page_tl = tl 1968 | 1969 | timeline = mastodon.account_statuses(account_id,exclude_reblogs=True,limit=1,max_id=datetime.now(timezone.utc)) 1970 | user_page(connection,timeline[0]) 1971 | if other_page == True: 1972 | return 1973 | else: 1974 | y-=1 1975 | z-=1 1976 | 1977 | if choice == "x": 1978 | return 1979 | 1980 | if choice == "v": 1981 | try: 1982 | mastodon.status_favourite(id) 1983 | y-=1 1984 | z-=1 1985 | favourited = True 1986 | except: 1987 | y-=1 1988 | z-=1 1989 | 1990 | if choice == "r": 1991 | connection.send(b'\x13') #clear 1992 | connection.send(b'\x93') #home 1993 | send_cr(connection, "white") 1994 | send_ln(connection, "Usernames are automatically added to\n") 1995 | send_ln(connection, "reply..\n\n") 1996 | send_ln(connection, "Enter Reply\n\n") 1997 | send_cr(connection, text_color) 1998 | reply = input_line(connection) 1999 | try: 2000 | mastodon.status_reply(to_status=accounts_id, status=reply, in_reply_to_id=conv_id) #replies are direct by default 2001 | replied = True 2002 | except: 2003 | pass 2004 | y-=1 2005 | z-=1 2006 | #replied = True 2007 | if choice == "s": 2008 | replies = mastodon.status_context(accounts_id) 2009 | past = replies["ancestors"] 2010 | lengthl = len(past) 2011 | l = 0 2012 | for l in range(lengthl): 2013 | time_now = datetime.now(timezone.utc) 2014 | send_cr(connection, displayname_color) 2015 | accounts = past[l] 2016 | created_at = past[l]["created_at"] 2017 | view_time = time_now - created_at 2018 | displayname = accounts["account"]["display_name"] 2019 | print(displayname) 2020 | content = past[l]["content"] 2021 | content = parse_content(connection, content) 2022 | connection.send(b'\x13') #clear 2023 | connection.send(b'\x93') #home 2024 | send_cr(connection, displayname_color) 2025 | send_ln(connection, displayname) 2026 | time_posted(connection,view_time) 2027 | send_ln(connection, "\n\n") 2028 | send_cr(connection, text_color) 2029 | do_print(connection, content,is_boosted = False) 2030 | send_cr(connection, main_menu_color) 2031 | cursorxy(connection,1,23) 2032 | send_ln(connection, " Press ") 2033 | send_cr(connection, "white") 2034 | send_ln(connection, "space ") 2035 | send_cr(connection, main_menu_color) 2036 | send_ln(connection, "for next reply\n") 2037 | send_ln(connection, " Press (") 2038 | send_cr(connection, "white") 2039 | send_ln(connection, "x") 2040 | send_cr(connection, main_menu_color) 2041 | send_ln(connection, ") to return to Message.") 2042 | send_cr(connection, "black") 2043 | choice = get_char(connection) 2044 | if choice == "x": 2045 | break 2046 | else: 2047 | l+=1 2048 | 2049 | connection.send(b'\x13') #clear 2050 | connection.send(b'\x93') #home 2051 | send_cr(connection, "white") 2052 | send_ln(connection, " End of replies.\n") 2053 | send_ln(connection, "Press any key to return to message.") 2054 | send_cr(connection, "black") 2055 | get_char(connection) 2056 | 2057 | y-=1 2058 | z-=1 2059 | 2060 | 2061 | y+=1 2062 | z+=1 2063 | print("\n\n") 2064 | 2065 | connection.send(b'\x13') #clear 2066 | connection.send(b'\x93') #home 2067 | send_cr(connection, "white") 2068 | send_ln(connection, " End of retrieved Messages.\n") 2069 | send_ln(connection, " Press any key to return to timeline.") 2070 | send_cr(connection, "black") 2071 | get_char(connection) 2072 | return 2073 | 2074 | 2075 | 2076 | def user_page(connection,timeline): #currently uses a users post, reply, etc to get Account ID and other info. Should pass in the Account ID instead of Post in case the user has never posted to their timeline. 2077 | global tl 2078 | global other_page 2079 | global account_id 2080 | global displayname_color 2081 | global text_color 2082 | global secondary_menu_color 2083 | global notification_color 2084 | global other_x 2085 | other_x = 0 2086 | account_id_temp = timeline["account"]["id"] 2087 | print("account id " + str(account_id_temp)) 2088 | following_check = mastodon.account_relationships(account_id_temp) 2089 | following_user = following_check[0]["following"] 2090 | followed_by = following_check[0]["followed_by"] 2091 | displayname = timeline["account"]["display_name"] 2092 | displayname = re.sub(r':.*:','',displayname) 2093 | displayname = deEmojify(connection ,displayname) 2094 | displayname = anyascii(str(displayname)) 2095 | username = "@" + timeline["account"]["acct"] 2096 | if len(displayname) == 1 or len(displayname) == 0 : 2097 | displayname = timeline["account"]["username"] 2098 | 2099 | note = timeline["account"]["note"] 2100 | note = re.sub(r'
', '\n', note) 2101 | note = re.sub(r'
', '\n', note) 2102 | note = re.sub(r'

', '\n', note) 2103 | note = re.sub(r"£","lll" ,note) 2104 | note = strip_tags(connection, note) 2105 | note = deEmojify(connection, note) 2106 | note = anyascii(str(note)) 2107 | content = note + "\n\n" 2108 | following = timeline["account"]["following_count"] 2109 | followers = timeline["account"]["followers_count"] 2110 | print(displayname) 2111 | print(username) 2112 | connection.send(b'\x13') #home 2113 | connection.send(b'\x93') #clear 2114 | send_cr(connection, displayname_color) 2115 | send_ln(connection, displayname+"\n") 2116 | send_ln(connection, username+"\n\n") 2117 | do_print(connection,note,is_boosted=False) 2118 | send_ln(connection, "\n") 2119 | connection.send(b'\x05') #white 2120 | send_ln(connection, "Press any key") 2121 | send_cr(connection, "black") 2122 | get_char(connection) 2123 | connection.send(b'\x13') #home 2124 | connection.send(b'\x93') #clear 2125 | print() 2126 | fields = timeline["account"]["fields"] 2127 | x=0 2128 | for field in fields: 2129 | name = field["name"] 2130 | print(name) 2131 | send_cr(connection,"white") 2132 | send_ln(connection, name+"\n") 2133 | value = field["value"] 2134 | value = strip_tags(connection,value) 2135 | value = deEmojify(connection,value) 2136 | value = anyascii(str(value)) 2137 | send_cr(connection,text_color) 2138 | do_print(connection,value,is_boosted=False) 2139 | content = content + value 2140 | send_ln(connection, "\n") 2141 | x+=1 2142 | print() 2143 | print("Following- " + str(following) + " Followers- " + str(followers)) 2144 | print() 2145 | send_cr(connection, notification_color) 2146 | send_ln(connection, "Following- ") 2147 | connection.send(b'\x05') #white 2148 | send_ln(connection, str(following)) 2149 | send_cr(connection, notification_color) 2150 | send_ln(connection, " Followers- ") 2151 | connection.send(b'\x05') #white 2152 | send_ln(connection, str(followers)) 2153 | send_ln(connection, "\n\n") 2154 | 2155 | 2156 | if following_user == True and followed_by == False: 2157 | send_ln(connection, "You follow them.") 2158 | print("You follow them.") 2159 | 2160 | if following_user == False and followed_by == True: 2161 | send_ln(connection, "They follow you.") 2162 | print("They follow you.") 2163 | 2164 | if following_user == True and followed_by == True: 2165 | send_ln(connection, "You follow each other.") 2166 | print("You follow each other.") 2167 | 2168 | if following_user == False and followed_by == False: 2169 | send_ln(connection, "You don't follow them.") 2170 | print("You don't follow them.") 2171 | 2172 | cursorxy(connection,1,23) 2173 | send_cr(connection, secondary_menu_color) 2174 | send_ln(connection, " (") 2175 | connection.send(b'\x05') #white 2176 | send_ln(connection, "f") 2177 | send_cr(connection, secondary_menu_color) 2178 | send_ln(connection, ")ollow (") 2179 | connection.send(b'\x05') #white 2180 | send_ln(connection, "u") 2181 | send_cr(connection, secondary_menu_color) 2182 | send_ln(connection, ")nfollow (") 2183 | connection.send(b'\x05') #white 2184 | send_ln(connection, "n") 2185 | send_cr(connection, secondary_menu_color) 2186 | send_ln(connection, ")otify\n") 2187 | send_ln(connection, " (") 2188 | connection.send(b'\x05') #white 2189 | send_ln(connection, "d") 2190 | send_cr(connection, secondary_menu_color) 2191 | send_ln(connection, ")irect message (") 2192 | connection.send(b'\x05') #white 2193 | send_ln(connection, "x") 2194 | send_cr(connection, secondary_menu_color) 2195 | send_ln(connection, ") return\n") 2196 | connection.send(b'\x05') #white 2197 | send_ln(connection, " Space ") 2198 | send_cr(connection, secondary_menu_color) 2199 | send_ln(connection, "to view posts") 2200 | send_cr(connection, "black") 2201 | 2202 | while True: 2203 | print("in the while true") 2204 | choice = get_char(connection) 2205 | if choice == "f": 2206 | try: 2207 | mastodon.account_follow(account_id_temp,reblogs=True,notify=False) 2208 | cursorxy(connection,1,22) 2209 | send_cr(connection, "white") 2210 | send_ln(connection, "You Followed them!") 2211 | send_cr(connection, "black") 2212 | connection.send(b'\x07') 2213 | except: 2214 | pass 2215 | 2216 | if choice == "u": 2217 | try: 2218 | mastodon.account_unfollow(account_id_temp) 2219 | cursorxy(connection,1,22) 2220 | send_cr(connection, "white") 2221 | send_ln(connection, "You Unfollowed them!") 2222 | send_cr(connection, "black") 2223 | connection.send(b'\x07') 2224 | except: 2225 | pass 2226 | 2227 | if choice == "n": 2228 | try: 2229 | mastodon.account_follow(account_id_temp,reblogs=True,notify=True) 2230 | cursorxy(connection,1,22) 2231 | send_cr(connection, "white") 2232 | send_ln(connection, "You will recieve notifications.") 2233 | send_cr(connection, "black") 2234 | connection.send(b'\x07') 2235 | except: 2236 | pass 2237 | 2238 | if choice == "d": 2239 | connection.send(b'\x13') #home 2240 | connection.send(b'\x93') #clear 2241 | connection.send(b'\x05') #white 2242 | send_ln(connection,"Username automatically added\n") 2243 | send_ln(connection,"Enter Direct Message..\n\n") 2244 | send_cr(connection, text_color) 2245 | message = input_line(connection) 2246 | message= username+ " " + message 2247 | try: 2248 | mastodon.status_post(message,visibility="direct") 2249 | except: 2250 | pass 2251 | connection.send(b'\x13') #home 2252 | connection.send(b'\x93') #clear 2253 | cursorxy(connection,1,22) 2254 | send_cr(connection, "white") 2255 | send_ln(connection, "You messaged them!\n") 2256 | connection.send(b'\x07') 2257 | send_cr(connection, secondary_menu_color) 2258 | send_ln(connection, " (") 2259 | connection.send(b'\x05') #white 2260 | send_ln(connection, "f") 2261 | send_cr(connection, secondary_menu_color) 2262 | send_ln(connection, ")ollow (") 2263 | connection.send(b'\x05') #white 2264 | send_ln(connection, "u") 2265 | send_cr(connection, secondary_menu_color) 2266 | send_ln(connection, ")nfollow (") 2267 | connection.send(b'\x05') #white 2268 | send_ln(connection, "n") 2269 | send_cr(connection, secondary_menu_color) 2270 | send_ln(connection, ")otify\n") 2271 | send_ln(connection, " (") 2272 | connection.send(b'\x05') #white 2273 | send_ln(connection, "d") 2274 | send_cr(connection, secondary_menu_color) 2275 | send_ln(connection, ")irect message (") 2276 | connection.send(b'\x05') #white 2277 | send_ln(connection, "x") 2278 | send_cr(connection, secondary_menu_color) 2279 | send_ln(connection, ") return\n") 2280 | connection.send(b'\x05') #white 2281 | send_ln(connection, " Space ") 2282 | send_cr(connection, secondary_menu_color) 2283 | send_ln(connection, "to view posts") 2284 | send_cr(connection, "black") 2285 | 2286 | if choice == "x": 2287 | if other_page == True: 2288 | return 2289 | else: 2290 | other_tl = "" #resets other tl 2291 | return 2292 | if choice == " ": 2293 | tl = "o" 2294 | account_id = account_id_temp #only sets account_id if you view the users posts. 2295 | other_page = True 2296 | return 2297 | 2298 | 2299 | 2300 | def timeline(connection): 2301 | global tl 2302 | global account_id 2303 | global displayname_color 2304 | global text_color 2305 | global main_menu_color 2306 | global secondary_menu_color 2307 | global home_tl 2308 | global local_tl 2309 | global federated_tl 2310 | global user_tl 2311 | global other_tl 2312 | global other_page 2313 | global home_x 2314 | global local_x 2315 | global federated_x 2316 | global user_x 2317 | global other_x 2318 | global previous_home_tl_old 2319 | global previous_home_tl_temp 2320 | global previous_home_x 2321 | global previous_local_tl_old 2322 | global previous_local_tl_temp 2323 | global previous_local_x 2324 | global previous_federated_tl_old 2325 | global previous_federated_tl_temp 2326 | global previous_federated_x 2327 | global previous_user_tl_old 2328 | global previous_user_tl_temp 2329 | global previous_user_x 2330 | global previous_other_tl_old 2331 | global previous_other_tl_temp 2332 | global previous_other_x 2333 | global notify_id 2334 | global pinned 2335 | global return_page_tl 2336 | global notification_loop 2337 | global timeline_h 2338 | global timeline_l 2339 | global timeline_f 2340 | global timeline_y 2341 | 2342 | home_length=0 2343 | local_length=0 2344 | federated_length=0 2345 | user_length=0 2346 | other_length = 0 2347 | time_now = datetime.now(timezone.utc) 2348 | pinned = False 2349 | 2350 | if tl == "h": 2351 | if home_tl == "": #first time loading the timeline 2352 | home_tl = time_now 2353 | timeline_h = mastodon.timeline_home(limit=40, max_id=home_tl) 2354 | x=0 2355 | else: # loads the next page of posts.. timeline is first loaded at the end of the first page below.. 2356 | x=home_x #sets the proper post location 2357 | timeline = timeline_h #pulls timeline from memory rather than pulling from API 2358 | home_length = len(timeline)-1 2359 | 2360 | 2361 | if tl == "l": 2362 | if local_tl == "": 2363 | local_tl = time_now 2364 | timeline_l = mastodon.timeline_local(limit=40, max_id=local_tl) 2365 | x=0 2366 | else: 2367 | x=local_x 2368 | timeline = timeline_l 2369 | local_length = len(timeline)-1 2370 | print() 2371 | 2372 | 2373 | if tl == "f": 2374 | if federated_tl == "": 2375 | federated_tl = time_now 2376 | timeline_f = mastodon.timeline_public(limit=40, max_id=federated_tl) 2377 | x=0 2378 | else: 2379 | x=federated_x 2380 | timeline = timeline_f 2381 | federated_length = len(timeline)-1 2382 | print() 2383 | 2384 | 2385 | if tl == "y": 2386 | if user_tl == "": 2387 | user_tl = datetime.now(timezone.utc)#"" #first time loading homepage. 2388 | x=user_x 2389 | timeline_y = mastodon.account_statuses(user_id, pinned=True) 2390 | if len(timeline_y) == 0: 2391 | user_tl = datetime.now(timezone.utc) 2392 | timeline_y = mastodon.account_statuses(user_id,limit=40, max_id=user_tl) 2393 | else: # if no pinned toots or after showing all pinned toots or loading the next page of posts... 2394 | x=user_x 2395 | timeline = timeline_y 2396 | user_length = len(timeline)-1 2397 | 2398 | 2399 | if tl == "o": 2400 | if other_tl == "": #try loading the pinned toots first. 2401 | other_tl = time_now 2402 | x=other_x 2403 | pinned = True 2404 | timeline = mastodon.account_statuses(account_id,limit=40,pinned=True) 2405 | 2406 | else: #if no pinned toots or after showing the first page of posts. Doesn't save the timeline because it is changes with every use.. 2407 | x=other_x 2408 | pinned = False 2409 | timeline = mastodon.account_statuses(account_id,limit=40, max_id=other_tl) 2410 | other_length = len(timeline)-1 2411 | 2412 | 2413 | ################################################################################################################# 2414 | new_timeline = False 2415 | for i in timeline: #synchronizes the x for each timeline for loop. 2416 | if tl == "h": 2417 | home_x = x 2418 | if tl == "l": 2419 | local_x = x 2420 | if tl == "f": 2421 | federated_x =x 2422 | if tl == "y": 2423 | user_x = x 2424 | if tl == "o": 2425 | other_x = x 2426 | print(x) 2427 | 2428 | connection.send(b'\x13') #home 2429 | connection.send(b'\x93') #clear 2430 | view_time,displayname,username,favourites,replies,boosts,content,boosted,alt_text,media_type = get_content(connection, timeline[x]) 2431 | id = timeline[x]["id"] 2432 | if boosted: 2433 | is_boosted = True 2434 | print(displayname + " BOOSTED") 2435 | send_cr(connection, "revon") 2436 | send_cr(connection, boosted_displayname_color) 2437 | send_ln(connection, displayname + " Boosted") 2438 | send_cr(connection, "revoff") 2439 | time_posted(connection, view_time) 2440 | 2441 | else: 2442 | is_boosted = False 2443 | print(displayname) 2444 | print(username) 2445 | send_cr(connection, displayname_color) 2446 | send_ln(connection, displayname) 2447 | time_posted(connection, view_time) 2448 | send_cr(connection, displayname_color) 2449 | send_ln(connection, "\n") 2450 | send_ln(connection, username) 2451 | send_ln(connection, "\n\n") 2452 | 2453 | try: 2454 | pinned = timeline[x]["pinned"] 2455 | except: 2456 | pass 2457 | if pinned == True: 2458 | send_cr(connection, "white") 2459 | send_ln(connection, "Pinned Toot !\n\n") 2460 | print("pinned Toot !\n") 2461 | 2462 | if media_type: 2463 | content = content + "\n" + media_type + "\n" 2464 | 2465 | if alt_text: 2466 | content = content + alt_text 2467 | 2468 | else: 2469 | alt_text == None 2470 | 2471 | do_print(connection,content,is_boosted) 2472 | interaction = interactions(connection, favourites,replies,boosts) 2473 | 2474 | if boosted: 2475 | boosted_id = boosted["id"] 2476 | boosted_status=mastodon.status(boosted_id) 2477 | boosted_time,boosted_displayname,boosted_username,boosted_favourites,boosted_replies,boosted_boosts,boosted_content,boosted,alt_text,media_type = get_content(connection, boosted_status) 2478 | print(boosted_displayname) 2479 | send_cr(connection, displayname_color) 2480 | send_ln(connection, "\n") 2481 | send_ln(connection, boosted_displayname) 2482 | time_posted(connection, boosted_time) 2483 | send_cr(connection, displayname_color) 2484 | send_ln(connection, "\n") 2485 | send_ln(connection, boosted_username) 2486 | send_cr(connection, text_color) 2487 | send_ln(connection, "\n\n") 2488 | 2489 | if media_type: 2490 | boosted_content = boosted_content + "\n" + media_type + "\n" 2491 | 2492 | if alt_text: 2493 | boosted_content = boosted_content + alt_text 2494 | 2495 | else: 2496 | alt_text = None 2497 | 2498 | do_print(connection,boosted_content,is_boosted) 2499 | interaction = interactions(connection, boosted_favourites,boosted_replies,boosted_boosts) 2500 | print(interaction) 2501 | print("--------------------------------------") 2502 | 2503 | if other_page ==False and username != yourname: #menu for the 3 main timelines. Home, Local, Federated Normal Menu and it's not your post. 2504 | send_cr(connection, "black") 2505 | cursorxy(connection,1,22) 2506 | send_cr(connection, main_menu_color) 2507 | send_ln(connection, "fa(") 2508 | connection.send(b'\x05') #white 2509 | send_ln(connection, "v") 2510 | send_cr(connection, main_menu_color) 2511 | send_ln(connection, ") (") 2512 | connection.send(b'\x05') #white 2513 | send_ln(connection, "b") 2514 | send_cr(connection, main_menu_color) 2515 | send_ln(connection, ")oost (") 2516 | connection.send(b'\x05') #white 2517 | send_ln(connection, "r") 2518 | send_cr(connection, main_menu_color) 2519 | send_ln(connection, ")eply (") 2520 | connection.send(b'\x05') #white 2521 | send_ln(connection, "p") 2522 | send_cr(connection, main_menu_color) 2523 | send_ln(connection, ")rivate reply\n") 2524 | send_ln(connection, "(") 2525 | connection.send(b'\x05') #white 2526 | send_ln(connection, "s") 2527 | send_cr(connection, main_menu_color) 2528 | send_ln(connection, ")how replies (") 2529 | connection.send(b'\x05') #white 2530 | send_ln(connection, "z") 2531 | send_cr(connection, main_menu_color) 2532 | send_ln(connection, ") Reload (") 2533 | connection.send(b'\x05') #white 2534 | send_ln(connection,"i") 2535 | send_cr(connection, main_menu_color) 2536 | send_ln(connection, ")nteract\n") 2537 | send_ln(connection, "(") 2538 | connection.send(b'\x05') #white 2539 | send_ln(connection, "h") 2540 | send_cr(connection, main_menu_color) 2541 | send_ln(connection, ") (") 2542 | connection.send(b'\x05') #white 2543 | send_ln(connection, "l") 2544 | send_cr(connection, main_menu_color) 2545 | send_ln(connection, ") (") 2546 | connection.send(b'\x05') #white 2547 | send_ln(connection, "f") 2548 | send_cr(connection, main_menu_color) 2549 | send_ln(connection, ") (") 2550 | connection.send(b'\x05') #white 2551 | send_ln(connection, "y") 2552 | send_cr(connection, main_menu_color) 2553 | send_ln(connection, ") (") 2554 | connection.send(b'\x05') #white 2555 | send_ln(connection, "t") 2556 | send_cr(connection, main_menu_color) 2557 | send_ln(connection, ")oot (") 2558 | connection.send(b'\x05') #white 2559 | send_ln(connection, "n") 2560 | send_cr(connection, main_menu_color) 2561 | send_ln(connection, ")otif (") 2562 | connection.send(b'\x05') #white 2563 | send_ln(connection, "m") 2564 | send_cr(connection, main_menu_color) 2565 | send_ln(connection, ")ess\n") 2566 | send_ln(connection, " sear(") 2567 | connection.send(b'\x05') #white 2568 | send_ln(connection, "c") 2569 | send_cr(connection, main_menu_color) 2570 | send_ln(connection, ")h ") 2571 | connection.send(b'\x05') #white 2572 | send_ln(connection, "Space ") 2573 | send_cr(connection, main_menu_color) 2574 | send_ln(connection, "next Toot (") 2575 | connection.send(b'\x05') #white 2576 | send_ln(connection, "g") 2577 | send_cr(connection, main_menu_color) 2578 | send_ln(connection, ")o Back") 2579 | send_cr(connection, "black") 2580 | 2581 | if other_page ==False and tl != "y" and username == yourname: #menu for the 3 main timelines. Home, Local, Federated with your post. 2582 | send_cr(connection, "black") 2583 | cursorxy(connection,1,22) 2584 | send_cr(connection, main_menu_color) 2585 | send_ln(connection, "fa(") 2586 | connection.send(b'\x05') #white 2587 | send_ln(connection, "v") 2588 | send_cr(connection, main_menu_color) 2589 | send_ln(connection, ") (") 2590 | connection.send(b'\x05') #white 2591 | send_ln(connection, "b") 2592 | send_cr(connection, main_menu_color) 2593 | send_ln(connection, ")oost (") 2594 | connection.send(b'\x05') #white 2595 | send_ln(connection, "r") 2596 | send_cr(connection, main_menu_color) 2597 | send_ln(connection, ")eply (") 2598 | connection.send(b'\x05') #white 2599 | send_ln(connection, "p") 2600 | send_cr(connection, main_menu_color) 2601 | send_ln(connection, ")in (") 2602 | connection.send(b'\x05') #white 2603 | send_ln(connection, "u") 2604 | send_cr(connection, main_menu_color) 2605 | send_ln(connection, ")npin\n") 2606 | send_ln(connection, "(") 2607 | connection.send(b'\x05') #white 2608 | send_ln(connection, "s") 2609 | send_cr(connection, main_menu_color) 2610 | send_ln(connection, ")how replies (") 2611 | connection.send(b'\x05') #white 2612 | send_ln(connection, "z") 2613 | send_cr(connection, main_menu_color) 2614 | send_ln(connection, ") Reload (") 2615 | connection.send(b'\x05') #white 2616 | send_ln(connection,"i") 2617 | send_cr(connection, main_menu_color) 2618 | send_ln(connection, ")nteract\n") 2619 | send_ln(connection, "(") 2620 | connection.send(b'\x05') #white 2621 | send_ln(connection, "h") 2622 | send_cr(connection, main_menu_color) 2623 | send_ln(connection, ") (") 2624 | connection.send(b'\x05') #white 2625 | send_ln(connection, "l") 2626 | send_cr(connection, main_menu_color) 2627 | send_ln(connection, ") (") 2628 | connection.send(b'\x05') #white 2629 | send_ln(connection, "f") 2630 | send_cr(connection, main_menu_color) 2631 | send_ln(connection, ") (") 2632 | connection.send(b'\x05') #white 2633 | send_ln(connection, "y") 2634 | send_cr(connection, main_menu_color) 2635 | send_ln(connection, ") (") 2636 | connection.send(b'\x05') #white 2637 | send_ln(connection, "t") 2638 | send_cr(connection, main_menu_color) 2639 | send_ln(connection, ")oot (") 2640 | connection.send(b'\x05') #white 2641 | send_ln(connection, "n") 2642 | send_cr(connection, main_menu_color) 2643 | send_ln(connection, ")otif (") 2644 | connection.send(b'\x05') #white 2645 | send_ln(connection, "m") 2646 | send_cr(connection, main_menu_color) 2647 | send_ln(connection, ")ess\n") 2648 | send_ln(connection, " sear(") 2649 | connection.send(b'\x05') #white 2650 | send_ln(connection, "c") 2651 | send_cr(connection, main_menu_color) 2652 | send_ln(connection, ")h ") 2653 | connection.send(b'\x05') #white 2654 | send_ln(connection, "Space ") 2655 | send_cr(connection, main_menu_color) 2656 | send_ln(connection, "next Toot (") 2657 | connection.send(b'\x05') #white 2658 | send_ln(connection, "g") 2659 | send_cr(connection, main_menu_color) 2660 | send_ln(connection, ")o Back") 2661 | send_cr(connection, "black") 2662 | 2663 | if other_page == True and yourname != username: 2664 | send_cr(connection, "black") 2665 | cursorxy(connection,1,22) 2666 | send_cr(connection, secondary_menu_color) 2667 | send_ln(connection, "fa(") 2668 | connection.send(b'\x05') #white 2669 | send_ln(connection, "v") 2670 | send_cr(connection, secondary_menu_color) 2671 | send_ln(connection, ") (") 2672 | connection.send(b'\x05') #white 2673 | send_ln(connection, "b") 2674 | send_cr(connection, secondary_menu_color) 2675 | send_ln(connection, ")oost (") 2676 | connection.send(b'\x05') #white 2677 | send_ln(connection, "r") 2678 | send_cr(connection, secondary_menu_color) 2679 | send_ln(connection, ")eply (") 2680 | connection.send(b'\x05') #white 2681 | send_ln(connection, "p") 2682 | send_cr(connection, secondary_menu_color) 2683 | send_ln(connection, ")rivate (") 2684 | connection.send(b'\x05') #white 2685 | send_ln(connection, "n") 2686 | send_cr(connection, secondary_menu_color) 2687 | send_ln(connection, ")otif\n") 2688 | send_ln(connection, "(") 2689 | connection.send(b'\x05') #white 2690 | send_ln(connection, "s") 2691 | send_cr(connection, secondary_menu_color) 2692 | send_ln(connection, ")how replies (") 2693 | connection.send(b'\x05') #white 2694 | send_ln(connection, "i") 2695 | send_cr(connection, secondary_menu_color) 2696 | send_ln(connection, ")nteract (") 2697 | connection.send(b'\x05') #white 2698 | send_ln(connection, "z") 2699 | send_cr(connection, secondary_menu_color) 2700 | send_ln(connection, ") Reload \n") 2701 | send_cr(connection, secondary_menu_color) 2702 | send_ln(connection, " Press ") 2703 | connection.send(b'\x05') #white 2704 | send_ln(connection, "Space ") 2705 | send_cr(connection, secondary_menu_color) 2706 | send_ln(connection, "for next Toot. (") 2707 | connection.send(b'\x05') #white 2708 | send_ln(connection, "g") 2709 | send_cr(connection, secondary_menu_color) 2710 | send_ln(connection, ")o Back \n") 2711 | send_ln(connection, " (") 2712 | connection.send(b'\x05') #white 2713 | send_ln(connection, "x") 2714 | send_cr(connection, secondary_menu_color) 2715 | send_ln(connection, ") to return to timeline. ") 2716 | send_cr(connection, "black") 2717 | 2718 | if tl == "y" and is_boosted == False and username == yourname: # when viewing your own timeline and your own posts. 2719 | send_cr(connection, "black") 2720 | cursorxy(connection,1,22) 2721 | send_cr(connection, main_menu_color) 2722 | send_ln(connection, " fa(") 2723 | connection.send(b'\x05') #white 2724 | send_ln(connection, "v") 2725 | send_cr(connection, main_menu_color) 2726 | send_ln(connection, ") (") 2727 | connection.send(b'\x05') #white 2728 | send_ln(connection, "b") 2729 | send_cr(connection, main_menu_color) 2730 | send_ln(connection, ")oost (") 2731 | connection.send(b'\x05') #white 2732 | send_ln(connection, "r") 2733 | send_cr(connection, main_menu_color) 2734 | send_ln(connection, ")eply (") 2735 | connection.send(b'\x05') #white 2736 | send_ln(connection, "p") 2737 | send_cr(connection, main_menu_color) 2738 | send_ln(connection, ")in (") 2739 | connection.send(b'\x05') #white 2740 | send_ln(connection, "u") 2741 | send_cr(connection, main_menu_color) 2742 | send_ln(connection, ")npin \n") 2743 | send_ln(connection, " (") 2744 | connection.send(b'\x05') #white 2745 | send_ln(connection, "s") 2746 | send_cr(connection, main_menu_color) 2747 | send_ln(connection, ")how replies (") 2748 | connection.send(b'\x05') #white 2749 | send_ln(connection, "z") 2750 | send_cr(connection, main_menu_color) 2751 | send_ln(connection, ") Reload") 2752 | send_ln(connection, " sear(") 2753 | connection.send(b'\x05') #white 2754 | send_ln(connection, "c") 2755 | send_cr(connection, main_menu_color) 2756 | send_ln(connection, ")h \n") 2757 | send_ln(connection, " (") 2758 | connection.send(b'\x05') #white 2759 | send_ln(connection, "h") 2760 | send_cr(connection, main_menu_color) 2761 | send_ln(connection, ") (") 2762 | connection.send(b'\x05') #white 2763 | send_ln(connection, "l") 2764 | send_cr(connection, main_menu_color) 2765 | send_ln(connection, ") (") 2766 | connection.send(b'\x05') #white 2767 | send_ln(connection, "f") 2768 | send_cr(connection, main_menu_color) 2769 | send_ln(connection, ")") 2770 | send_ln(connection, " (") 2771 | connection.send(b'\x05') #white 2772 | send_ln(connection, "t") 2773 | send_cr(connection, main_menu_color) 2774 | send_ln(connection, ")oot (") 2775 | connection.send(b'\x05') #white 2776 | send_ln(connection, "n") 2777 | send_cr(connection, main_menu_color) 2778 | send_ln(connection, ")otif (") 2779 | connection.send(b'\x05') #white 2780 | send_ln(connection, "m") 2781 | send_cr(connection, main_menu_color) 2782 | send_ln(connection, ")ess\n") 2783 | connection.send(b'\x05') #white 2784 | send_ln(connection, " Space ") 2785 | send_cr(connection, main_menu_color) 2786 | send_ln(connection, "next Toot (") 2787 | connection.send(b'\x05') #white 2788 | send_ln(connection, "g") 2789 | send_cr(connection, main_menu_color) 2790 | send_ln(connection, ")o Back (") 2791 | connection.send(b'\x05') #white 2792 | send_ln(connection, "x") 2793 | send_cr(connection, main_menu_color) 2794 | send_ln(connection, ") Exit") 2795 | send_cr(connection, "black") 2796 | 2797 | if tl == "y" and is_boosted == True: # when viewing your own timeline with a boosted post. 2798 | send_cr(connection, "black") 2799 | cursorxy(connection,1,22) 2800 | send_cr(connection, main_menu_color) 2801 | send_ln(connection, " fa(") 2802 | connection.send(b'\x05') #white 2803 | send_ln(connection, "v") 2804 | send_cr(connection, main_menu_color) 2805 | send_ln(connection, ") (") 2806 | connection.send(b'\x05') #white 2807 | send_ln(connection, "b") 2808 | send_cr(connection, main_menu_color) 2809 | send_ln(connection, ")oost (") 2810 | connection.send(b'\x05') #white 2811 | send_ln(connection, "r") 2812 | send_cr(connection, main_menu_color) 2813 | send_ln(connection, ")eply (") 2814 | connection.send(b'\x05') #white 2815 | send_ln(connection, "p") 2816 | send_cr(connection, main_menu_color) 2817 | send_ln(connection, ")rivate reply") 2818 | send_ln(connection, " (") 2819 | connection.send(b'\x05') #white 2820 | send_ln(connection, "s") 2821 | send_cr(connection, main_menu_color) 2822 | send_ln(connection, ")how replies (") 2823 | connection.send(b'\x05') #white 2824 | send_ln(connection, "z") 2825 | send_cr(connection, main_menu_color) 2826 | send_ln(connection, ") Reload") 2827 | send_ln(connection, " sear(") 2828 | connection.send(b'\x05') #white 2829 | send_ln(connection, "c") 2830 | send_cr(connection, main_menu_color) 2831 | send_ln(connection, ")h \n") 2832 | send_ln(connection, "(") 2833 | connection.send(b'\x05') #white 2834 | send_ln(connection, "h") 2835 | send_cr(connection, main_menu_color) 2836 | send_ln(connection, ") (") 2837 | connection.send(b'\x05') #white 2838 | send_ln(connection, "l") 2839 | send_cr(connection, main_menu_color) 2840 | send_ln(connection, ") (") 2841 | connection.send(b'\x05') #white 2842 | send_ln(connection, "f") 2843 | send_cr(connection, main_menu_color) 2844 | send_ln(connection, ")") 2845 | send_ln(connection, " (") 2846 | connection.send(b'\x05') #white 2847 | send_ln(connection, "t") 2848 | send_cr(connection, main_menu_color) 2849 | send_ln(connection, ")oot (") 2850 | connection.send(b'\x05') #white 2851 | send_ln(connection, "n") 2852 | send_cr(connection, main_menu_color) 2853 | send_ln(connection, ")otif (") 2854 | connection.send(b'\x05') #white 2855 | send_ln(connection, "m") 2856 | send_cr(connection, main_menu_color) 2857 | send_ln(connection, ")ess (") 2858 | connection.send(b'\x05') #white 2859 | send_ln(connection, "i") 2860 | send_cr(connection, main_menu_color) 2861 | send_ln(connection, ")nt\n") 2862 | connection.send(b'\x05') #white 2863 | send_ln(connection, " Space ") 2864 | send_cr(connection, main_menu_color) 2865 | send_ln(connection, "next Toot (") 2866 | connection.send(b'\x05') #white 2867 | send_ln(connection, "g") 2868 | send_cr(connection, main_menu_color) 2869 | send_ln(connection, ")o Back (") 2870 | connection.send(b'\x05') #white 2871 | send_ln(connection, "x") 2872 | send_cr(connection, main_menu_color) 2873 | send_ln(connection, ") Exit") 2874 | send_cr(connection, "black") 2875 | 2876 | 2877 | if notification_loop == 3: #prevents querying the API every screen refresh.Cuts down on rate limiting. You can change to 1 to check for notifications every page reload. 2878 | new_notifications(connection) #checks for new notifications 2879 | notification_loop = 0 2880 | 2881 | while True: #scans the keyboard waiting for input. 2882 | choice = get_char(connection) 2883 | send_cr(connection, "black") 2884 | 2885 | if choice == "z": #Refreshes the current timeline. 2886 | if tl=="h": 2887 | home_tl="" 2888 | home_x = 0 2889 | new_timeline = True 2890 | break 2891 | if tl == "l": 2892 | local_tl="" 2893 | local_x = 0 2894 | new_timeline = True 2895 | break 2896 | if tl == "f": 2897 | federated_tl="" 2898 | federated_x = 0 2899 | new_timeline = True 2900 | break 2901 | if tl== "y": 2902 | user_tl="" 2903 | user_x = 0 2904 | new_timeline = True 2905 | break 2906 | if tl== "o": 2907 | other_tl="" 2908 | other_x = 0 2909 | new_timeline = True 2910 | break 2911 | 2912 | if choice == "c": 2913 | if other_page == True: 2914 | pass 2915 | else: 2916 | search(connection) 2917 | new_timeline = True 2918 | break 2919 | 2920 | if choice == "t": 2921 | toot(connection) 2922 | break 2923 | 2924 | if choice == "m": 2925 | messages(connection) 2926 | if other_page == True: 2927 | new_timeline = True 2928 | break 2929 | else: 2930 | break 2931 | 2932 | if choice == "h": 2933 | if other_page == True: #removes timeline switching from other peoples pages. uses x to return. 2934 | pass 2935 | else: 2936 | tl = "h" 2937 | new_timeline = True 2938 | print() 2939 | break 2940 | 2941 | if choice == "l": 2942 | if other_page == True: 2943 | pass 2944 | else: 2945 | tl = "l" 2946 | new_timeline = True 2947 | print() 2948 | break 2949 | 2950 | if choice == "f": 2951 | if other_page == True: 2952 | pass 2953 | else: 2954 | tl = "f" 2955 | new_timeline = True 2956 | print() 2957 | break 2958 | 2959 | if choice == "y": 2960 | if other_page == True: 2961 | pass 2962 | else: 2963 | return_page_tl = tl 2964 | tl = "y" 2965 | new_timeline = True 2966 | print() 2967 | break 2968 | 2969 | if choice == "i": 2970 | if other_page == True and is_boosted == False: #doesn't set returning timeline when already interacting from an interaction. So it can return to the original location. 2971 | user_page(connection, timeline[x]) 2972 | new_timeline = True 2973 | break 2974 | if other_page == True and is_boosted == True: #doesn't set returning timeline when already interacting from an interaction. So it can return to the original location. 2975 | user_page(connection, boosted_status) 2976 | new_timeline = True 2977 | break 2978 | 2979 | if tl == "y" and is_boosted == True: # interact with people from your homepage but not yourself. 2980 | return_page_tl = tl 2981 | user_page(connection, boosted_status) 2982 | new_timeline = True 2983 | break 2984 | if username == yourname and tl == "y" : #Don't interact with your posts while on your homepage. 2985 | pass 2986 | if username == yourname and tl != "y": # interact with yourself from regular timeline. Skips normal user_page function. 2987 | return_page_tl = tl 2988 | tl = "y" 2989 | 2990 | new_timeline = True 2991 | break 2992 | 2993 | if other_page == False and is_boosted == False and username != yourname: #normal interaction from a main timeline. 2994 | return_page_tl = tl 2995 | user_page(connection, timeline[x]) 2996 | new_timeline = True 2997 | break 2998 | if other_page == False and is_boosted == True and username != yourname: #normal interaction from a main timeline. 2999 | return_page_tl = tl 3000 | user_page(connection, boosted_status) 3001 | new_timeline = True 3002 | break 3003 | 3004 | if choice == "n": 3005 | notifications(connection) 3006 | if other_page == True: 3007 | new_timeline = True 3008 | break 3009 | else: 3010 | break 3011 | 3012 | 3013 | if choice == "v": 3014 | try: 3015 | mastodon.status_favourite(id) 3016 | cursorxy(connection,1,21) 3017 | send_cr(connection, "red") 3018 | send_ln(connection, "You Favourited this Toot ! ") 3019 | send_cr(connection, "black") 3020 | connection.send(b'\x07') 3021 | except: 3022 | pass 3023 | 3024 | if choice == "b": 3025 | try: 3026 | mastodon.status_reblog(id) 3027 | cursorxy(connection,1,21) 3028 | send_cr(connection, "red") 3029 | send_ln(connection, "You Boosted this Toot ! ") 3030 | send_cr(connection, "black") 3031 | connection.send(b'\x07') 3032 | except: 3033 | pass 3034 | 3035 | if choice == "r": 3036 | if is_boosted == True: 3037 | connection.send(b'\x13') #home 3038 | connection.send(b'\x93') #clear 3039 | connection.send(b'\x05') #white 3040 | send_ln(connection, "Usernames are automatically added to\n") 3041 | send_ln(connection, "reply..\nAll users who are tagged in the reply\nwill be added.\n") 3042 | send_ln(connection, "Enter Reply...\n\n") 3043 | send_cr(connection, text_color) 3044 | reply = input_line(connection) 3045 | try: 3046 | mastodon.status_reply(boosted_status,reply,in_reply_to_id=boosted_id) 3047 | except: 3048 | pass 3049 | break 3050 | else: 3051 | connection.send(b'\x13') #home 3052 | connection.send(b'\x93') #clear 3053 | connection.send(b'\x05') #white 3054 | send_ln(connection, "Usernames are automatically added to\n") 3055 | send_ln(connection, "reply..\nAll users who are tagged in the reply\nwill be added.\n") 3056 | send_ln(connection, "Enter Reply...\n\n") 3057 | send_cr(connection, text_color) 3058 | reply = input_line(connection) 3059 | try: 3060 | mastodon.status_reply(timeline[x],reply,in_reply_to_id=id) 3061 | except: 3062 | pass 3063 | break 3064 | 3065 | if choice == "u": 3066 | if is_boosted == False and username == yourname: 3067 | mastodon.status_unpin(id) 3068 | cursorxy(connection,1,21) 3069 | connection.send(b'\x05') #white 3070 | send_ln(connection, "You Unpinned this Toot ! ") 3071 | send_cr(connection, "black") 3072 | connection.send(b'\x07') 3073 | 3074 | if choice == "p": 3075 | if is_boosted == False and username == yourname: 3076 | mastodon.status_pin(id) 3077 | cursorxy(connection,1,21) 3078 | connection.send(b'\x05') #white 3079 | send_ln(connection, "You Pinned this Toot ! ") 3080 | send_cr(connection, "black") 3081 | connection.send(b'\x07') 3082 | 3083 | if is_boosted == True: 3084 | connection.send(b'\x13') #home 3085 | connection.send(b'\x93') #clear 3086 | connection.send(b'\x05') #white 3087 | send_ln(connection, "Usernames are automatically added to\n") 3088 | send_ln(connection, "reply..\nAll users who are tagged in the reply\nwill be added.\n") 3089 | send_ln(connection, "Enter Reply...\n") 3090 | send_cr(connection, text_color) 3091 | reply = input_line(connection) 3092 | try: 3093 | mastodon.status_reply(boosted_status,reply,in_reply_to_id=boosted_id,visibility="direct") 3094 | except: 3095 | pass 3096 | break 3097 | else: 3098 | connection.send(b'\x13') #home 3099 | connection.send(b'\x93') #clear 3100 | connection.send(b'\x05') #white 3101 | send_ln(connection, "Usernames are automatically added to\n") 3102 | send_ln(connection, "reply..\nAll users who are tagged in the reply\nwill be added.\n") 3103 | send_ln(connection, "Enter Reply...\n") 3104 | send_cr(connection, text_color) 3105 | reply = input_line(connection) 3106 | try: 3107 | mastodon.status_reply(timeline[x],reply,in_reply_to_id=id,visibility="direct") 3108 | except: 3109 | pass 3110 | break 3111 | 3112 | if choice == "s": #show replies.. 3113 | 3114 | if is_boosted: 3115 | id = boosted_id 3116 | replies = mastodon.status_context(id) 3117 | since = replies["descendants"] 3118 | reply_return = False 3119 | length2 = len(since) 3120 | is_boosted = False 3121 | for s in range(length2): 3122 | reply_id = since[s]["id"] 3123 | to_status_id = mastodon.status(since[s]["id"]) 3124 | view_time,displayname,username,favourites,replies,boosts,content,boosted,alt_text,media_type = get_content(connection,since[s]) 3125 | print(displayname) 3126 | print("\n\n") 3127 | connection.send(b'\x13') #home 3128 | connection.send(b'\x93') #clear 3129 | send_cr(connection, displayname_color) 3130 | send_ln(connection, displayname+"\n") 3131 | send_ln(connection, username) 3132 | time_posted(connection, view_time) 3133 | send_ln(connection, "\n\n") 3134 | send_cr(connection, text_color) 3135 | 3136 | if media_type: 3137 | content = content + "\n" + media_type + "\n" 3138 | do_print(connection,content,is_boosted) 3139 | interaction = interactions(connection, favourites,replies,boosts) 3140 | cursorxy(connection,1,22) 3141 | reply_num = s + 1 3142 | send_cr(connection, "cyan") 3143 | send_ln(connection, "Reply # ") 3144 | connection.send(b'\x05') #white 3145 | send_ln(connection, str(reply_num) + "\n") 3146 | send_cr(connection, secondary_menu_color) 3147 | send_ln(connection, "Fa(") 3148 | connection.send(b'\x05') #white 3149 | send_ln(connection, "v") 3150 | send_cr(connection, secondary_menu_color) 3151 | send_ln(connection, ")ourite (") 3152 | connection.send(b'\x05') #white 3153 | send_ln(connection, "b") 3154 | send_cr(connection, secondary_menu_color) 3155 | send_ln(connection, ")oost (") 3156 | connection.send(b'\x05') #white 3157 | send_ln(connection, "r") 3158 | send_cr(connection, secondary_menu_color) 3159 | send_ln(connection, ")eply \n(") 3160 | connection.send(b'\x05') #white 3161 | send_ln(connection, "p") 3162 | send_cr(connection, secondary_menu_color) 3163 | send_ln(connection, ")rivate reply (") 3164 | connection.send(b'\x05') #white 3165 | send_ln(connection, "i") 3166 | send_cr(connection, secondary_menu_color) 3167 | send_ln(connection, ")nteract with user \n(") 3168 | connection.send(b'\x05') #white 3169 | send_ln(connection, "x") 3170 | send_cr(connection, secondary_menu_color) 3171 | send_ln(connection, ") to exit") 3172 | connection.send(b'\x05') #white 3173 | send_ln(connection, " Space ") 3174 | send_cr(connection, secondary_menu_color) 3175 | send_ln(connection, "for next reply.") 3176 | send_cr(connection, "black") 3177 | 3178 | 3179 | while True: 3180 | choice = get_char(connection) 3181 | if choice == "x": 3182 | reply_return = True 3183 | break 3184 | 3185 | if choice == "v": 3186 | try: 3187 | mastodon.status_favourite(reply_id) 3188 | cursorxy(connection,1,21) 3189 | send_cr(connection, "red") 3190 | send_ln(connection, "You Favourited this Reply !") 3191 | send_cr(connection, "black") 3192 | connection.send(b'\x07') 3193 | except: 3194 | pass 3195 | 3196 | if choice == "b": 3197 | try: 3198 | mastodon.status_reblog(reply_id) 3199 | cursorxy(connection,1,21) 3200 | send_cr(connection, "red") 3201 | send_ln(connection, "You Boosted this Reply ! ") 3202 | send_cr(connection, "black") 3203 | connection.send(b'\x07') 3204 | except: 3205 | pass 3206 | 3207 | if choice == "r": 3208 | connection.send(b'\x13') #home 3209 | connection.send(b'\x93') #clear 3210 | connection.send(b'\x05') #white 3211 | send_ln(connection, "Usernames are automatically added to\n") 3212 | send_ln(connection, "reply..\nAll users who are tagged in the reply\nwill be added.\n\n") 3213 | send_cr(connection, notification_color) 3214 | send_ln(connection, "Enter Reply...\n") 3215 | send_cr(connection, text_color) 3216 | reply = input_line(connection) 3217 | try: 3218 | mastodon.status_reply(to_status= to_status_id , status=reply , in_reply_to_id=reply_id) 3219 | except: 3220 | pass 3221 | send_cr(connection, "black") 3222 | break 3223 | 3224 | if choice == "p": 3225 | connection.send(b'\x13') #home 3226 | connection.send(b'\x93') #clear 3227 | connection.send(b'\x05') #white 3228 | send_ln(connection, "Usernames are automatically added to\n") 3229 | send_ln(connection, "reply..\nAll users who are tagged in the reply\nwill be added.\n") 3230 | send_cr(connection, notification_color) 3231 | send_ln(connection, "Enter Reply...\n") 3232 | send_cr(connection, text_color) 3233 | reply = input_line(connection) 3234 | try: 3235 | mastodon.status_reply(to_status= to_status_id , status=reply , in_reply_to_id=reply_id,visibility = "direct") 3236 | except: 3237 | pass 3238 | send_cr(connection, "black") 3239 | break 3240 | 3241 | if choice == "i": 3242 | if other_page == True: 3243 | user_page(connection, since[s]) 3244 | new_timeline = True 3245 | break 3246 | else: 3247 | 3248 | return_page_tl = tl 3249 | user_page(connection, since[s]) 3250 | new_timeline = True 3251 | reply_return = True 3252 | break 3253 | 3254 | if choice == " ": 3255 | break 3256 | 3257 | if reply_return == True: 3258 | break 3259 | if new_timeline ==True: 3260 | break 3261 | 3262 | connection.send(b'\x13') #home 3263 | connection.send(b'\x93') #clear 3264 | send_cr(connection, "white") 3265 | send_ln(connection, " No more replies...\n") 3266 | send_ln(connection, "Press any key to Return to Toot...") 3267 | send_cr(connection, "black") 3268 | get_char(connection) 3269 | break 3270 | 3271 | if choice == "g": #goes back to previous post. 3272 | if x == 0: #used when reaching the very first post x=0 in a timeline and needs to load the previous timeline and last (x)post number. 3273 | if tl=="h": 3274 | home_tl=previous_home_tl_old 3275 | home_x=previous_home_x 3276 | timeline_h = mastodon.timeline_home(limit=40, max_id=home_tl) 3277 | new_timeline = True 3278 | break 3279 | 3280 | if tl=="l": 3281 | local_tl=previous_local_tl_old 3282 | local_x=previous_local_x 3283 | timeline_l = mastodon.timeline_local(limit=40, max_id=local_tl) 3284 | new_timeline = True 3285 | break 3286 | 3287 | if tl=="f": 3288 | federated_tl=previous_federated_tl_old 3289 | federated_x=previous_federated_x 3290 | timeline_f = mastodon.timeline_public(limit=40, max_id=federated_tl) 3291 | new_timeline = True 3292 | break 3293 | 3294 | if tl=="y": 3295 | user_tl=previous_user_tl_old 3296 | user_x=previous_user_x 3297 | timeline_y = mastodon.account_statuses(user_id,limit=40, max_id=user_tl) #probem here. 3298 | new_timeline = True 3299 | break 3300 | 3301 | if tl=="o": 3302 | other_tl=previous_other_tl_old 3303 | other_x=previous_other_x 3304 | new_timeline = True 3305 | 3306 | break 3307 | else: 3308 | x-=1 3309 | break 3310 | 3311 | if choice == "x":# and other_page == True: #only used on others timelines in order to return to a main timeline. 3312 | if other_page == True: 3313 | other_tl="" #resets the timeline. 3314 | tl = return_page_tl #loads the timeline it was on before jumping to others timeline. 3315 | other_page = False 3316 | new_timeline = True 3317 | break 3318 | 3319 | if tl == "y": 3320 | tl = return_page_tl #loads the timeline it was on before jumping to others timeline. 3321 | x=0 3322 | new_timeline = True 3323 | break 3324 | 3325 | 3326 | if choice == " ": # when pressing space on a timeline. 3327 | 3328 | if tl == "h" and home_x == 0: #used to hold the current timeline when loading a new page. 3329 | previous_home_tl_temp = home_tl 3330 | 3331 | if tl == "l" and local_x == 0: 3332 | previous_local_tl_temp = local_tl 3333 | 3334 | if tl == "f" and federated_x == 0: 3335 | previous_federated_tl_temp = federated_tl 3336 | 3337 | if tl == "y" and user_x == 0: 3338 | if user_tl == "": 3339 | previous_user_tl_temp = "" 3340 | else: 3341 | previous_user_tl_temp = user_tl 3342 | 3343 | if tl == "o" and other_x == 0: 3344 | if other_tl == "": 3345 | previous_other_tl_temp = "" 3346 | else: 3347 | previous_other_tl_temp = other_tl 3348 | 3349 | 3350 | if tl == "h" and home_length == x: #used to lock in the previous timeline when reaching the end of a timeline page. i.e. after viewing 40 comments and loading new ones. 3351 | home_tl=timeline[x]["id"] 3352 | previous_home_tl_old = previous_home_tl_temp #locks in the previous temp page so it knows what to load if going back a previous timeline. 3353 | previous_home_x = home_x 3354 | home_x = 0 3355 | 3356 | timeline_h = mastodon.timeline_home(limit=40, max_id=home_tl) #only pulls a new timeline from the API only after the end of the timeline is finished. Prevents querrying the API everytime you switch between timelines. 3357 | new_timeline=True 3358 | break 3359 | 3360 | if tl == "l" and local_length == x: 3361 | local_tl=timeline[x]["id"] 3362 | previous_local_tl_old = previous_local_tl_temp 3363 | previous_local_x = local_x 3364 | local_x = 0 3365 | timeline_l = mastodon.timeline_local(limit=40, max_id=local_tl) 3366 | new_timeline=True 3367 | break 3368 | 3369 | if tl == "f" and federated_length == x: 3370 | federated_tl=timeline[x]["id"] 3371 | previous_federated_tl_old = previous_federated_tl_temp 3372 | previous_federated_x = federated_x 3373 | federated_x = 0 3374 | timeline_f = mastodon.timeline_public(limit=40, max_id=federated_tl) 3375 | new_timeline=True 3376 | break 3377 | 3378 | 3379 | if tl == "y" and user_length == x: 3380 | if pinned == True: 3381 | previous_user_x = user_x 3382 | user_x = 0 3383 | user_tl = datetime.now(timezone.utc) 3384 | pinned = False 3385 | timeline_y = mastodon.account_statuses(user_id,limit=40, max_id=user_tl) 3386 | previous_user_tl_old = "" 3387 | new_timeline=True 3388 | break 3389 | else: 3390 | previous_user_x = user_x 3391 | user_tl=timeline[x]["id"] 3392 | user_x = 0 3393 | timeline_y = mastodon.account_statuses(user_id,limit=40, max_id=user_tl) 3394 | previous_user_tl_old = previous_user_tl_temp 3395 | new_timeline=True 3396 | break 3397 | 3398 | if tl == "o" and other_length == x: 3399 | if pinned == True: 3400 | previous_other_x = other_x 3401 | other_x = 0 3402 | other_tl = datetime.now(timezone.utc) 3403 | pinned = False 3404 | previous_other_tl_old = "" 3405 | new_timeline=True 3406 | break 3407 | else: 3408 | previous_other_x = other_x 3409 | other_tl=timeline[x]["id"] 3410 | other_x = 0 3411 | previous_other_tl_old = previous_other_tl_temp 3412 | new_timeline=True 3413 | break 3414 | 3415 | else: 3416 | x+=1 #advances the next timeline post. 3417 | notification_loop+=1 3418 | break 3419 | 3420 | if new_timeline == True: #loads the new timeline you selected above. 3421 | break 3422 | print() 3423 | 3424 | 3425 | def run_once(connection): 3426 | global tl 3427 | global other_tl 3428 | global text_color 3429 | send_cr(connection,"clear") 3430 | send_cr(connection,"home") 3431 | send_cr(connection, text_color) 3432 | connection.send(b'\x05') #white 3433 | send_ln(connection, " MOS") 3434 | send_cr(connection, "blue") 3435 | send_ln(connection, "todon\n\n") 3436 | send_cr(connection, text_color) 3437 | send_ln(connection, "Press ") 3438 | send_cr(connection, text_color) 3439 | send_ln(connection, "(") 3440 | connection.send(b'\x05') #white 3441 | send_ln(connection, "t") 3442 | send_cr(connection, text_color) 3443 | send_ln(connection, ") to post a Toot or send a\n") 3444 | send_ln(connection, "Direct Message.\n\n") 3445 | send_ln(connection, "Switch between timelines at anytime.\n") 3446 | send_ln(connection, "(") 3447 | connection.send(b'\x05') #white 3448 | send_ln(connection, "h") 3449 | send_cr(connection, text_color) 3450 | send_ln(connection, ") for Home (") 3451 | connection.send(b'\x05') #white 3452 | send_ln(connection, "l") 3453 | send_cr(connection, text_color) 3454 | send_ln(connection, ") for Local\n") 3455 | send_ln(connection, "(") 3456 | connection.send(b'\x05') #white 3457 | send_ln(connection, "f") 3458 | send_cr(connection, text_color) 3459 | send_ln(connection, ") for Federated (") 3460 | connection.send(b'\x05') #white 3461 | send_ln(connection, "y") 3462 | send_cr(connection, text_color) 3463 | send_ln(connection, ") for Your page.\n\n") 3464 | connection.send(b'\x05') #white 3465 | send_cr(connection, text_color) 3466 | send_ln(connection, "Fa(") 3467 | connection.send(b'\x05') #white 3468 | send_ln(connection, "v") 3469 | send_cr(connection, text_color) 3470 | send_ln(connection, ")ourite, (") 3471 | connection.send(b'\x05') #white 3472 | send_ln(connection, "b") 3473 | send_cr(connection, text_color) 3474 | send_ln(connection, ")oost, or (") 3475 | connection.send(b'\x05') #white 3476 | send_ln(connection, "r") 3477 | send_cr(connection, text_color) 3478 | send_ln(connection, ")eply.\n") 3479 | send_ln(connection, "You can also send (") 3480 | connection.send(b'\x05') #white 3481 | send_ln(connection, "p") 3482 | send_cr(connection, text_color) 3483 | send_ln(connection, ")rivate replies.\n(") 3484 | connection.send(b'\x05') #white 3485 | send_ln(connection, "s") 3486 | send_cr(connection, text_color) 3487 | send_ln(connection, ")how and interact with replies.\n\n") 3488 | send_ln(connection, "(") 3489 | connection.send(b'\x05') #white 3490 | send_ln(connection, "g") 3491 | send_cr(connection, text_color) 3492 | send_ln(connection, ")o back to the previous toot.\n") 3493 | send_ln(connection, "(") 3494 | connection.send(b'\x05') #white 3495 | send_ln(connection, "i") 3496 | send_cr(connection, text_color) 3497 | send_ln(connection, ")nteracts with the users homepage.\n(") 3498 | connection.send(b'\x05') #white 3499 | send_ln(connection, "z") 3500 | send_cr(connection, text_color) 3501 | send_ln(connection, ") reloads the timeline with\nthe newest toots.\n\n") 3502 | send_ln(connection, "Sear(") 3503 | connection.send(b'\x05') #white 3504 | send_ln(connection, "c") 3505 | send_cr(connection, text_color) 3506 | send_ln(connection, ")h for other users.\n") 3507 | send_ln(connection, "(") 3508 | connection.send(b'\x05') #white 3509 | send_ln(connection, "n") 3510 | send_cr(connection, text_color) 3511 | send_ln(connection, ") will load notifications. This will\nalso clear the notification alert.\n") 3512 | send_ln(connection, "(") 3513 | connection.send(b'\x05') #white 3514 | send_ln(connection, "m") 3515 | send_cr(connection, text_color) 3516 | send_ln(connection, ") to read your Messages.\n\n") 3517 | connection.send(b'\x05') #white 3518 | send_ln(connection, "Select Choice.") 3519 | send_cr(connection, text_color) 3520 | send_cr(connection, text_color) 3521 | send_ln(connection, "(") 3522 | connection.send(b'\x05') #white 3523 | send_ln(connection, "h") 3524 | send_cr(connection, text_color) 3525 | send_ln(connection, ")(") 3526 | connection.send(b'\x05') #white 3527 | send_ln(connection, "l") 3528 | send_cr(connection, text_color) 3529 | send_ln(connection, ")(") 3530 | connection.send(b'\x05') #white 3531 | send_ln(connection, "f") 3532 | send_cr(connection, text_color) 3533 | send_ln(connection, ")(") 3534 | connection.send(b'\x05') #white 3535 | send_ln(connection, "y") 3536 | send_cr(connection, text_color) 3537 | send_ln(connection, ")(") 3538 | connection.send(b'\x05') #white 3539 | send_ln(connection, "t") 3540 | send_cr(connection, text_color) 3541 | send_ln(connection, ")(") 3542 | connection.send(b'\x05') #white 3543 | send_ln(connection, "c") 3544 | send_cr(connection, text_color) 3545 | send_ln(connection, ")(") 3546 | connection.send(b'\x05') #white 3547 | send_ln(connection, "n") 3548 | send_cr(connection, text_color) 3549 | send_ln(connection, ")(") 3550 | connection.send(b'\x05') #white 3551 | send_ln(connection, "m") 3552 | send_cr(connection, text_color) 3553 | send_ln(connection, ")\n") 3554 | send_ln(connection, "or press") 3555 | connection.send(b'\x05') #white 3556 | send_ln(connection, " Space ") 3557 | send_cr(connection, text_color) 3558 | send_ln(connection, "for Home Timeline.") 3559 | send_cr(connection, "black") 3560 | choice = get_char(connection) 3561 | send_ln(connection, "\n") 3562 | print("choice selected " + choice) 3563 | 3564 | 3565 | if choice == "t": 3566 | toot(connection) 3567 | 3568 | if choice == "h": 3569 | tl = "h" 3570 | 3571 | if choice == "l": 3572 | tl = "l" 3573 | 3574 | if choice == "f": 3575 | tl = "f" 3576 | 3577 | if choice == "y": 3578 | tl = "y" 3579 | 3580 | if choice == "n": 3581 | notifications(connection) 3582 | 3583 | if choice == "m": 3584 | messages(connection) 3585 | 3586 | if choice == "c": 3587 | search(connection) 3588 | 3589 | def user_session(connection): 3590 | send_cr(connection,"clear") 3591 | send_cr(connection,"home") 3592 | send_cr(connection, "blue") 3593 | send_ln(connection, "Connected. Hit Return key...") 3594 | bucl=input_line(connection) 3595 | send_cr(connection,"clear") 3596 | send_cr(connection,"home") 3597 | send_seq(connection, "seq/MOStodon.seq") 3598 | 3599 | 3600 | 3601 | 3602 | def threaded_client(connection): 3603 | global UsersCount 3604 | try: 3605 | connection.settimeout(1200) # 20 mins of inactivity will disconnect.. 3606 | user_session(connection) 3607 | run_once(connection) 3608 | while True: 3609 | timeline(connection) 3610 | 3611 | except Exception: 3612 | connection.send(b'\x13') #home 3613 | connection.send(b'\x93') #clear 3614 | send_cr(connection, "white") 3615 | send_ln(connection, "Disconnected from MOStodon..\n\n") 3616 | connection.close() 3617 | print('Timeout occurred. Closed connection',connection) 3618 | UsersCount -= 1 3619 | print("\nConnected users ", UsersCount) 3620 | 3621 | 3622 | 3623 | def threaded_clientTesting(connection): 3624 | global UsersCount 3625 | ############################### removed the try and except for testing!!!!!!!!!!!!!!!!!! Use to display the error messages... 3626 | connection.settimeout(1200) # 20 minutes of inactivity will end session. 3627 | user_session(connection) 3628 | run_once(connection) 3629 | while True: 3630 | timeline(connection) 3631 | 3632 | 3633 | try: 3634 | MOStodon.bind((host, port)) 3635 | MOStodon.setsockopt(socket.IPPROTO_TCP,socket.TCP_NODELAY,False) 3636 | 3637 | except socket.error as e: 3638 | print("Connection error detected ->", str(e)) 3639 | 3640 | print('SERVER > Waiting for a Connection..\r') 3641 | 3642 | MOStodon.listen() 3643 | 3644 | while True: 3645 | Client, address = MOStodon.accept() 3646 | print('New connection from: ' + address[0] + ':' + str(address[1])) 3647 | start_new_thread(threaded_client, (Client, )) 3648 | UsersCount += 1 3649 | print('Connected Users: ' + str(UsersCount)) 3650 | 3651 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MOStodon 2 | https://oldbytes.space/@Havoc 3 | 4 | ![image](https://github.com/Havoc6502/MOStodon/assets/140346993/fb95578a-86e7-42ae-911c-7d1dcc4ff2bc) 5 | 6 | A Commodore 64 Mastodon Client. A modern C64 compatible Modem is required. 7 | 8 | ![image](https://github.com/Havoc6502/MOStodon/assets/140346993/8d7667ef-3318-4465-b748-16ab38294f89) 9 | 10 | ![image](https://github.com/Havoc6502/MOStodon/assets/140346993/d2800796-d172-4e12-8fc7-b78a2046c10e) 11 | 12 | Setup a local Python proxy server. 13 | 14 | You can use a Raspberry Pi or any computer with the latest Python 3 installed. 15 | 16 | Python 3.7 or newer is required! 17 | 18 | Install- 19 | 20 | pip install -r requirements.txt 21 | 22 | 23 | or install manually.- 24 | 25 | pip install Mastodon.py 26 | 27 | pip install anyascii 28 | 29 | 30 | Create your Mastodon app on your Mastodon Instance.- 31 | 32 | Log into your Mastodon instance and navigate to your settings. Under the Development tab click New Application. 33 | Add the application name MOStodon. Default application settings should already be Read,Write,Crypto. 34 | 35 | Click on the newly created app. Copy "Your access token" secret. 36 | Paste the token between the quotes in MOStodon.py after access_token = "" 37 | Add the name of your Mastodon instance between the quotes in api_base_url = "" 38 | e.g. api_base_url = "https://oldbytes.space" 39 | 40 | Running the MOStodon.py Server.- 41 | 42 | Simply type python MOStodon.py 43 | 44 | Connecting to the Server.- 45 | 46 | You will need a modern compatible Commodore 64 Modem. Any of the C64 WiFi modems, a 1541 Ultimate, or equivilent Modem will work. 47 | You can even use Vice with TCPser. 48 | The higher the Baud rate the better! 49 | 50 | Once the Server is running you can log into the Server with any Commodore Modem software that works with your Modem. CCGMS, etc.. 51 | Because local IP addresses can change I prefer to connect by using AT commands instead of saving the Server IP. 52 | With CCGMS you can type atdt192.168.1.100:6502 to connect. Use the IP of your Local Machine running MOStodon.py 53 | 54 | Changing the look of MOStodon.- 55 | 56 | You can change the colors of almost every aspect of MOStodon. Simply edit the MOStodon.py color variables with the list of included colors. 57 | Other hard coded colors can be changed by finding them in the code and replacing the "color". 58 | -------------------------------------------------------------------------------- /funct.py: -------------------------------------------------------------------------------- 1 | #Dictionary converts ascii into petscii bytes 2 | petscii={'A':b'\xc1','B':b'\xc2','C':b'\xc3','D':b'\xc4','E':b'\xc5','F':b'\xc6','G':b'\xc7','H':b'\xc8', 3 | 'I':b'\xc9','J':b'\xca','K':b'\xcb','L':b'\xcc','M':b'\xcd','N':b'\xce','O':b'\xcf','P':b'\xd0', 4 | 'Q':b'\xd1','R':b'\xd2','S':b'\xd3','T':b'\xd4','U':b'\xd5','V':b'\xd6','W':b'\xd7','X':b'\xd8','Y':b'\xd9', 5 | 'Z':b'\xda','a':b'A','b':b'B','c':b'C','d':b'D','e':b'E','f':b'F','g':b'G','h':b'H','i':b'I','j':b'J', 6 | 'k':b'K','l':b'L','m':b'M','n':b'N','o':b'O','p':b'P','q':b'Q','r':b'R','s':b'S','t':b'T','u':b'U', 7 | 'w':b'W','x':b'X','y':b'Y','z':b'Z','v':b'V','0':b'0','1':b'1','2':b'2','3':b'3','4':b'4','5':b'5', 8 | '6':b'6','7':b'7','8':b'8','9':b'9','!':b'!','"':b'"','$':b'$','%':b'%','&':b'&','/':b'/','(':b'(', 9 | ')':b')', '*':b'*', '-':b'-','+':b'+','<':b'<','>':b'>',' ':b' ',':':b':','\n':b'\r\n','.':b'.', 10 | ',':b',','?':b'?','@':b'@','┌':b'\xb0','┐':b'\xae','└':b'\xad','┘':b'\xbd','─':b'\xc0', 11 | '├':b'\xab','┤':b'\xb3','#':b'#', '£':b'\x5c','~':b'\xa3', '^':b'\xae','_':b'\xa4', '|':b'\x7d', 12 | '{':b'\xb3', '}':b'\xab', '\\':b'\xa5', 13 | '\x1c':b'\x1c','\x1e':b'\x1e','\x1f':b'\x1f','\x9c':b'\x9c', 14 | '\x98':b'\x98','\x1d':b'\x1d','\x11':b'\x11','\x91':b'\x91','\x9d':b'\x9d','\x93':b'\x93', 15 | '\x12':b'\x12','\x92':b'\x92','\x81':b'\x81','\x90':b'\x90','\x95':b'\x95','\x96':b'\x96', 16 | '\x97':b'\x97','\x98':b'\x98','\x99':b'\x99','\x9a':b'\x9a','\x9b':b'\x9b','\x9e':b'\x9e', 17 | '\x9f':b'\x9f','\x13':b'\x13', 18 | "'":b"\x27","=":b"\x3d","[":b"[","]":b"]",";":b";" 19 | } 20 | 21 | 22 | #This function moves the cursor and changes color, clear screen 23 | def cbmcursor(tx): 24 | out = b'' 25 | if tx=="right" : out =b'\x1d' 26 | if tx=="home" : out =b'\x13' 27 | if tx=="down" : out =b'\x11' 28 | if tx=="up": out =b'\x91' 29 | if tx=="left": out=b'\x9d' 30 | if tx=="clear" : out =b'\x93' 31 | if tx=="white" : out =b'\x05' 32 | if tx=="red": out = b'\x1c' 33 | if tx=="green": out =b'\x1e' 34 | if tx=="blue": out =b'\x1f' 35 | if tx=="orange": out =b'\x81' 36 | if tx=="black": out =b'\x90' 37 | if tx=="brown": out =b'\x95' 38 | if tx=="pink": out =b'\x96' 39 | if tx=="dark grey": out=b'\x97' 40 | if tx=="dark gray": out=b'\x97' 41 | if tx=="gray": out=b'\x98' 42 | if tx=="grey": out=b'\x98' 43 | if tx=="lightgreen": out=b'\x99' 44 | if tx=="lightblue": out=b'\x9a' 45 | if tx=="lightgrey": out=b'\x9b' 46 | if tx=="purple": out=b'\x9c' 47 | if tx=="yellow": out=b'\x9e' 48 | if tx=="cyan": out=b'\x9f' 49 | if tx=="revon": out=b'\x12' 50 | if tx=="revoff": out=b'\x92' 51 | if tx=="randc": 52 | m=random.randint(0, 15) 53 | if m==0: out =b'\x1f' 54 | if m==1: out =b'\x81' 55 | if m==2: out =b'\x90' 56 | if m==3: out =b'\x95' 57 | if m==4: out =b'\x96' 58 | if m==5: out=b'\x97' 59 | if m==6: out=b'\x98' 60 | if m==7: out=b'\x99' 61 | if m==8: out=b'\x9a' 62 | if m==9: out=b'\x9b' 63 | if m==10: out=b'\x9c' 64 | if m==11: out=b'\x9e' 65 | if m==12: out=b'\x9f' 66 | if m==13: out =b'\x05' 67 | if m==14: out = b'\x1c' 68 | if m==15: out =b'\x1e' 69 | return out 70 | 71 | #this function moves the cursor to an x,y position 72 | def cursorxy(connection,x,y): 73 | connection.send(cbmcursor("home")) 74 | cy=1 75 | cx=1 76 | for cy in range(1,y): 77 | if (cy",filen) 219 | textMode = b'\x0e' 220 | connection.send(textMode) 221 | with open(filen, "rb") as f: 222 | nb=b'' 223 | byte = f.read(1) 224 | while byte: 225 | nb = byte 226 | connection.send(nb) 227 | #print(nb) 228 | byte = f.read(1) 229 | send_cr(connection, "black") 230 | send_cr(connection, "revoff") 231 | get_char(connection) 232 | 233 | 234 | def send_ln(connection, line): 235 | linet=cbmencode(line) 236 | connection.send(linet) 237 | 238 | def send_cr(connection, charx): 239 | chrxx=cbmcursor(charx) 240 | connection.send(chrxx) 241 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Mastodon.py >= 1.8.1 2 | anyascii >= 0.3.2 3 | -------------------------------------------------------------------------------- /seq/MOStodon.seq: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Havoc6502/MOStodon/c9bcc28f204fa365fd9ef18eac7f2ef498fe4ce6/seq/MOStodon.seq --------------------------------------------------------------------------------