diff --git a/CHANGES.txt b/CHANGES.txt old mode 100755 new mode 100644 diff --git a/Pipfile b/Pipfile index 87311bb..2799bee 100644 --- a/Pipfile +++ b/Pipfile @@ -6,30 +6,21 @@ verify_ssl = true [dev-packages] [packages] -telepot = "*" urllib3 = "*" -flask = "*" python-dotenv = "*" -python-telegram-bot = "*" requests = "*" flup = "*" gunicorn = "*" -pypng = "*" -totalvoice = "*" pytz = "*" dataset = "*" -youtube-dl = "*" PyMySQL = "*" -PyQRCode = "*" Babel = "*" -aiogram = "*" uvloop = {version = "*",sys_platform = "!= 'win32'"} brotlipy = {version = "*",sys_platform = "!= 'win32'"} ujson = "*" cchardet = "*" aiodns = "*" aiohttp = {extras = ["speedups"],version = "*"} -quart = "*" hypercorn = "*" pydantic = "*" validators = "*" @@ -39,19 +30,9 @@ validators = "*" python_version = "3" [scripts] -### Telegram -matebot = 'python app.py aiogram' # Vai usar 'matebot' por padrão -prod = 'python app.py aiogram production' -test = 'python app.py aiogram testing' -dev = 'python app.py aiogram development' -### Discord -discord = 'python app.py discord' # Vai usar 'matebot' por padrão -### Scripts antigos -telepot = 'python app.py telepot' -ptb = 'python app.py flask' -flask_dev = 'flask run' -flask_test = 'gunicorn matebot.ptb_matebot:app' -quart_dev = 'quart run' -quart_test = 'hypercorn matebot.aio_matebot:app' -### O mesmo que 'pipenv run python app.py aiogram matebot' +nasabot = 'python app.py discord' # Vai usar 'nasabot' por padrão +prod = 'python app.py discord production' +test = 'python app.py discord testing' +dev = 'python app.py discord development' +### O mesmo que 'pipenv run python app.py discord nasabot' pure = 'python app.py' diff --git a/Pipfile.lock b/Pipfile.lock index 3af06ed..fa588ea 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "c0e48a6fe7fe7d63de831b7b5fa372e1d5e1a2aa46bc3df3c4ee813475cc06ce" + "sha256": "02a3b45e80eb111961a7b9ec97bb92d62ff58eee7edaf391f6c0e5117544e2b1" }, "pipfile-spec": 6, "requires": { @@ -24,21 +24,6 @@ "index": "pypi", "version": "==2.0.0" }, - "aiofiles": { - "hashes": [ - "sha256:377fdf7815cc611870c59cbd07b68b180841d2a2b79812d8c218be02448c2acb", - "sha256:98e6bcfd1b50f97db4980e182ddd509b7cc35909e903a8fe50d8849e02d815af" - ], - "version": "==0.5.0" - }, - "aiogram": { - "hashes": [ - "sha256:35c6b0998b2a175d718098c26c199a3643c4c33d68f7c97927a5b67239adc490", - "sha256:f37dd5906052af1120862f8ec7d23110e724dacc8c111b0ced9ddcdc9ca3ff3f" - ], - "index": "pypi", - "version": "==2.10.1" - }, "aiohttp": { "extras": [ "speedups" @@ -92,12 +77,6 @@ "index": "pypi", "version": "==2.8.0" }, - "blinker": { - "hashes": [ - "sha256:471aee25f3992bd325afa3772f1063dbdbbca947a041b8b89466dc00d606f8b6" - ], - "version": "==1.4" - }, "brotlipy": { "hashes": [ "sha256:07194f4768eb62a4f4ea76b6d0df6ade185e24ebd85877c351daa0a069f1111a", @@ -225,42 +204,6 @@ ], "version": "==3.0.4" }, - "click": { - "hashes": [ - "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", - "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==7.1.2" - }, - "cryptography": { - "hashes": [ - "sha256:21b47c59fcb1c36f1113f3709d37935368e34815ea1d7073862e92f810dc7499", - "sha256:451cdf60be4dafb6a3b78802006a020e6cd709c22d240f94f7a0696240a17154", - "sha256:4549b137d8cbe3c2eadfa56c0c858b78acbeff956bd461e40000b2164d9167c6", - "sha256:48ee615a779ffa749d7d50c291761dc921d93d7cf203dca2db663b4f193f0e49", - "sha256:559d622aef2a2dff98a892eef321433ba5bc55b2485220a8ca289c1ecc2bd54f", - "sha256:5d52c72449bb02dd45a773a203196e6d4fae34e158769c896012401f33064396", - "sha256:65beb15e7f9c16e15934569d29fb4def74ea1469d8781f6b3507ab896d6d8719", - "sha256:680da076cad81cdf5ffcac50c477b6790be81768d30f9da9e01960c4b18a66db", - "sha256:762bc5a0df03c51ee3f09c621e1cee64e3a079a2b5020de82f1613873d79ee70", - "sha256:89aceb31cd5f9fc2449fe8cf3810797ca52b65f1489002d58fe190bfb265c536", - "sha256:983c0c3de4cb9fcba68fd3f45ed846eb86a2a8b8d8bc5bb18364c4d00b3c61fe", - "sha256:99d4984aabd4c7182050bca76176ce2dbc9fa9748afe583a7865c12954d714ba", - "sha256:9d9fc6a16357965d282dd4ab6531013935425d0dc4950df2e0cf2a1b1ac1017d", - "sha256:a7597ffc67987b37b12e09c029bd1dc43965f75d328076ae85721b84046e9ca7", - "sha256:ab010e461bb6b444eaf7f8c813bb716be2d78ab786103f9608ffd37a4bd7d490", - "sha256:b12e715c10a13ca1bd27fbceed9adc8c5ff640f8e1f7ea76416352de703523c8", - "sha256:b2bded09c578d19e08bd2c5bb8fed7f103e089752c9cf7ca7ca7de522326e921", - "sha256:b372026ebf32fe2523159f27d9f0e9f485092e43b00a5adacf732192a70ba118", - "sha256:cb179acdd4ae1e4a5a160d80b87841b3d0e0be84af46c7bb2cd7ece57a39c4ba", - "sha256:e97a3b627e3cb63c415a16245d6cef2139cca18bb1183d1b9375a1c14e83f3b3", - "sha256:f0e099fc4cc697450c3dd4031791559692dd941a95254cb9aeded66a7aa8b9bc", - "sha256:f99317a0fa2e49917689b8cf977510addcfaaab769b3f899b9c481bbd76730c2" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==3.1.1" - }, "dataset": { "hashes": [ "sha256:41e55410f853815753740a84f7dc51b5740266c8bf0d88c7f64d0a83b21d1ae4", @@ -284,14 +227,6 @@ "index": "pypi", "version": "==1.4.1" }, - "flask": { - "hashes": [ - "sha256:4efa1ae2d7c9865af48986de8aeb8504bf32c7f3d6fdc9353d34b21f4b127060", - "sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557" - ], - "index": "pypi", - "version": "==1.1.2" - }, "flup": { "hashes": [ "sha256:5eb09f26eb0751f8380d8ac43d1dfb20e1d42eca0fa45ea9289fa532a79cd159", @@ -333,11 +268,11 @@ }, "hypercorn": { "hashes": [ - "sha256:19f32e7267225c8108ad585b2c5deddf1fe75950797a0e87a682a3a00ef1af95", - "sha256:809d77f3bf9fa0794a598d8dfa0f8d889e7e1c2f927581cd33068803169dc474" + "sha256:6540faeba9dd44f7e74c7cc1beae3a438a7efb5f77323d1199457da46d32c2c2", + "sha256:b5c479023757e279f954b46a4ec9dd85e58a2bcbf4d959d5601cbced593e711d" ], "index": "pypi", - "version": "==0.10.2" + "version": "==0.11.0" }, "hyperframe": { "hashes": [ @@ -355,22 +290,6 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.10" }, - "itsdangerous": { - "hashes": [ - "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19", - "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.1.0" - }, - "jinja2": { - "hashes": [ - "sha256:89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0", - "sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==2.11.2" - }, "mako": { "hashes": [ "sha256:8195c8c1400ceb53496064314c6736719c6f25e7479cd24c77be3d9361cddc27", @@ -521,21 +440,6 @@ "index": "pypi", "version": "==0.10.1" }, - "pypng": { - "hashes": [ - "sha256:1032833440c91bafee38a42c38c02d00431b24c42927feb3e63b104d8550170b" - ], - "index": "pypi", - "version": "==0.0.20" - }, - "pyqrcode": { - "hashes": [ - "sha256:1b2812775fa6ff5c527977c4cd2ccb07051ca7d0bc0aecf937a43864abe5eff6", - "sha256:fdbf7634733e56b72e27f9bce46e4550b75a3a2c420414035cae9d9d26b234d5" - ], - "index": "pypi", - "version": "==1.2.1" - }, "python-dateutil": { "hashes": [ "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", @@ -555,21 +459,13 @@ "python-editor": { "hashes": [ "sha256:1bf6e860a8ad52a14c3ee1252d5dc25b2030618ed80c022598f00176adc8367d", - "sha256:ea87e17f6ec459e780e4221f295411462e0d0810858e055fc514684350a2f522", + "sha256:51fda6bcc5ddbbb7063b2af7509e43bd84bfc32a4ff71349ec7847713882327b", "sha256:5f98b069316ea1c2ed3f67e7f5df6c0d8f10b689964a4a811ff64f0106819ec8", "sha256:c3da2053dbab6b29c94e43c486ff67206eafbe7eb52dbec7390b5e2fb05aac77", - "sha256:51fda6bcc5ddbbb7063b2af7509e43bd84bfc32a4ff71349ec7847713882327b" + "sha256:ea87e17f6ec459e780e4221f295411462e0d0810858e055fc514684350a2f522" ], "version": "==1.0.4" }, - "python-telegram-bot": { - "hashes": [ - "sha256:327186c56469216207dcdf8706892e58e0a62e51ef46f5143268e387bbb4edc3", - "sha256:7eebed539ccacf77896cff9e41d1f68746b8ff3ca4da1e2e59285e9c749cb050" - ], - "index": "pypi", - "version": "==12.8" - }, "pytz": { "hashes": [ "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed", @@ -578,14 +474,6 @@ "index": "pypi", "version": "==2020.1" }, - "quart": { - "hashes": [ - "sha256:9c634e4c1e4b21b824003c676de1583581258c72b0ac4d2ba747db846e97ff56", - "sha256:d885d782edd9d5dcfd2c4a56e020db3b82493d4c3950f91c221b7d88d239ac93" - ], - "index": "pypi", - "version": "==0.13.1" - }, "requests": { "hashes": [ "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b", @@ -640,13 +528,6 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.3.19" }, - "telepot": { - "hashes": [ - "sha256:ba123e49e72d0bd471543350c5a3aacd5a7ac38aaf7f0abccaf786936b3ba8b0" - ], - "index": "pypi", - "version": "==12.7" - }, "toml": { "hashes": [ "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f", @@ -654,38 +535,6 @@ ], "version": "==0.10.1" }, - "tornado": { - "hashes": [ - "sha256:0fe2d45ba43b00a41cd73f8be321a44936dc1aba233dee979f17a042b83eb6dc", - "sha256:22aed82c2ea340c3771e3babc5ef220272f6fd06b5108a53b4976d0d722bcd52", - "sha256:2c027eb2a393d964b22b5c154d1a23a5f8727db6fda837118a776b29e2b8ebc6", - "sha256:5217e601700f24e966ddab689f90b7ea4bd91ff3357c3600fa1045e26d68e55d", - "sha256:5618f72e947533832cbc3dec54e1dffc1747a5cb17d1fd91577ed14fa0dc081b", - "sha256:5f6a07e62e799be5d2330e68d808c8ac41d4a259b9cea61da4101b83cb5dc673", - "sha256:c58d56003daf1b616336781b26d184023ea4af13ae143d9dda65e31e534940b9", - "sha256:c952975c8ba74f546ae6de2e226ab3cc3cc11ae47baf607459a6728585bb542a", - "sha256:c98232a3ac391f5faea6821b53db8db461157baa788f5d6222a193e9456e1740" - ], - "markers": "python_version >= '3.5'", - "version": "==6.0.4" - }, - "totalvoice": { - "hashes": [ - "sha256:02fe61398b49a22497e009863f1a5320bb67c9407c592f2fe51bfeebcfb9dedb", - "sha256:7146a2da334b2fe9a688036023f2b56ecc4b7ba337c1953150b79db01a260fca" - ], - "index": "pypi", - "version": "==1.6.0" - }, - "typing-extensions": { - "hashes": [ - "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918", - "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c", - "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f" - ], - "markers": "python_version < '3.8'", - "version": "==3.7.4.3" - }, "ujson": { "hashes": [ "sha256:0784f35f2ace41ed55c435ee11f9d9877cf3e6ff03c8850f87504cb93e9a9469", @@ -744,14 +593,6 @@ "index": "pypi", "version": "==0.18.1" }, - "werkzeug": { - "hashes": [ - "sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43", - "sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==1.0.1" - }, "wsproto": { "hashes": [ "sha256:614798c30e5dc2b3f65acc03d2d50842b97621487350ce79a80a711229edfa9d", @@ -762,34 +603,26 @@ }, "yarl": { "hashes": [ - "sha256:040b237f58ff7d800e6e0fd89c8439b841f777dd99b4a9cca04d6935564b9409", - "sha256:17668ec6722b1b7a3a05cc0167659f6c95b436d25a36c2d52db0eca7d3f72593", - "sha256:3a584b28086bc93c888a6c2aa5c92ed1ae20932f078c46509a66dce9ea5533f2", - "sha256:4439be27e4eee76c7632c2427ca5e73703151b22cae23e64adb243a9c2f565d8", - "sha256:48e918b05850fffb070a496d2b5f97fc31d15d94ca33d3d08a4f86e26d4e7c5d", - "sha256:9102b59e8337f9874638fcfc9ac3734a0cfadb100e47d55c20d0dc6087fb4692", - "sha256:9b930776c0ae0c691776f4d2891ebc5362af86f152dd0da463a6614074cb1b02", - "sha256:b3b9ad80f8b68519cc3372a6ca85ae02cc5a8807723ac366b53c0f089db19e4a", - "sha256:bc2f976c0e918659f723401c4f834deb8a8e7798a71be4382e024bcc3f7e23a8", - "sha256:c22c75b5f394f3d47105045ea551e08a3e804dc7e01b37800ca35b58f856c3d6", - "sha256:c52ce2883dc193824989a9b97a76ca86ecd1fa7955b14f87bf367a61b6232511", - "sha256:ce584af5de8830d8701b8979b18fcf450cef9a382b1a3c8ef189bedc408faf1e", - "sha256:da456eeec17fa8aa4594d9a9f27c0b1060b6a75f2419fe0c00609587b2695f4a", - "sha256:db6db0f45d2c63ddb1a9d18d1b9b22f308e52c83638c26b422d520a815c4b3fb", - "sha256:df89642981b94e7db5596818499c4b2219028f2a528c9c37cc1de45bf2fd3a3f", - "sha256:f18d68f2be6bf0e89f1521af2b1bb46e66ab0018faafa81d70f358153170a317", - "sha256:f379b7f83f23fe12823085cd6b906edc49df969eb99757f58ff382349a3303c6" + "sha256:04a54f126a0732af75e5edc9addeaa2113e2ca7c6fce8974a63549a70a25e50e", + "sha256:3cc860d72ed989f3b1f3abbd6ecf38e412de722fb38b8f1b1a086315cf0d69c5", + "sha256:5d84cc36981eb5a8533be79d6c43454c8e6a39ee3118ceaadbd3c029ab2ee580", + "sha256:5e447e7f3780f44f890360ea973418025e8c0cdcd7d6a1b221d952600fd945dc", + "sha256:61d3ea3c175fe45f1498af868879c6ffeb989d4143ac542163c45538ba5ec21b", + "sha256:67c5ea0970da882eaf9efcf65b66792557c526f8e55f752194eff8ec722c75c2", + "sha256:6f6898429ec3c4cfbef12907047136fd7b9e81a6ee9f105b45505e633427330a", + "sha256:7ce35944e8e61927a8f4eb78f5bc5d1e6da6d40eadd77e3f79d4e9399e263921", + "sha256:b7c199d2cbaf892ba0f91ed36d12ff41ecd0dde46cbf64ff4bfe997a3ebc925e", + "sha256:c15d71a640fb1f8e98a1423f9c64d7f1f6a3a168f803042eaf3a5b5022fde0c1", + "sha256:c22607421f49c0cb6ff3ed593a49b6a99c6ffdeaaa6c944cdda83c2393c8864d", + "sha256:c604998ab8115db802cc55cb1b91619b2831a6128a62ca7eea577fc8ea4d3131", + "sha256:d088ea9319e49273f25b1c96a3763bf19a882cff774d1792ae6fba34bd40550a", + "sha256:db9eb8307219d7e09b33bcb43287222ef35cbcf1586ba9472b0a4b833666ada1", + "sha256:e31fef4e7b68184545c3d68baec7074532e077bd1906b040ecfba659737df188", + "sha256:e32f0fb443afcfe7f01f95172b66f279938fbc6bdaebe294b0ff6747fb6db020", + "sha256:fcbe419805c9b20db9a51d33b942feddbf6e7fb468cb20686fd7089d4164c12a" ], "markers": "python_version >= '3.5'", - "version": "==1.5.1" - }, - "youtube-dl": { - "hashes": [ - "sha256:012de159061570a6107e2da9a24d9ce628f045604471192f4b66236a6915a1f8", - "sha256:67fb9bfa30f5b8f06227c478a8a6ed04af1f97ad4e81dd7e2ce518df3e275391" - ], - "index": "pypi", - "version": "==2020.9.20" + "version": "==1.6.0" } }, "develop": {} diff --git a/app.py b/app.py old mode 100755 new mode 100644 diff --git a/matebot/discord_matebot/__init__.py b/matebot/discord_matebot/__init__.py index aa72dfd..8fe60cc 100644 --- a/matebot/discord_matebot/__init__.py +++ b/matebot/discord_matebot/__init__.py @@ -36,6 +36,7 @@ ## https://discord.com/developers/docs/intro ## https://discordpy.readthedocs.io/en/latest/ import discord +from discord import errors ### Discord MateBot from matebot.discord_matebot import ( @@ -43,18 +44,230 @@ # ~ views, controllers, ) -from matebot.discord_matebot.controllers.client import MateClient +from matebot.discord_matebot.controllers.clients import MateBot from matebot.discord_matebot.controllers.events import add_events def app(bot_name): try: - client = MateClient(config = config, name = bot_name) - add_events(client) - client.run(config.bots[bot_name]['token'] or '') + bot = MateBot(command_prefix="!", config = config, name = bot_name) + add_events(bot) + bot.run(config.bots[bot_name]['token'] or '') except KeyError as exception: logging.warning(u"""Problema com o arquivo de configuração. Já lerdes o man\ ual? Fizerdes tudo certo? Se tiverdes certeza de que está tudo certo e não func\ iona, pede ajuda no Github, no Telegram, no Discord, enfim...\nChave que não fo\ i encontrada no arquivo de configuração: {}""".format(str(exception))) + except errors.LoginFailure: + logging.warning(u"""Token não existe ou está errada. Favor consultar o manu\ +al do Discord.""") except Exception as exception: logging.warning(u"Deu Errado: {}".format(repr(exception))) + +### Código do Pedrinho +### FIXME portar tudo pro plugin nsa20 +# ~ get.user +# ~ if user.database = true: //ve se o usuario ja esta registrado no banco de dados +# ~ print('Posso te ajudar?') +# ~ else: //ou se ele é um novo usuário que precisa ser registrado +# ~ printf('você é da Equipe de Controle ou Participante?') +# ~ if answer=Equipe de Controle or Controle: +# ~ print('digite o seu e-mail de registro:') +# ~ get.email +# ~ if (email=user.moderadores): //verifica se tem registro de admin //será uma lista de emails de quem é admin +# ~ print('tamo junto. vamos começar essa missão. preciso que tu me responda umas perguntas...' +# ~ print('posso utilizar os seus dados para melhorar sua experiência na maratona de inovação NASA Space Apps Challenge 2020? Nós precisamos do seu nome, sobrenome, idade, email, cargo, estado do brasil e cidade escolhida. Você nós dá permisão? sim ou não?') //para estar de acordo com LGPD +# ~ if answer=sim: +# ~ print('qual sem nome?): +# ~ set.nome.user +# ~ print('qual seu sobrenome?): +# ~ set.sobrenome.user +# ~ print('qual sua idade?): +# ~ set.idade.user +# ~ print('qual seu email?): +# ~ set.email.user +# ~ print('qual seu cargo? +# ~ print('[emoji-brain] - mentor') +# ~ print('[emoji-anatomical_heart]') +# ~ print('[emoji-eye] - operação') +# ~ if [emoji-brain]: //coloca a pessoa no cargo que ela disse ser +# ~ roleVer = '[emoji-brain]' //role to add +# ~ user = ctx.message.author //user +# ~ role = roleVer //change the name from roleVer to role +# ~ await ctx.send("""Tentando Verificar {}""".format(user))try: +# ~ await user.add_roles(discord.utils.get(user.guild.roles, name=role)) +# ~ //add the role +# ~ except Exception as e: +# ~ await ctx.send('Rolou problema rodando esse comando..' + str(e)) +# ~ //if error +# ~ else: +# ~ await ctx.send("""Verificado!: {}""".format(user)) +# ~ //no errors, say verified + +# ~ if [emoji-anatomical_heart] //coloca a pessoa no cargo que ela disse ser +# ~ roleVer = '[emoji-brain]' //role to add +# ~ user = ctx.message.author //user +# ~ role = roleVer //change the name from roleVer to role +# ~ await ctx.send("""Tentando Verificar {}""".format(user))try: +# ~ await user.add_roles(discord.utils.get(user.guild.roles, name=role)) +# ~ //add the role +# ~ except Exception as e: +# ~ await ctx.send('Rolou problema rodando esse comando..' + str(e)) +# ~ //if error +# ~ else: +# ~ await ctx.send("""Verificado!: {}""".format(user)) +# ~ //no errors, say verified + +# ~ if [emoji-eye] //coloca a pessoa no cargo que ela disse ser +# ~ roleVer = '[emoji-eye]' //role to add +# ~ user = ctx.message.author //user +# ~ role = roleVer //change the name from roleVer to role +# ~ await ctx.send("""Tentando Verificar {}""".format(user))try: +# ~ await user.add_roles(discord.utils.get(user.guild.roles, name=role)) +# ~ //add the role +# ~ except Exception as e: +# ~ await ctx.send('Rolou problema rodando esse comando..' + str(e)) +# ~ //if error +# ~ else: +# ~ await ctx.send("""Verificado!: {}""".format(user)) +# ~ //no errors, say verified +# ~ printf(qual seu estado?) +# ~ set.estado.user +# ~ printf(qual sua cidade?) +# ~ set.cidade.user +# ~ print ('Essas são as principais dúvidas e informações gerais do hackathon: [inserir links gerais do hackathon]. Você tem mais alguma dúvida? sim ou não') +# ~ if answer=sim: +# ~ loop (FAQ) //entra no modo perguntas e respostas que podemos desenvolver +# ~ else: +# ~ loop return loop (bot.on) +# ~ else answer=não: +# ~ return loop (bot.on) +# ~ else('ops... um impostor... volte para o começo!'): +# ~ client.channels.get(`alertas`).send(`aviso de tentativa de invasao feita pelo usuário`+get.user) //informa ao canal alerta que fulaninho tentou invadir +# ~ return loop (bot.on) //volta pro inicio do algoritmo +# ~ if answer=Participante: +# ~ print('posso utilizar os seus dados para melhorar sua experiência na maratona de inovação NASA Space Apps Challenge 2020? Nós precisamos do seu nome, sobrenome, idade, email, cargo, estado do brasil e cidade escolhida. Você nós dá permisão? sim ou não?') //para estar de acordo com LGPD +# ~ if answer=sim: +# ~ print('qual sem nome?): +# ~ set.nome.user +# ~ print('qual seu sobrenome?): +# ~ set.sobrenome.user +# ~ print('qual sua idade?): +# ~ set.idade.user +# ~ print('qual seu email?): +# ~ set.email.user +# ~ print('qual seu cargo? +# ~ print('[emoji-woman_technologist] - desenvolvedor') +# ~ print('[emoji-woman_artist] - designer') +# ~ print('[emoji-woman_cientist] - cientista') +# ~ print('[emoji-woman_in_tuxedo] - negócios') +# ~ if [emoji-woman_technologist]: //coloca a pessoa no cargo que ela disse ser +# ~ roleVer = '[emoji-woman_technologist]' //role to add +# ~ user = ctx.message.author //user +# ~ role = roleVer //change the name from roleVer to role +# ~ await ctx.send("""Tentando Verificar {}""".format(user))try: +# ~ await user.add_roles(discord.utils.get(user.guild.roles, name=role)) +# ~ //add the role +# ~ except Exception as e: +# ~ await ctx.send('Rolou problema rodando esse comando..' + str(e)) +# ~ //if error +# ~ else: +# ~ await ctx.send("""Verificado!: {}""".format(user)) +# ~ //no errors, say verified + +# ~ if [emoji-woman_artist]: //coloca a pessoa no cargo que ela disse ser +# ~ roleVer = '[emoji-woman_artist]' //role to add +# ~ user = ctx.message.author //user +# ~ role = roleVer //change the name from roleVer to role +# ~ await ctx.send("""Tentando Verificar {}""".format(user))try: +# ~ await user.add_roles(discord.utils.get(user.guild.roles, name=role)) +# ~ //add the role +# ~ except Exception as e: +# ~ await ctx.send('Rolou problema rodando esse comando..' + str(e)) +# ~ //if error +# ~ else: +# ~ await ctx.send("""Verificado!: {}""".format(user)) +# ~ //no errors, say verified + +# ~ if [emoji-woman_cientist]: //coloca a pessoa no cargo que ela disse ser +# ~ roleVer = '[emoji-woman_cientist]' //role to add +# ~ user = ctx.message.author //user +# ~ role = roleVer //change the name from roleVer to role +# ~ await ctx.send("""Tentando Verificar {}""".format(user))try: +# ~ await user.add_roles(discord.utils.get(user.guild.roles, name=role)) +# ~ //add the role +# ~ except Exception as e: +# ~ await ctx.send('Rolou problema rodando esse comando..' + str(e)) +# ~ //if error +# ~ else: +# ~ await ctx.send("""Verificado!: {}""".format(user)) +# ~ //no errors, say verified + +# ~ if [emoji-woman_in_tuxedo]: //coloca a pessoa no cargo que ela disse ser +# ~ roleVer = '[emoji-woman_in_tuxedo]' //role to add +# ~ user = ctx.message.author //user +# ~ role = roleVer //change the name from roleVer to role +# ~ await ctx.send("""Tentando Verificar {}""".format(user))try: +# ~ await user.add_roles(discord.utils.get(user.guild.roles, name=role)) +# ~ //add the role +# ~ except Exception as e: +# ~ await ctx.send('Rolou problema rodando esse comando..' + str(e)) +# ~ //if error +# ~ else: +# ~ await ctx.send("""Verificado!: {}""".format(user)) +# ~ //no errors, say verified + +# ~ printf(qual seu estado?) +# ~ set.estado.user +# ~ printf(qual sua cidade?) +# ~ set.cidade.user +# ~ print ('Essas são as principais dúvidas e informações gerais do hackathon: [inserir links gerais do hackathon]') +# ~ print ('Agora que você está registrado. Precisamos colocar você na sua equipe!') +# ~ print ('Você já tem uma equipe formada? sim ou não?') +# ~ if answer=sim: //ja tem uma equipe +# ~ print('marque todos os seus amigxs abaixo: [para isso é só colocar @nomedousuario]') +# ~ def on_message(message): //ve quem ele colocou, procura o time em que eles +# ~ //estao e coloca o usuario nesse canal de texto +# ~ //e no canal de voz +# ~ find.text_channel=user +# ~ if '!MOVE' in message.content.upper(): +# ~ author = message.author +# ~ await client.move_member(author, text_channel) +# ~ else: //grupo ainda nao foi criado +# ~ print('Parece que ninguém criou esse grupo ainda') +# ~ get.user.estado //pega estado para saber em qual regiao vai criar o time +# ~ bot.createChannel(server,name) //cria canal_texto no servidor da regiãoBR +# ~ print('marque todos os seus amigxs abaixo: [para isso é só colocar @nomedousuario. Se ele ainda não está registrado no discord, manda pra ele esse link: [inserir link de convite do Discord]') +# ~ client.channels.get(`channelID`).send(`Text`) //o robo manda essa mesma //mensagem que o usuário mandou para o canal que foi criado para o time, //marcando todos membros no novo canal_texto. Trocar channelID pelo ID do //novo canal da equipe e Text pelos nomes dos users que ele mandou e //estão no mesmo grupo. +# ~ client.channels.get(`channelID`).send(`Essas são as principais dúvidas e informações gerais do hackathon: [inserir links gerais do hackathon]. Você tem mais alguma dúvida? sim ou não') +# ~ if answer sim: +# ~ loop (FAQ) //entra no modo FAQ que podemos desenvolver +# ~ else: +# ~ loop return loop (bot.on) +# ~ else: // usuário não tem equipe nenhuma +# ~ // algoritmo deve colocar o usuario no canal procuro-time da regiãoBR escolhida +# ~ //no canal preciso de time o usuário deverá escolher um dos 22 desafios +# ~ //(1 emoji pra cada desafio) +# ~ //e sempre que fechar 4 pessoas votando no mesmo emoji, cria um canal de texto +# ~ //e outro canal de voz com essas 4 pessoas, essa é a equipe +# ~ else: +# ~ return loop (bot.on) +# ~ else +# ~ return loop (bot.on) +# ~ else +# ~ return loop (bot.on) +# ~ } catch (err) { + # ~ // There are various reasons why sending a message may fail. + # ~ // The API might time out or choke and return a 5xx status, + # ~ // or the bot may not have permission to send the + # ~ // message (403 status). + # ~ console.warn('Failed to respond to mention.'); + # ~ console.warn(err); + # ~ } + # ~ } +# ~ }); + +# ~ bot.on('error', err => { + # ~ console.warn(err); +# ~ }); + +# ~ bot.connect(); diff --git a/matebot/discord_matebot/controllers/client.py b/matebot/discord_matebot/controllers/client.py deleted file mode 100644 index 0b2c0cc..0000000 --- a/matebot/discord_matebot/controllers/client.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Matebot -# -# Copyleft 2012-2020 Iuri Guilherme , -# Matehackers -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# - -import logging, sys - -from discord import ( - Client, - errors, -) - -class MateClient(Client): - def __init__(self, *args, **kwargs): - ## Tratando as configurações - config = kwargs.get('config') - name = kwargs.get('name', 'matebot') - setattr(self, 'config_info', - config.bots[name]['info'] or config.default_bot['info']) - setattr(self, 'config_plugins', - config.bots[name]['plugins'] or config.default_bot['plugins']) - setattr(self, 'config_users', - config.bots[name]['users'] or config.default_bot['users']) - kwargs.pop('config', None) - kwargs.pop('name', None) - super().__init__(*args, **kwargs) - - ## Tratamento de erros - async def on_error(event, *args, **kwargs): - logging.warning( - u"event: {}\n\nargs: {}\n\nkwargs: {}\n\nexception: {}".format( - str(event), - str(args), - str(kwargs), - str(sys.exc_info()), - ) - ) - try: - raise - except errors.LoginFailure: - logging.warning(u"""Token não existe ou está errada. Favor consultar o ma\ -nual do Discord.""") - except Exception as exception: - logging.warning(u"Deu Errado: {}".format(repr(exception))) - super().on_error(event, *args, **kwargs) - diff --git a/matebot/discord_matebot/controllers/clients.py b/matebot/discord_matebot/controllers/clients.py new file mode 100644 index 0000000..4206b47 --- /dev/null +++ b/matebot/discord_matebot/controllers/clients.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- +# +# Matebot +# +# Copyleft 2012-2020 Iuri Guilherme , +# Matehackers +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +import json, logging, sys + +from discord import ( + Client, + errors, +) +from discord.ext.commands import Bot +from matebot.discord_matebot.controllers.events import add_events + +class MateClient(Client): + def __init__(self, *args, **kwargs): + ## Tratando as configurações + config = kwargs.get('config') + name = kwargs.get('name', 'matebot') + setattr(self, 'config_info', + config.bots[name]['info'] or config.default_bot['info']) + setattr(self, 'config_plugins', + config.bots[name]['plugins'] or config.default_bot['plugins']) + setattr(self, 'config_users', + config.bots[name]['users'] or config.default_bot['users']) + kwargs.pop('config', None) + kwargs.pop('name', None) + super().__init__(*args, **kwargs) + add_events(self) + + async def on_message(*args, **kwargs): + logging.info(u"""Mensagem de {author} no canal #{channel} do servidor {guil\ +d}: {content}""".format( + author = args[1].author or '', + channel = args[1].channel or '', + guild = args[1].guild or '', + content = args[1].content or '', + ) + ) + + ## Mensagens apagadas + ## Ver também: + ## on_bulk_message_delete + ## on_raw_message_delete + ## on_raw_bulk_message_delete + @bot.event + async def on_message_delete(message): + logging.info(u"Mesagem apagada: {}".format(message)) + + ## Mensagem atualizada + @bot.event + async def on_message_edit(before, after): + logging.info(u"Mesagem atualizada. Era: {0}\n\nAgora: {1}".format( + before, after)) + + ## Reações + @bot.event + async def on_reaction_add(reaction, user): + logging.info(u"Reação de {0} em {1}:\n\n{2}".format( + user, reaction.message, reaction)) + @bot.event + async def on_reaction_remove(reaction, user): + logging.info(u"Reação removida de {0} em {1}:\n\n{2}".format( + user, reaction.message, reaction)) + + ## Servidores + @bot.event + async def on_guild_join(guild): + logging.info(u"Entramos no servidor {}".format(guild)) + @bot.event + async def on_guild_remove(guild): + logging.info(u"Saímos do servidor {}".format(guild)) + + ## Usuários + @bot.event + async def on_member_join(member): + logging.info(u"{} entrou no servidor".format(member)) + async def on_member_remove(member): + logging.info(u"{} saiu do servidor".format(member)) + + ## Tratamento de erros + async def on_error(event, *args, **kwargs): + logging.warning( + u"event: {0}\n\nargs: {1}\n\nkwargs: {2}\n\nexception: {3}".format( + str(event), + str(args), + str(kwargs), + str(sys.exc_info()), + ) + ) + await super().on_error(event, *args, **kwargs) + +class MateBot(Bot): + async def on_error(event, *args, **kwargs): + logging.warning( + u"event: {0}\n\nargs: {1}\n\nkwargs: {2}\n\nexception: {3}".format( + str(event), + str(args), + str(kwargs), + str(sys.exc_info()), + ) + ) + await super().on_error(event, *args, **kwargs) + + diff --git a/matebot/discord_matebot/controllers/events.py b/matebot/discord_matebot/controllers/events.py index f44e713..75d1a23 100644 --- a/matebot/discord_matebot/controllers/events.py +++ b/matebot/discord_matebot/controllers/events.py @@ -23,59 +23,17 @@ import logging -from discord import Client +from discord.ext.commands import Bot +from matebot.plugins import nsa20 -def add_events(client: Client): - @client.event +def add_events(bot: Bot): + ## Nasa Space Apps 2020 + nsa20.add_commands(bot) + @bot.command() + async def design(ctx): + await ctx.send(u"digite !design se você é designer ou web designer;") + + @bot.event async def on_ready(): logging.info(u"""Conectada com sucesso, o nosso nome de usuário é {0.user}\ -""".format(client)) - - ## Trata todas as mensagens menos a do próprio bot - @client.event - async def on_message(message): - if message.author == client.user: - return - logging.info(u"Mensagem de {0.author}: {0.content}".format(message)) - if message.content.startswith('$hello'): - await message.channel.send('Hello!') - - ## Mensagens apagadas - ## Ver também: - ## on_bulk_message_delete - ## on_raw_message_delete - ## on_raw_bulk_message_delete - @client.event - async def on_message_delete(message): - logging.info(u"Mesagem apagada: {}".format(message)) - - ## Mensagem atualizada - @client.event - async def on_message_edit(before, after): - logging.info(u"Mesagem atualizada. Era: {0}\n\nAgora: {1}".format( - before, after)) - - ## Reações - @client.event - async def on_reaction_add(reaction, user): - logging.info(u"Reação de {0} em {1}:\n\n{2}".format( - user, reaction.message, reaction)) - @client.event - async def on_reaction_remove(reaction, user): - logging.info(u"Reação removida de {0} em {1}:\n\n{2}".format( - user, reaction.message, reaction)) - - ## Servidores - @client.event - async def on_guild_join(guild): - logging.info(u"Entramos no servidor {}".format(guild)) - @client.event - async def on_guild_remove(guild): - logging.info(u"Saímos do servidor {}".format(guild)) - - ## Usuários - @client.event - async def on_member_join(member): - logging.info(u"{} entrou no servidor".format(member)) - async def on_member_remove(member): - logging.info(u"{} saiu do servidor".format(member)) +""".format(bot)) diff --git a/matebot/plugins/nsa20.py b/matebot/plugins/nsa20.py new file mode 100644 index 0000000..5e27c9c --- /dev/null +++ b/matebot/plugins/nsa20.py @@ -0,0 +1,47 @@ +# vim:fileencoding=utf-8 +# Plugin nsa20 para matebot: NASA Space Apps Challenge +# Copyleft (C) 2020 Iuri Guilherme, 2020 Fábrica do Futuro +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from discord.ext.commands import Bot + +def add_commands(bot: Bot): + @bot.command() + async def desenvolvimento(ctx): + await ctx.send(u"digite !desenvolvimento se você for desenvolvedor de sistemas;") + + @bot.command() + async def design(ctx): + await ctx.send(u"digite !design se você é designer ou web designer;") + + @bot.command() + async def negocios(ctx): + await ctx.send(u"digite !negocios se você for da área comercial, empreendedor, gestor, etc;") + + @bot.command() + async def mkt(ctx): + await ctx.send(u"digite !mkt se você é da área de marketing ou publicidade;") + + @bot.command() + async def cientista_de_dados(ctx): + await ctx.send(u"digite !cientista_de_dados se for o seu caso;") + + @bot.command() + async def outros(ctx): + await ctx.send(u"digite !outros se sua área de atuação não se encaixa em nenhum dos perfis acima :wink: ") + + @bot.event + async def on_member_join(member): + logging.info(u"{} entrou no servidor".format(member))