Code Monkey home page Code Monkey logo

cloudbot's People

Contributors

a-underscore-d avatar antdking avatar archaicmotion avatar blaneyxyz avatar blha303 avatar daboross avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dmptrluke avatar dsphat avatar edillingham avatar edwardslabs avatar elonsatoshi avatar flotwig avatar ilgnome avatar ksaredfx avatar linuxdaemon avatar manyraptors avatar mwscanlon avatar n7st avatar nasonfish avatar neersighted avatar qczar avatar starsparrow avatar suzip avatar thenoodle68 avatar threewaffles avatar typoguy avatar vault108 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudbot's Issues

LIKE operator causing problems with underscores in usernames when using .seen command

Checking when users were last online using the .seen <nick> command, the LIKE operator is used in the database lookup. This causes problems when people have underscores in their IRC nicks, because the LIKE operator uses the underscore as a single-character wildcard. In our case, this caused .seen justin_timeforcake to return the output for justin-timeforcake.

If the LIKE operator was being used to allow wildcard searching, a simple solution might be to use GLOB instead.

CloudBot (Gonzobot Branch) loads plugins even if they are in disabled_plugins[]

Example from config.json:

            "disabled_plugins": [
                "animal_gifs",
                "attacks",
                "badwords",
                "bible",
                "cats"

Example from starting gonzobot:


[14:19:19] [INFO] Loaded command bible/passage from bible.py
[14:19:19] [INFO] Loaded command cats from cats.py
[14:19:19] [INFO] Loaded command doggifs from animal_gifs.py
[14:16:33] [INFO] Registering tables for badwords

It loads all 77 plugins that I have disabled...

Edit: having looked through plugin.py, it looks like there is a whitelist and a blacklist. I'll see if I can get this working with whitelist. In the meantime, I'm humbly requesting that these two lines all be changed to indicate whitelist/blacklist instead of "disabled_plugins":

Won't load any plugins listed in "disabled_plugins".

Won't load any plugins listed in "disabled_plugins".

.wiki command returns invalid links.

Edit: woops, .wiki

When links contain non-standard characters that need to be encoded, the bot returns links that cannot be opened.
For examples:
.wiki soufflé
.wiki "Women_are_wonderful"_effect
.wiki José

A little bit of investigation seems to suggest that requests.utils.quote at the end of the wikipedia.py plugin file encodes an already encoded URL (since % is encoded as %25). The URL seems to be already encoded in request.text . Not reencoding the (already encoded) url at the end might suffice to solve the issue.

Error in hook amazon:amazon

Not sure if the plugins are supported or not, but the Amazon plugin does not work.

[09:27:01] [INFO] [network:#channel] <user> .amazon U28E590D
[09:27:02] [ERROR] Error in hook amazon:amazon
Traceback (most recent call last):
  File "/home/james/CloudBot/cloudbot/plugin.py", line 376, in _execute_hook
    out = yield from self.bot.loop.run_in_executor(None, self._execute_hook_threaded, hook, event)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/james/CloudBot/cloudbot/plugin.py", line 340, in _execute_hook_threaded
    return hook.function(*parameters)
  File "/home/james/CloudBot/plugins/amazon.py", line 77, in amazon
    price = item.find('span', {'class': ['s-price', 'a-color-price']}).text
AttributeError: 'NoneType' object has no attribute 'text'

The offending line in amazon.py:

    price = item.find('span', {'class': ['s-price', 'a-color-price']}).text

Pastes for listoptout blocks the entire bot

Tested on Snoonet over two channels:
Channel 1:

[06:27:48] <@A_Dragon> .listoptout #channel
[06:28:19] <gonzobot> (A_Dragon) Unable to paste data

Channel 2:

[06:27:48] <@A_Dragon> .ping 127.0.0.1
[06:28:19] <+gonzobot> (A_Dragon) Attempting to ping 127.0.0.1 5 times...
[06:28:23] <+gonzobot> (A_Dragon) min: 0.013ms, max: 0.030ms, average: 0.023ms, range: 0.007ms, count: 5

Note the timestamps on the commands and the responses. The bot is being blocked globally (including across conns)

Channel 1 (Snoonet):

[06:30:52] <@A_Dragon> .listoptout #channel
[06:31:22] <gonzobot> (A_Dragon) Unable to paste data

Channel 2 (Freenode):

[06:30:52] <A_D> .ping 127.0.0.1
[06:30:52] <gonzobot> (A_D) Attempting to ping 127.0.0.1 5 times...
[06:31:22] <gonzobot> (A_D) min: 0.018ms, max: 0.025ms, average: 0.022ms, range: 0.005ms, count: 5

In the above test case the Freenode first response comes through and then hangs until the paste finishes (in this case finishing is a failure)

Coroutine hooks not recognized in asyncio debug mode

When launching the bot with the environment variable PYTHONASYNCIODEBUG set to 1, the hook system no longer recognizes coroutine hook functions as such and instead treats them as normal function, leading to "undefined behavior".

Probable Cause

When debug mode is enabled, the @asyncio.coroutine decorator wraps the function completely instead of just patching data to it like it does in normal mode. This means the reference to the function the hook decorator stores isn't changed only replaced.

Potential Fix (workaround)

  • Reorder hook function decorators
  • Add unit tests to verify proper order

Multiple plugins are having JSON decoding errors

Distro Information:

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial

Python 3.5.2
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)

[01:21:35] [INFO] [techtronix:#lounge] <Techman> .wa 5+5
[01:21:36] [ERROR] Error in hook wolframalpha:wolframalpha
Traceback (most recent call last):
  File "/home/ircd/Cloudbot/cloudbot/plugin.py", line 483, in internal_launch
    out = yield from task
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/ircd/Cloudbot/cloudbot/plugin.py", line 446, in _execute_hook_threaded
    return hook.function(*parameters)
  File "/home/ircd/Cloudbot/plugins/wolframalpha.py", line 43, in wolframalpha
    short_url = web.try_shorten(query_url.format(urllib.parse.quote_plus(text)))
  File "/home/ircd/Cloudbot/cloudbot/util/web.py", line 67, in try_shorten
    return impl.try_shorten(url, custom, key)
  File "/home/ircd/Cloudbot/cloudbot/util/web.py", line 109, in try_shorten
    return self.shorten(url, custom, key)
  File "/home/ircd/Cloudbot/cloudbot/util/web.py", line 154, in shorten
    j = r.json()
  File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[01:21:42] [INFO] [techtronix:#lounge] <Techman> nope, still errors

.time command doesn't take time zones as an argument

It would make sense to be able to use a time zone as argument to the .time command. Some simple format like "UTC+3" would suffice for me, but people in the US might prefer to use time zone names like "EET", "CST" and so on.

If I get the time and interest I might make a pull request myself.

Spotify api error

Seems like spotify are enforcing access tokens on all endpoint references thus breaking the plugin completely.

Feature request: sick people need soup

How to reproduce issue:

go to IRC channel on snoonet with gonzobot in it

type ".soup foobar"

expected result:

  • Gonzobot serves foobar a steaming bowl of chicken soup with wild rice and peppers

actual result:

crickets

Provide a way to have users connect nicknames with reddit accounts

Allowing users to connect there nick to there reddit account, when there IRC nick and reddit nick are not the same, would provide a bunch of advantages. First of all, .karma would return there real reddit karma, rather than usually the karma of some other Reddit user. Secondly, if a mod bans someone from IRC, it would be nice to look up what Reddit accounts they're associated with, to perhaps take action on the sub as well.

The way I'd propose doing this:

  1. Have a .connect command. When the user sends this command, gonzobot private messages her with an oAuth link from reddit, so she can prove she owns the account she's connecting.

  2. Change .karma so it checks to see if the nickname has a reddit account connected. If so, return the karma from that account. If the nickname is given with a /u/ prefix, instead assume that the karma of that exact reddit user is wanted.

  3. Eventually, other super cool features could be added. For example, chan ops could set gonzobot to op other mods of the sub there channel is associated with, once they connect there accounts.

Of course, the .connect and other features should probably only be enabled for nicknames that have been set up with nickserv, for obvious reasons.

whois.py has trouble with "new" tld's

Such as .date, .party etc

File "/home/Cloudbot/Cloudbot/plugins/whois.py", line 33, in whois
    info.append("\x02Registrant\x02: {} - \x02{}\x02".format(data["contacts"]["registrant"]["name"], data["contacts"]["registrant"]["email"]))
TypeError: 'NoneType' object is not subscriptable

Auto reload plugins on change?

How can I auto reload any plugins thats been changed? Currently I have to manually reload them using !pluginload plugins/plugin.py

Refactor: link_announcer.py blacklist

blacklist = '.*(reddit\.com|redd\.it|youtube\.com|youtu\.be|imdb\.com|spotify\.com|twitter\.com|twitch\.tv|amazon\.co|xkcd\.com|amzn\.co|steamcommunity\.com|steampowered\.com|newegg\.com|soundcloud\.com|vimeo\.com).*'

This line is getting pretty lengthy, it would be nice to see this refactored in some way.

My idea for this is that we could add some sort of hook which individual plugins could call to add their URLs to the blacklist.

So for example, in spotify.py, we could do something like this:

@hook.url_blacklist("spotify.com")

And the same for each plugin which snarfs URLs.

That would move the hard-coded URLs out of the link announcer code and into the plugins which duplicate the snarfing functionality, which would be cleaner.

User Account System

Building off the ideas in #200 I think a system where users can authenticate to the bot in some way may be a good idea. Basically it would be some way for a person to prove their identity for things like duckhunt, heralds, etc.

Possible implementations

  • Using NickServ account information from the network
  • A username/password system where the user has to manually log in

Any suggestions or requests are appreciated.

Dice roll math possibly inaccurate

We currently can not prove that

return [int(random.normalvariate(.5 * (1 + n) * count,
(((n + 1) * (2 * n + 1) / 6. -
(.5 * (1 + n)) ** 2) * count) ** .5))]

fairly calculates the sum of count rolls of n-sided dice. This method for 'faking' the rolls may be able to be cleaned up and improved.

Character code causing issues rendering messages

The ASCII character "8203" or u'\u200b' (which just looks like a space) causes issues with rendering of a message while using weechat (v1.2 and v1.3 (latest stable as of right now)).

This character is most seen with duckhunt and also herald.

Once the character is in a message it will cut off all text from after that point.

Example:
gonzobot bug screenshot

The first line is a herald, and the second is what happens to a "duck".

Have bot perform specified action every 5 minutes

I have experience writing plugins for SkyBot (not CloudBot) and would like to write a plugin for this bot that does a specific action every 5 minutes. Is there a timer hook built into CloudBot?

Feature Request: Grab previous lines

Unfortunately chat can move quick making .grab difficult to use. Would it be possible to implement a feature to grab a line that was said n lines back (eg, grab 2 username to grab 2 lines back instead of last line)?

Certain hook errors not being logged by chan_log.py

Many plugins implement their own error handling in varying ways, resulting in an inconsistent amount of information being logged about certain issues. Multiple plugins either only log generic error messages or completely disregard all errors. Some even use bare except: statements, leading to undefined behavior with some iterators in certain cases due to the fact that except: will match any thrown exception, not just those that subclass Exception (eg. SystemExit, KeyboardInterrupt, GeneratorExit, StopIteration).

The lack of standardized error logging in plugins makes tracking down issues just that much more difficult. A more extensive error logging system would allow more run time inspection of issues, instead of attempting to replicate them later in a test environment.

Main Issues

  • Plugins suppressing exceptions with broad except clauses
  • Sieve hook errors are not logged at all
  • Many plugins only return a generic error message and don't log the error any further

Amazon URLs sometimes display the wrong items

Amazon URLs are parsed and then the product ID is searched for in the normal search method, this appears to break sometimes and should most likely be replaced by just scraping the URL the user pasted.

Duck score sometimes shows incorrectly if there is points in only one channel

Steps to reproduce:

  1. Have a user with bef or kill points in only one channel
  2. query the duck score of the user with .duck USERNAME in another channel.
  3. the user is shown as having no points.

possible solutions

at this place,
check if the location is the current channel too. That way the code will not return here and continue to the next formatting which is correct.

Guns don't work like they should in duck hunt

<gonzobot> ・゜゜・。。・゜ ​ ゜\_ó<​ Q​UACK!
<frostyfrog> .bef
<gonzobot> (frostyfrog) Who knew ducks could be so picky? You can try again in 7 seconds.
<frostyfrog> .bang
-gonzobot- You are in a cool down period, you can try again in 1.8953230381011963 seconds.
<frostyfrog> ...
<frostyfrog> cooldown period?
<frostyfrog> no fair!
<frostyfrog> I have a gun!

I feel cheated out of a good duck.

Reddit plugin command syntax inconsistent with others

Example:

2018-03-08 16:27:17	desgen	.sub /r/techsupport
2018-03-08 16:27:17	gonzobot	/r/techsupport - TechSupport - a community for 9y, there are 198,175 subscribers and 994 people online now.
2018-03-08 16:27:22	desgen	.sub techsupport
2018-03-08 16:27:22	gonzobot	/r/techsupport - TechSupport - a community for 9y, there are 198,175 subscribers and 994 people online now.
2018-03-08 16:27:32	desgen	.reddit /r/techsupport
2018-03-08 16:27:33	gonzobot	Error: 404 Client Error: Not Found for url: https://www.reddit.com/r//r/techsupport/.json
2018-03-08 16:27:39	desgen	.reddit techsupport
2018-03-08 16:27:40	gonzobot	Setting up a home server to access files/documents remotely? : techsupport - 2 comments, 3 points - scottpressman 35m ago - https://redd.it/830vzt
2018-03-08 16:28:05	desgen	.mods /r/techsupport
2018-03-08 16:28:06	gonzobot	/r/techsupport mods: discobreakin (9y) • Synth3t1c (8y) • g2g079 (7y) • -Mikee (3y) • Kumorigoe (2y) • desgen (1y) • MuffinMedic (304d)
2018-03-08 16:28:10	desgen	.mods techsupport
2018-03-08 16:28:11	gonzobot	/r/techsupport mods: discobreakin (9y) • Synth3t1c (8y) • g2g079 (7y) • -Mikee (3y) • Kumorigoe (2y) • desgen (1y) • MuffinMedic (304d)

Specific error:

2018-03-08 16:27:32	desgen	.reddit /r/techsupport
2018-03-08 16:27:33	gonzobot	Error: 404 Client Error: Not Found for url: https://www.reddit.com/r//r/techsupport/.json

Steps to reproduce:

Specify /r/ before subreddit when using command .reddit

Duckhunt should not be active in query windows

Sorry, I'd totally put in a PR, but I don't know CloudBot well enough. It should have that in the hook params somewhere, no?
Noticed that you can .starthunt in a query window and the bot will happily spawn ducks.
Since that would probably count towards the global stats, it should not be possible. Might want to clean the database too if it was abused already.

[18:02:31]<langerhans> .starthunt
[18:02:32]<gonzobot> Ducks have been spotted nearby. See how many you can shoot or save. use .bang to shoot or .befriend to save them.
[18:21:59]<gonzobot> ・゜ ​ ゜・。。・゜゜\_O<​ FL​AP FLAP!
[18:22:03]<langerhans> .bef
[18:22:03]<gonzobot> langerhans you befriended a duck in 4.266 seconds! You have made friends with 1 duck in langerhans.
[18:22:15]<langerhans> .friends
[18:22:15]<gonzobot> Duck friend scores in langerhans: l​angerhans: 1
[18:23:01]<langerhans> .stophunt
[18:23:01]<gonzobot> the game has been stopped.

Dogpile cert errors

Error occurred in dogpile.dogpileimage
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.dogpile.com', port=443): Max retries exceeded with url: /search/images?<query> (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),))

It seems dogpile's CA isn't trusted by default on Ubuntu, not sure how we want to fix this temporarily or what

SASL Issue When Connecting

I have run into some kind of issue with gonzo recently after doing a git pull from the code I used to run months ago. It gets hung up when trying to do SASL authentication.

pastebin

Feature request: Add duckduckgo and searx commands

I'd like to be able to search open source search engines via gonzobot. Bonus points if I can search images, videos, and files with searx.

Maybe if I ever get my life together I'll learn how to program this myself.

listchans command fails with error

[11:03:39] [INFO] [snoonet:rory] <rory> listchans
[11:03:39] [ERROR] Error in hook admin_bot:listchans
Traceback (most recent call last):
  File "/home/rory/repos/CloudBot/cloudbot/plugin.py", line 376, in _execute_hook
    out = yield from self.bot.loop.run_in_executor(None, self._execute_hook_threaded, hook, event)
  File "/usr/lib/python3.4/asyncio/futures.py", line 386, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 287, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 275, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/rory/repos/CloudBot/cloudbot/plugin.py", line 340, in _execute_hook_threaded
    return hook.function(*parameters)
  File "/home/rory/repos/CloudBot/plugins/admin_bot.py", line 390, in listchans
    lines = formatting.chunk_str("I am currently in: {}".format(chans))
NameError: name 'formatting' is not defined

.syn command returns URL encoding when used incorrectly

Notice how it returns %20 for space.

desgen  ╡.syn busting balls
<bot> ╡ (desgen) Sorry, I couldn't find any synonyms for busting%20balls.

Suggestion:
Disallow more then one word being used, and if a user does, return the correct syntax usage help:
<bot> ╡ .syn <word> - Returns a list of synonyms for <word>.
Or, alternatively:
<bot> ╡ Only one word can be specified.
Small note:
Noticed the help command doesn't have anything for .syn, old plugin?

Request - Merge / Update Score

Hi, i would like to request a feature so that I can merge score for a user that have 2 or 3 nicks.

For example:
nick1 have scores of 40 kills but sometimes he used nick2 and nick3 for shooting the ducks. And it would be helpful if me (as admin) can update the score for him.

This merge feature should cater to kill and befriend. Thanks!

Removal of python 3.4 support

Many libraries (eg. yarl) have begun dropping python 3.4 support to support type hinting. The final release of 3.4 is also expected in March 2019. If we can migrate away from supporting 3.4 it will allow us to use newer features and syntax as well as updated libraries.

Are there any major drawbacks to dropping 3.4 support? Does anyone even run 3.4 anymore?

Adding a command to "give" other commands to users

Similair to the newly added chain-command, having a !give <user> <command> [args..] would be a neat feature.

Example:

input:
.give User1 !youtube Awesome cat videos

output:

<Bot> User1 <output from !youtube Awesome cat videos>

Maybe have a command similair to chainallow that allows certain commands to be given

Make .etym command append link to full article

Currently, the .etym command outputs an article (or part of an article if its long enough), but does not include a link to the article. For example,

.etym frog

will output

frog (n.1) Old English frogga "frog," a diminutive of frosc, forsc, frox "frog," a common Germanic word but with different formations that are difficult to explain (cognates: Old Norse froskr, Middle Dutch vorsc, German Frosch "frog"), probably literally "hopper," from PIE root *preu- "to hop" (source also of Sanskrit provate "hops," Russian prygat "to hop, jump"). Watkins calls the Old English ...

The link to the full article is https://www.etymonline.com/word/frog#etymonline_v_14201

Regardless of article length, the output should be limited to X characters with room for a link to the full article at the end. Would it be possible to modify this behavior? Thanks.

duckhunt.py is outputting "channels" twice

Via line 642, .ducks is printing the word channels twice.

Example:

PineApple's duck stats: 2 ducks killed and 499 ducks befriended in #mturkrefugees. Across 3 channels channels: 4 ducks killed and 1,631 ducks befriended. Averaging 1 kill and 543 friends per channel.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.